Replace this template with your information
Describe your question in as much detail as possible:
How can I use docker runners with my own CA in a CI/CD pipeline?
- What are you seeing, and how does that differ from what you expect to see?
As mentioned in the documentation there, there are few ways of preparing the runner to be able to recognize self-signed CA, please check here: Self-signed certificates or custom Certification Authorities | GitLab
So I have this on every runner as configuration:
executor = "docker"
# Copy and install CA certificate before each job
pre_build_script = """
apt-get update -y > /dev/null
apt-get install -y ca-certificates > /dev/null
cp /etc/gitlab-runner/certs/ca.crt /usr/local/share/ca-certificates/ca.crt
update-ca-certificates --fresh > /dev/null
volumes = ["/cache", "/etc/gitlab-runner/certs/ca.crt:/etc/gitlab-runner/certs/ca.crt:ro"]
Which works like a charm, but I’m restricted to use only Debian/Ubuntu based images…
How I know that? I tried to run an Alpine container and the pipeline failed because apt-get is not a valid command. (this is step of the preparation process)
Are you using self-managed or The DevSecOps Platform | GitLab
I do use self-hosted Gitlab instance.
- Runner (Hint:
/admin/runners
):
I do use self-hosted runners, with a Docker executor.
- Add the CI configuration from
.gitlab-ci.yml
and other configuration if relevant (e.g. docker-compose.yml)
image:
name: aquasec/trivy
entrypoint: [""]
sast-scan-trivy:
variables:
GIT_STRATEGY: fetch
GIT_CHECKOUT: "true"
before_script:
- apk update
- apk add git bash
script:
- >
#!/bin/bash
export COMMIT_BEFORE_SHA="$(git rev-parse HEAD~1)"
export COMMIT_SHA="$(git rev-parse HEAD~0)"
export COMMIT_BEFORE_SHA="$(git rev-parse HEAD~1)"
export COMMIT_SHA="$(git rev-parse HEAD~0)"
FILES=`git diff "${COMMIT_BEFORE_SHA}" "${COMMIT_SHA}" --name-only`
for FILE in "${FILES[@]}"; do
# Check if the file exists
if [ -e "$FILE" ]; then
echo "Scanning file $FILE"
trivy fs --scanners vuln,secret,misconfig "$FILE"
else
echo "File $FILE does not exist."
fi
done
- What troubleshooting steps have you already taken? Can you link to any docs or other resources so we know where you have been?
I really don’t have a clue how to do next.
Thanks for taking the time to be thorough in your request, it really helps!