Skip to content

Instantly share code, notes, and snippets.

@carlohcs
Created February 1, 2022 20:45
Show Gist options
  • Save carlohcs/c9a59ad2f7dc22c4bb708b3b7684d509 to your computer and use it in GitHub Desktop.
Save carlohcs/c9a59ad2f7dc22c4bb708b3b7684d509 to your computer and use it in GitHub Desktop.
Build an image docker with static react application
# build environment
FROM node:13.12.0-alpine as builder
WORKDIR /app
ENV PATH /app/node_modules/.bin:$PATH
COPY package.json ./
COPY package-lock.json ./
RUN npm ci --silent
RUN npm install react-scripts@3.4.1 -g --silent
COPY . ./
RUN npm run build
# production environment
FROM nginx:stable-alpine
COPY --from=builder /app/build /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment