Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix nginx conf and dockerization #636

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
48 changes: 29 additions & 19 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,29 +1,39 @@
# This file is the main docker file configurations
# Stage 1 - the build process
# FROM node:14-alpine as build

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

# Set the working directory to ./app
WORKDIR /app
# set working directory
RUN mkdir /usr/app
#copy all files from current directory to docker
COPY . /usr/app

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

RUN apk add --no-cache git
# Remove package-lock.json
RUN rm ./package-lock.json

# Install any needed packages
# install and cache app dependencies
RUN npm install

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

# Bundle app source
COPY . /app
RUN npm run build

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

# Run app.js when the container launches
CMD ["npm", "start"]
# Set working directory to nginx asset directory
WORKDIR /usr/share/nginx/html

# Remove default nginx static assets
RUN rm -rf ./*

# Copy static assets from builder stage
COPY --from=build-stage /usr/app/build .
COPY nginx.conf /etc/nginx/conf.d/default.conf

# Containers run nginx with global directives and daemon off
ENTRYPOINT ["nginx", "-g", "daemon off;"]
17 changes: 17 additions & 0 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
server {
listen 80;
server_name localhost;

location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri /index.html;
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}


}