Dockerize the CLI
I recently needed to run the CLI inside containers (due to our CI platform). Not sure if there's an existing solution to run the CLI inside Docker because the CLI also spawn containers. What I've temporarily done is to just use docker:dind to accomplish this.
Dockerfile goes like this:
FROM golang:1.24-alpine3.21 AS install-dependabot
RUN go install github.com/dependabot/cli/cmd/dependabot@latest \
&& cp $GOPATH/bin/dependabot /usr/local/bin/
FROM docker:28-dind AS runtime
COPY --from=install-dependabot /usr/local/bin/dependabot /usr/local/bin/
ENTRYPOINT ["dependabot"]
Then build: docker build -t dependabot-cli:latest.
And run below to run update on local folder:
docker run \
-v /var/run/docker.sock:/var/run/docker.sock \
-v $HOME/.docker/config.json:/root/.docker/config.json \
-v $HOME/repos/repo:/repo \
--network=host \
-it \
--rm \
dependabot-cli update pip test/test --local /repo
If there's a better way, pls let me know. 🥺
Hi @pilosoposerio , I'd like to ask you a question: With this Docker image, we won't need root permission to run it anymore, right? Thanks in advance
Hi @pilosoposerio , I'd like to ask you a question: With this Docker image, we won't need root permission to run it anymore, right? Thanks in advance
I do not understand the question. Pls share more details.
If it's about the user inside the container: I did not set up a non-root user in the image. You can check the base image if they are rootless.
Hi @pilosoposerio , sorry for my unclear question. My issue is when I run dependabot-cli in the K8s cluster container, it requires securityContext: privileged =true. We want to get rid of it and think that maybe wrapping it in a Docker Image with docker-dind as you did can solve the issue.
Hi @pilosoposerio , sorry for my unclear question. My issue is when I run dependabot-cli in the K8s cluster container, it requires securityContext: privileged =true. We want to get rid of it and think that maybe wrapping it in a Docker Image with docker-dind as you did can solve the issue.
I am not knowledgeable in K8s so I cannot provide an answer.