How to start custom entry point?

Hi all

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

FROM ubuntu:bionic as builder

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.41.0/doctl-1.41.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.4.3/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/

COPY connection.sh /usr/local/bin/

RUN chmod +x /usr/local/bin/connection.sh

ENTRYPOINT ["/usr/local/bin/connection.sh" 

When I use the image in the pipeline:

  - name: DEV deployment
    image: hub.example.io/devops/argcd-cli:0.1.6
    commands:
      - git clone https://$USER:$PW@gitlab.com/example.io/gitops.git
      - cd gitops
      - echo $IMAGE_VERSION
      - helm template dashboard --set image.tag=$IMAGE_VERSION ./dashboard | tee  ./dashboard/dev/app.yml
      - sleep 1
      - git add . --all

The connection.sh script does not get called. Unlike when I start a container with the image

docker run --rm -it \                                                 
        --name argo \
        argocd-cli

then the connection.sh script gets called.

The question is, when the DEV deployment step starts, how to execute connection.sh script first before commands get executed?

Thanks

The commands section is converted to a shell script that is executed as the container entrypoint. This means the default entrypoint of your image is ignored, by design, if you specify a commands section.

The steps section defines a series of shell commands. These commands are executed inside the Docker container as the Entrypoint . If any command returns a non-zero exit code, the pipeline fails and exits.

If you need the script to execute you should add to your commands section:

  - name: DEV deployment
    image: hub.example.io/devops/argcd-cli:0.1.6
    commands:
+     - /usr/local/bin/connection.sh
      - cd gitops
      - echo $IMAGE_VERSION
      - helm template dashboard --set image.tag=$IMAGE_VERSION ./dashboard | tee  ./dashboard/dev/app.yml
      - sleep 1
      - git add . --all

1 Like

Thanks a lot for your help.