Some files in docker image not present in subsequent stage when using image built in previous stage
When running a CI Pipeline with the following structure:
build stage produces a docker image tagged with a ci variable,
test stage uses the
$IMAGE_TAG as its image. This image is based on
node:latest. In the
npm install as part of
docker build, not as a step in the stage.
When running the
npm test is run, whose behavior is defined in the
package.json. After a bit of debugging. If I run
ls -l in the
test stage, the
node_modules dir as well as a few other files added in the
build stage are not present. However, when I pull the image locally, and run
ls -l in the image,
node_modules is there, as well as the files added in the
Steps to reproduce
Create a basic node project, a Dockerfile in which you
npm install the dependencies. Create a
.gitlab-ci.yml file like so:
stages: - build - test variables: IMAGE_TAG: "$myrepo/$myapp:$CI_BUILD_REF_SLUG-$CI_COMMIT_SHA" build: services: - docker:dind image: docker:dind stage: build script: - docker build -t $IMAGE_TAG . - docker push $IMAGE_TAG test: stage: test image: $IMAGE_TAG script: - npm test
However, I have not been able to set up the CI pipeline as I'm not exactly sure what the setup is here on the public gitlab.
What is the current bug behavior?
(What actually happens)
What is the expected correct behavior?
The command run in the
test stage (
npm test) should complete successfully