4

I'm trying to run docker run ID npm run test but I get the following error: docker-entrypoint.sh: 38: exec: npm: not found.

I'm very new to Docker and I tried this (adding the entrypoint ENTRYPOINT ["/usr/src/app/api-entrypoint.sh"]) but it doesn't seem to work.

What do I need to change?

Dockerfile

FROM node:13.12.0-alpine as builder
WORKDIR '/app'
COPY package.json .
RUN npm install
COPY . .
RUN npm run build

FROM nginx
COPY --from=builder /app/build /usr/share/nginx/html
uber
  • 4,163
  • 5
  • 26
  • 55

1 Answers1

7

the entrypoint is running on the second image, the nginx one, which does not have npm

Kroustou
  • 659
  • 5
  • 14
  • I don't really know what an entrypoint is in Docker or how to properly fix it – uber May 11 '21 at 11:28
  • 1
    no worries i will try to explain. You are using a multi stage build: https://docs.docker.com/develop/develop-images/multistage-build/ in short, you are using an image to perform a couple of actions and then you are copying to a second image something from the first one. An image is just an image like a vm. It does not do anything. If you need to run something when the image is up you need an entrypoint which will execute stuff. I would suggest to creat your image, spin up a container and run manually the entrypoint until you get good results. Then you can copy the entrypoint on build time. – Kroustou May 11 '21 at 13:31