Can't show all files in Command line runner inside docker
My goal is to build a docker image, install modules inside it (by running npm install from Dockerfile), push image to container registry and run tests inside the image. I have a configuration with 3 steps:
- Runner type: Docker, command: docker build, image name: gitlab.xxx.com:5050/services/mk-rocketsms/image:build_%build.counter%
- Runner type: Docker, command: docker push, image name: gitlab.xxx.com:5050/services/mk-rocketsms/image:build_%build.counter%
- Runner type: Command Line, custom script: ls -l; npm run lint, Run step within Docker container: gitlab.xxx.com:5050/services/mk-rocketsms/image:build_%build.counter%, Pull image explicitly: checked.
Docker file is quite simple:
FROM mhart/alpine-node:10.16
WORKDIR /src
COPY . .
RUN npm install
EXPOSE 4513
CMD ["npm", "start"]
Steps 1 and 2 are completed correctly, and if I run the image from container registry from console, I can see all files including node_modules directory:
dimon@gitlab:~$ sudo docker run -it --entrypoint=sh gitlab.xxx.com:5050/services/mk-rocketsms/image:build_47
/src # ls
Dockerfile __mocks__ docker-compose.yml openapi package.json test
README.md deploy.sh node_modules package-lock.json src
But in step 3 there is no directory node_modules, so my tests are failed. Part of Build log from step 3:
[22:08:53][Step 3/3] Starting: /bin/sh -c "docker pull gitlab.xxx.com:5050/services/mk-rocketsms/image:build_47 && . /home/teamcity/BuildAgent/temp/agentTmp/docker-wrapper-250759087093117074.sh && docker run --rm -w /home/teamcity/BuildAgent/work/d5c08d0bcec02a29 --label jetbrains.teamcity.buildId=50 -v "/home/teamcity/BuildAgent/lib:/home/teamcity/BuildAgent/lib:ro" -v "/home/teamcity/BuildAgent/tools:/home/teamcity/BuildAgent/tools:ro" -v "/home/teamcity/BuildAgent/plugins:/home/teamcity/BuildAgent/plugins:ro" -v "/home/teamcity/BuildAgent/work/d5c08d0bcec02a29:/home/teamcity/BuildAgent/work/d5c08d0bcec02a29" -v "/home/teamcity/BuildAgent/temp/agentTmp:/home/teamcity/BuildAgent/temp/agentTmp" -v "/home/teamcity/BuildAgent/temp/buildTmp:/home/teamcity/BuildAgent/temp/buildTmp" -v "/home/teamcity/BuildAgent/system:/home/teamcity/BuildAgent/system" --env-file /home/teamcity/BuildAgent/temp/agentTmp/docker-wrapper-4393553095895573147.envList --entrypoint /bin/sh "gitlab.xxx.com:5050/services/mk-rocketsms/image:build_47" /home/teamcity/BuildAgent/temp/agentTmp/docker-shell-script-5117031137291622016.sh"
[22:08:53][Step 3/3] in directory: /home/teamcity/BuildAgent/work/d5c08d0bcec02a29
[22:08:53][Step 3/3] build_47: Pulling from services/mk-rocketsms/image
[22:08:53][Step 3/3] 5d20c808ce19: Already exists
[22:08:53][Step 3/3] fff97c9b60dd: Already exists
[22:08:54][Step 3/3] 1e8c7f639059: Already exists
[22:08:54][Step 3/3] efda49a9f734: Pulling fs layer
[22:08:54][Step 3/3] 95fdfa0a08c7: Pulling fs layer
[22:08:54][Step 3/3] efda49a9f734: Verifying Checksum
[22:08:54][Step 3/3] efda49a9f734: Download complete
[22:08:54][Step 3/3] efda49a9f734: Pull complete
[22:08:54][Step 3/3] 95fdfa0a08c7: Verifying Checksum
[22:08:54][Step 3/3] 95fdfa0a08c7: Download complete
[22:08:58][Step 3/3] 95fdfa0a08c7: Pull complete
[22:08:58][Step 3/3] Digest: sha256:7a44b9632157f189208efece1c17910b21ff819d5f891cd2b6e88f926da0858a[22:08:58][Step 5/5] Status: Downloaded newer image for gitlab.xxx.com:5050/services/mk-rocketsms/image:build_47
[22:08:58][Step 3/3] gitlab.xxx.com:5050/services/mk-rocketsms/image:build_47
[22:08:59][Step 3/3] total 308
[22:08:59][Step 3/3] -rw-r--r-- 1 1001 1001 104 Jan 5 17:08 Dockerfile
[22:08:59][Step 3/3] -rw-r--r-- 1 1001 1001 86 Jan 5 17:08 README.md
[22:08:59][Step 3/3] drwxr-xr-x 2 1001 1001 4096 Jan 5 17:08 __mocks__
[22:08:59][Step 3/3] -rw-r--r-- 1 1001 1001 255 Jan 5 17:08 deploy.sh
[22:08:59][Step 3/3] -rw-r--r-- 1 1001 1001 365 Jan 5 17:08 docker-compose.yml
[22:08:59][Step 3/3] drwxr-xr-x 2 1001 1001 4096 Jan 5 17:08 openapi
[22:08:59][Step 3/3] -rw-r--r-- 1 1001 1001 276910 Jan 5 17:08 package-lock.json
[22:08:59][Step 3/3] -rw-r--r-- 1 1001 1001 1475 Jan 5 17:08 package.json
[22:08:59][Step 3/3] drwxr-xr-x 7 1001 1001 4096 Jan 5 17:08 src
[22:08:59][Step 3/3] drwxr-xr-x 2 1001 1001 4096 Jan 5 17:08 test
[22:08:59][Step 3/3]
[22:08:59][Step 3/3] > mk-rocketsms@1.0.0 lint /home/teamcity/BuildAgent/work/d5c08d0bcec02a29
[22:08:59][Step 3/3] > eslint --fix ./src ./test
[22:08:59][Step 3/3]
[22:08:59][Step 3/3] sh: eslint: not found
Any ideas how to run scripts in correct builded docker image?
Please sign in to leave a comment.