Reputation: 49
I'm trying to replicate the image build from a Dockerfile in the Gitlab pipeline. When i use docker locally in my machine I have no problem. But when I try to replicate the process in the pipeline, the script fails with the following error:
Step 6/12 : RUN npm run-script build
---> Running in 4717c4b9d61a
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /app/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/app/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
Here is my .gitlab-ci.yml
image: docker:18.09.7
services:
- docker:18.09.7-dind
stages:
- build
- test
variables:
IMAGE_TAG: $CI_REGISTRY_IMAGE -f ./hackapp/Dockerfile
before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY"
build:
stage: build
script:
- docker build -t $IMAGE_TAG .
- docker push $IMAGE_TAG
test:
stage: test
services:
- mongo:bionic
script:
- docker pull $IMAGE_TAG
- docker run $IAMGE_TAG
And my Dockerfile
# Stage I
FROM node:stretch-slim AS react-build
WORKDIR /app
COPY . /app/
RUN npm install
RUN npm install [email protected] -g
RUN npm run-script build
# Stage II
#Setup Nginx
FROM nginx:1.16.0-alpine
COPY --from=react-build /app/build /usr/share/nginx/html
RUN rm /etc/nginx/conf.d/default.conf
COPY nginx/nginx.conf /etc/nginx/conf.d
#Fire up Nginx
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
I tried installing adding npm install npm@latest -g
in the first RUN
but is like it cannot found the path to package.json
file
Upvotes: 0
Views: 959
Reputation: 1743
May be the package.json is not really getting copied into /app/ directory. You can check using ls -l to be sure.
Upvotes: 1