Reputation: 51
I need a way to pass a job artifact from gitlab ci to a Dockerfile, so I can copy it into a directory. What is the path where this artifact is located?
Thank you!
Upvotes: 5
Views: 8437
Reputation: 141
Steps:
artifacts
at your stage.dependencies
to pass dependencies to the current stage.Dockerfile
.For example, I run the vueJS project, the main flow:
npm run build:prod
in vueJS projectbuild-dist:
stage: build-dist
image: node
script:
- npm run build:prod
artifacts:
paths:
- dist/
dependencies
build-docker:
stage: build-docker
image: docker:stable
script:
- docker build
dependencies:
- build-dist
FROM fholzer/nginx-brotli
COPY ./dist /usr/share/nginx/html
COPY ./nginx.conf /etc/nginx/nginx.conf
Upvotes: 6
Reputation: 83
You can use RUN --mount=type=secret
Build images with BuildKit
There is an example to show how to copy credentials into dockerfile This dockerfile
# syntax = docker/dockerfile:experimental
RUN --mount=type=secret,id=aws,target=/root/.aws/credentials \
cat /root/.aws/credentials
This the CI
$ docker build -t test --secret id=aws,src=$HOME/.aws/credentials .
Upvotes: 0
Reputation: 4478
You should use dependencies
, the docs also state that job artifacts are passed to the next job by default.
The artifacts from the previous jobs will be downloaded and extracted in the context of the build.
Upvotes: 0