I have a pipeline with two stages. in first one I build an image based on Dockerfile from “node:latest”. in this stage I run “npm run build” and it create build folder. in second stage I want to use previously built “build” folder and run it in “nginx” container. but I cant share folder between to stages in Gitlab-ci ce.
I use docker executor as gitlab-runner. gitlab-ci-yml
services: - name: docker:dind command: ["--insecure-registry=mygitlab:5050"] stages: - build - test - release variables: DEV_IMAGE: mygitlab:5050/development/registry:dashboard-dev RELEASE_IMAGE: mygitlab:5050/development/registry:dashboard-prod DOCKER_TLS_CERTDIR: "/certs" GIT_SSL_NO_VERIFY: "1" before_script: - docker login -u root -p my-token mygitlab:5050 build: stage: build script: - docker build -t $DEV_IMAGE . --target=dashboard-dev - docker push $DEV_IMAGE - docker run --name dashboard-dev -d $DEV_IMAGE tail -f /dev/null - docker cp dashboard-dev:/src/app/build /cache - docker stop dashboard-dev - docker rm dashboard-dev release: stage: release script: - docker build -t $RELEASE_IMAGE . --target=dashboard-prod - docker push $RELEASE_IMAGE only: - master` This is my Dockerfile FROM mygitlab:5050/development/registry:dashboard-dev AS dashboard-dev EXPOSE 3000 COPY . . RUN npm install RUN npm run build FROM mygitlab:5050/development/registry:nginx AS dashboard-prod COPY builds/build /usr/share/nginx/html and this is my gitlab-runner config.toml concurrent = 10 check_interval = 0 [session_server] session_timeout = 1800 [[runners]] name = "dash-dock" url = "https://mygitlab/" token = "my-token" executor = "docker" [runners.custom_build_dir] [runners.docker] pull_policy = "if-not-present" tls_verify = false extra_hosts = ["mygitlabDomain:mygitlabIP"] image = "docker:latest" privileged = true disable_entrypoint_overwrite = false oom_kill_disable = false disable_cache = false volumes = ["/cache", "/certs/client", "/builds"] shm_size = 0 [runners.cache] [runners.cache.s3] [runners.cache.gcs]