Docker build image

I created the dockerfile and wrote the following inside it

FROM node:14.16.0-alpine3.13
RUN addgroup app && adduser -S -G app app
USER app
WORKDIR /app
COPY package*.json .
RUN npm install
COPY . .
ENV FINERACT_API_URL=http://api.domainname.com

EXPOSE 3000
CMD [“npm”, “start”]

after that i wrote the following command to build and run the project image

docker run -it react-app

the container running successfully but when go the browser and wrote the following url
http://localhost:8080/ or http://localhost:3000

the application not loaded in the browser

This site can’t be reached

What’s that FINERACT_API_URL all about? I get “This site can’t be reached” too, when I go to http://api.domainname.com.

Since you didn’t map the ports between the host and the container.
Mosh explains about this in the next section.

1 Like

In module “Defining Entrypoints”, when I was trying to build the image by:

docker build -t react-app .

I was getting a lot of warnings like these:

#10 3.546 npm WARN read-shrinkwrap This version of npm is compatible with lockfileVersion@1, but package-lock.json was generated for lockfileVersion@2. I’ll try to do my best with it!
#10 6.158 npm WARN checkPermissions Missing write access to /app/node_modules/@babel/compat-data
#10 6.158 npm WARN checkPermissions Missing write access to /app/node_modules/@babel/core/node_modules/semver

And this final error:

executor failed running [/bin/sh -c npm install]: exit code: 243

It happened that in the module “Speeding Up Builds” the re-arrangement of the code lines solved the problem !!! (so I deleted the previous question) .

I’m still investigating the cause of the problem…