CleverCloud / clever-tools-dockerhub

Dockerfile for clever-tools CLI
0 stars 1 forks source link

node 18.15 does not play nice with `curl` command #5

Open dgoosens opened 8 months ago

dgoosens commented 8 months ago

hello,

the clever-tools now come with a very nice curl command to interact with the API (without providing the credentials)
this works perfectly well locally but throws an error in the docker image (that I use in the CI)

docker run --rm clevercloud/clever-tools curl -X GET "https://api.clever-cloud.com/v2/oauth/rights" -H "accept: application/json"
node:events:491
      throw er; // Unhandled 'error' event
      ^

Error: spawn curl ENOENT
    at ChildProcess._handle.onexit (node:internal/child_process:283:19)
    at onErrorNT (node:internal/child_process:476:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
Emitted 'error' event on ChildProcess instance at:
    at ChildProcess._handle.onexit (node:internal/child_process:289:12)
    at onErrorNT (node:internal/child_process:476:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawn curl',
  path: 'curl',
  spawnargs: [
    '-X',
    'GET',
    'https://api.clever-cloud.com/v2/oauth/rights',
    '-H',
    'accept: application/json',
    '-H',
    'Authorization: OAuth oauth_consumer_key="***", oauth_nonce="***", oauth_signature="****", oauth_signature_method="HMAC-SHA512", oauth_timestamp="1708523365", oauth_version="1.0"'
  ]
}

Node.js v18.15.0

when building the image with the latest LTS of node (20.11.1), everything is ok.

FROM debian AS build

RUN apt-get update && apt-get install -y \
    libtool \
    curl

RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && apt-get install -y nodejs
RUN ln -s /usr/bin/node /usr/local/bin/nodejs

RUN curl --output clever-tools_linux.tar.gz https://clever-tools.clever-cloud.com/releases/3.4.0/clever-tools-3.4.0_linux.tar.gz \
    && mkdir clever-tools_linux \
    && tar xvzf clever-tools_linux.tar.gz -C clever-tools_linux --strip-components=1 \
    && cp clever-tools_linux/clever /usr/local/bin

# Only grep the clever-tools binary and his libraries for the release stage
# We use ldd to find the shared object dependencies.
RUN \
    mkdir -p /tmp/fakeroot/lib  && \
    cp $(ldd /usr/local/bin/clever | grep -o '/.\+\.so[^ ]*' | sort | uniq) /tmp/fakeroot/lib && \
    for lib in /tmp/fakeroot/lib/*; do strip --strip-all $lib; done && \
    mkdir -p /tmp/fakeroot/bin/ && \
    cp /usr/local/bin/clever /tmp/fakeroot/bin/

VOLUME ["/tmp/fakeroot"]
WORKDIR /tmp/fakeroot

## The loader search ld-linux-x86-64.so.2 in /lib64 but the folder does not exist
RUN ln -s lib lib64

ENTRYPOINT ["clever"]

(this is obviously not prod ready... way to heavy)

node appears to be provided busybox:glibc... so don't know what the best approach would be to deal with this issue:

will be using my temporary Dockerfile in the meantime

Dmitri

chmuche commented 6 months ago

Same error with 3.6.1 docker image

"secret:valid:clever":
  stage: .pre
  image:
    name: clevercloud/clever-tools:3.6.1
    entrypoint: [ "/bin/sh", "-c" ]
  before_script:
    - clever version
  script:
    - clever login --token ${CLEVER_TOKEN} --secret ${CLEVER_SECRET}
    - clever profile
    - clever applications
    - clever diag
    - clever curl https://api.clever-cloud.com/v2/self
  tags:
    - clever-ci

CI log

Using docker image sha256:089cdb5fa00ab3f868153a5d759edd96edff26a3aac2fb4f67617fb9293fd285 for clevercloud/clever-tools:3.6.1 with digest clevercloud/clever-tools@sha256:1ad035a7b4d030af1f640b65951d2646a9bd5c0315f62ea6a98df2634fecce9b ...
$ clever version
3.6.1
$ clever login --token ${CLEVER_TOKEN} --secret ${CLEVER_SECRET}
$ clever profile
You're currently logged in as:
User id          user_9daa899b-c7a0-443f-8727-xxxxxxxxxxxx
Name           xxxxxxxxxxxxxxxxxx
Email            xxxxxxxxxxxxxxxxxx
Two factor auth  no
$ clever applications
$ clever diag
clever-tools  3.6.1
Node.js       v18.15.0
Platform      linux
Release       5.4.0-155-generic
Architecture  x64
Shell         undefined
Packaged      true
Exec path     /bin/clever
Config file   /root/.config/clever-cloud/clever-tools.json
Auth source   environment variables
oAuth token   [MASKED]
User ID       user_9daa899b-c7a0-443f-8727-xxxxxxxxxxxx
$ clever curl https://api.clever-cloud.com/v2/self
node:events:491
      throw er; // Unhandled 'error' event
      ^
Error: spawn curl ENOENT
    at ChildProcess._handle.onexit (node:internal/child_process:283:19)
    at onErrorNT (node:internal/child_process:476:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
Emitted 'error' event on ChildProcess instance at:
    at ChildProcess._handle.onexit (node:internal/child_process:289:12)
    at onErrorNT (node:internal/child_process:476:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawn curl',
  path: 'curl',
  spawnargs: [
    'https://api.clever-cloud.com/v2/self',
    '-H',
    'Authorization: OAuth oauth_consumer_key="T5nFjKeHH4AIlEveuGhB5S3xg8T19e", oauth_nonce="8RwVXQ89Ey1eLOnNGzW4DU4qeRswdVYl", oauth_signature="cE0B74pNGcCh83fxEZ9Ef13l0ym5fTp8qV3hnXBnkHF08keZwAJZ2lVr6LKufV54ZL%2BT%2FYdwuqzBIFKcncmK1Q%3D%3D", oauth_signature_method="HMAC-SHA512", oauth_timestamp="1714752469", oauth_token="[MASKED]", oauth_version="1.0"'
  ]
}
Node.js v18.15.0