Docker workdir not respected by the runner
Summary
Possibly related to #27079
Given a dockerfile with a workdir, when I run a script in GitLab CI, then it is not run from the workdir.
Steps to reproduce
Dockerfile:
FROM node:14-alpine
WORKDIR /app
COPY ["package.json", "yarn.lock", "./"]
RUN yarn install --frozen-lockfile && yarn autoclean && yarn cache clean
COPY packages packages
RUN yarn build
Job:
Test:
image: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
stage: test
before_script:
- pwd
- cd /app
- pwd
script:
- yarn test
Actual Output:
$ pwd
/builds/xxxxxx/0/project-group/project-name
$ cd /app
$ pwd
/app
$ pwd
/app
$ yarn test
...
Expected Output:
$ pwd
/app
$ cd /app
$ pwd
/app
$ pwd
/app
$ yarn test
...
Used GitLab Runner version
Running with gitlab-runner 13.12.0 (7a6612da)
on docker-runner-08 BjtdEFz_
Using Docker executor with image xxx
Possible fixes
The runner should execute script entries from the Dockerfile WORKDIR
.
Edited by Adrien Poupa