Skip to content

Commit 08d1959

Browse files
committed
fix issue created in saadpasta#629
1 parent ac2baf8 commit 08d1959

File tree

2 files changed

+46
-19
lines changed

2 files changed

+46
-19
lines changed

Dockerfile

+29-19
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,39 @@
1-
# This file is the main docker file configurations
1+
# Stage 1 - the build process
2+
# FROM node:14-alpine as build
23

3-
# Official Node JS runtime as a parent image
4-
FROM node:10.16.0-alpine
4+
FROM node:14-alpine as build-stage
55

6-
# Set the working directory to ./app
7-
WORKDIR /app
6+
# set working directory
7+
RUN mkdir /usr/app
8+
#copy all files from current directory to docker
9+
COPY . /usr/app
810

9-
# Install app dependencies
10-
# A wildcard is used to ensure both package.json AND package-lock.json are copied
11-
# where available (npm@5+)
12-
COPY package.json ./
11+
WORKDIR /usr/app
1312

14-
RUN apk add --no-cache git
13+
# Remove package-lock.json
14+
RUN rm ./package-lock.json
1515

16-
# Install any needed packages
16+
# install and cache app dependencies
1717
RUN npm install
1818

19-
# Audit fix npm packages
20-
RUN npm audit fix
19+
# add `/usr/src/app/node_modules/.bin` to $PATH
20+
ENV PATH /usr/src/app/node_modules/.bin:$PATH
2121

22-
# Bundle app source
23-
COPY . /app
22+
RUN npm run build
2423

25-
# Make port 3000 available to the world outside this container
26-
EXPOSE 3000
24+
# Stage 2
25+
# Copy the react app build above in nginx
26+
FROM nginx:alpine
2727

28-
# Run app.js when the container launches
29-
CMD ["npm", "start"]
28+
# Set working directory to nginx asset directory
29+
WORKDIR /usr/share/nginx/html
30+
31+
# Remove default nginx static assets
32+
RUN rm -rf ./*
33+
34+
# Copy static assets from builder stage
35+
COPY --from=build-stage /usr/app/build .
36+
COPY nginx.conf /etc/nginx/conf.d/default.conf
37+
38+
# Containers run nginx with global directives and daemon off
39+
ENTRYPOINT ["nginx", "-g", "daemon off;"]

nginx.conf

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
server {
2+
listen 80;
3+
server_name localhost;
4+
5+
location / {
6+
root /usr/share/nginx/html;
7+
index index.html index.htm;
8+
try_files $uri /index.html;
9+
}
10+
11+
error_page 500 502 503 504 /50x.html;
12+
location = /50x.html {
13+
root /usr/share/nginx/html;
14+
}
15+
16+
17+
}

0 commit comments

Comments
 (0)