forked from saadpasta/developerFolio
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ac2baf8
commit 08d1959
Showing
2 changed files
with
46 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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;"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
|
||
} |