gitlab react docker: npm not found

I am trying to get myself up and running with Gitlab, so I may have misunderstood some concepts. My goal is to setup a continuous integration pipeline where a docker image is built (and eventually deployed, at the moment it is just the build)

  1. I have created a simple hello-world app with create-react-app.
  2. I have created an account on Gitlab and a repository for my project
  3. I have added a .gitlab-ci.yml to enable continuous integration (I would like to use a shared gitlab-runner)
  4. I have added a dockerfile to my project to build an image.

Here is the content of my gitlab-ci.yml file: enter image description here

And here is the content of my dockerfile:

enter image description here

Then when I push a commit the my gitlab repo, the CI pipeline starts and attends to run my scripts.

But it fails with this error:

enter image description here

I cannot figure out what I am doing wrong so that npm is not found. Is there an error in my .yml file or the dockerfile or both?

Any suggestion would be greatly appreciated.

Thanks

1 answer

  • answered 2019-02-10 13:50 Amityo

    npm is not installed in alpine:latest. you can install the relevant dependencies in your own image that uses alpine:latest or just use node:alpine which comes with npm, node and yarn