Last active
December 29, 2022 15:34
-
-
Save enqtran/ad58cd3cc6e30a99e464b611db2198f2 to your computer and use it in GitHub Desktop.
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
# pull official base image | |
FROM node:14 AS builder | |
# set working directory | |
WORKDIR /app | |
# install app dependencies | |
#copies package.json and package-lock.json to Docker environment | |
COPY package.json ./ | |
# Installs all node packages | |
RUN npm install | |
# Copies everything over to Docker environment | |
COPY . ./ | |
RUN npm run build | |
#Stage 2 | |
####################################### | |
#pull the official nginx:1.19.0 base image | |
FROM nginx:1.19.0 | |
#copies React to the container directory | |
# Set working directory to nginx resources directory | |
WORKDIR /usr/share/nginx/html | |
# Remove default nginx static resources | |
RUN rm -rf ./* | |
# Copies static resources from builder stage | |
COPY --from=builder /app/build . | |
EXPOSE 8080 | |
# Containers run nginx with global directives and daemon off | |
ENTRYPOINT ["nginx", "-g", "daemon off;"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
docker build -t example-react-app .
docker run — rm -it -p 8080:80 example-react-app