Why chmod and doctl not found?

Hi all

I have created a docker image that has the following content:

FROM ubuntu:20.10

RUN apt-get update
RUN apt-get install -y curl
RUN apt-get install -y git

RUN curl -L https://github.com/digitalocean/doctl/releases/download/v1.43.0/doctl-1.43.0-linux-amd64.tar.gz  | tar xz
RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl
RUN curl -L https://github.com/argoproj/argo-cd/releases/download/v1.5.5/argocd-linux-amd64 -o argocd
RUN curl -L https://get.helm.sh/helm-v3.2.1-linux-amd64.tar.gz | tar xz


RUN chmod +x ./argocd
RUN chmod +x ./kubectl
RUN chmod +x ./linux-amd64/helm

RUN mv ./argocd /usr/local/bin/
RUN mv ./kubectl /usr/local/bin/
RUN mv ./doctl /usr/local/bin/
RUN mv ./linux-amd64/helm /usr/local/bin/

WORKDIR /sh

COPY test.sh /sh
RUN chmod +x /sh/test.sh

Then I tested the image locally on my computer, if the image works:

docker pull hub.databaker.io/devops/argcd-cli:0.1.22
docker run -it --rm hub.databaker.io/devops/argcd-cli:0.1.22
root@76db905a83c6:/sh# pwd
/sh
root@76db905a83c6:/sh# doctl version
doctl version 1.43.0-release
Git commit hash: 1b6d0b8

as you can see, I can call doctl inside the container and it shows the expected result.

I use Drone CI to build my pipelines and run into trouble on the following pipeline:

kind: pipeline
type: docker
name: DEV build, push and deploy

steps:
  - name: DEV deployment
    image: hub.databaker.io/devops/argcd-cli:0.1.22
    pull: if-not-exists
    environment:
      DO_AC:
        from_secret: do_ac
      K8S_CLUSTER:
        from_secret: k8s_cluster
      ARGO_SERVER:
        from_secret: argo_server
      ARGO_USERNAME:
        from_secret: argo_username
      ARGO_PW:
        from_secret: argo_pw
      IMAGE_VERSION: ${DRONE_SEMVER_SHORT}
      USER:
        from_secret: gituser
      PW:
        from_secret: gitpw
      GIT_URL: gitlab.com/databaker.io/gitops.git
      PATH: keycloak-svc
      NAMESPACE: dev
    commands:
      - cd /sh
      - pwd
      - doctl version

trigger:
  event:
    - tag

image_pull_secrets:
  - dockerconfig

It shows the following error message:

/bin/sh: 5: chmod: not found
/bin/sh: 24: doctl: not found
+ cd /sh
+ pwd
/sh
+ doctl version

I also tried:

commands:
  - ls -la
  - cd /usr/local/bin/
  - ls -la
  - /bin/bash -c doctl version
  - /bin/bash -c pwd
  - doctl version

and got:

/bin/sh: 5: chmod: not found
2 /bin/sh: 18: ls: not found
3 + ls -la

Why doctl and chmod can not be found in the pipeline? Do I forget to activate something on the pipeline?

I am using drone/drone:1.7.0.

Thanks

You are overwriting the PATH environment variable with “PATH: keycloak-svc”, so it’s not possible to find any executable anymore by the shell.

1 Like

Thanks a lot for your help