I have created nginx config, DockerFile, Docker-compose file for the same.
nginx/nginx.conf
server {
listen 80;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
DockerFile
FROM node:13.12.0-alpine as build
WORKDIR /app
ENV PATH /app/node_modules/.bin:$PATH
COPY package.json ./
COPY package-lock.json ./
RUN npm ci --silent
RUN npm install [email protected] -g --silent
COPY . ./
RUN npm run build
# production environment
FROM nginx:stable-alpine
COPY --from=build /app/build /usr/share/nginx/html
RUN rm /etc/nginx/conf.d/default.conf
COPY nginx/nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
docker-compose.yml
version: "3.7"
services:
client:
container_name: client
build:
context: .
dockerfile: Dockerfile
ports:
- 3001:3000
Now after doing docker-compose up --build
I get the logs as
client | /docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
client | /docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
client | /docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
client | 10-listen-on-ipv6-by-default.sh: Getting the checksum of /etc/nginx/conf.d/default.conf
client | 10-listen-on-ipv6-by-default.sh: error: /etc/nginx/conf.d/default.conf differs from the packages version
client | /docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
client | /docker-entrypoint.sh: Configuration complete; ready for start up
I am not sure, if the problem is due to different packages version or something else but when tried to visit the url it says this site can’t be reached.
docker ps