Created
May 15, 2021 11:23
-
-
Save mostafa-asg/b512e2f7f1a81e89a65b4cc9f5e4deb9 to your computer and use it in GitHub Desktop.
Dockerizing a React App
This file contains hidden or 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
# build environment | |
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 | |
# new | |
COPY nginx/nginx.conf /etc/nginx/conf.d/default.conf | |
EXPOSE 80 | |
CMD ["nginx", "-g", "daemon off;"] |
This file contains hidden or 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
# build environment | |
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 | |
EXPOSE 80 | |
CMD ["nginx", "-g", "daemon off;"] | |
Here, we take advantage of the multistage bu |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment