Reputation: 347
I need to be able to copy ssl files that is inside a private gitlab server into the docker image through gitlab ci/cd.
Below is the configuration of my gitlab runner. I have mapped the volume of /root/server-ssl directory so the files could be read through the ci/cd
[runners.docker]
tls_verify = false
image = "docker.myserver.com/gitlab-base-image"
privileged = true
disable_entrypoint_overwrite = false
oom_kill_disable = false
disable_cache = true
volumes = ["/var/run/docker.sock:/var/run/docker.sock",
"/root/.docker/config.json:/root/.docker/config.json",
"/cache",
"/root/server-ssl:/root/server-ssl"]
extra_hosts = ["gitlab.myserver.com:<some_ip>"]
shm_size = 0
And below is my dockerfile configuration:
# 1 - Build environment
FROM node:10.16 as react-build
WORKDIR /usr/src/app
COPY package.json yarn.lock ./
RUN yarn
COPY . ./
RUN yarn build
# 2 - Production environment
FROM nginx:alpine
RUN mkdir -p /root/server-ssl
COPY /root/server-ssl/ssl.chained.crt /root/server-ssl/
COPY /root/server-ssl/ssl.key /root/server-ssl/
COPY nginx.staging.conf /etc/nginx/conf.d/default.conf
EXPOSE 80 443
CMD ["nginx", "-g", "daemon off;"]
But i always get the following error by the gitlab ci/cd runner:
Step 5/18 : COPY /root/server-ssl/ssl.chained.crt /root/server-ssl/
COPY failed: stat /var/lib/docker/tmp/docker-builder528505413/root/server-ssl/ssl.chained.crt: no such file or directory
could anyone provide me some help to copy these files?
Upvotes: 2
Views: 4415
Reputation: 3001
The files are not in the docker build context. Can think of a couple of ways to bring them into the docker context
Create symlink in the folder where the Dockerfile is located with the directory where the files are located
Physically copy the files to the folder where the Dockerfile is located before running the docker build command
Upvotes: 3