Skip to content

Instantly share code, notes, and snippets.

@mr-pascal
Created January 23, 2021 07:37
Show Gist options
  • Select an option

  • Save mr-pascal/442fd64ab34632d60e5d5e5e35c4b1b9 to your computer and use it in GitHub Desktop.

Select an option

Save mr-pascal/442fd64ab34632d60e5d5e5e35c4b1b9 to your computer and use it in GitHub Desktop.
# Name the node stage "builder"
FROM node:15-alpine AS builder
# Set working directory
WORKDIR /app
# Copy our node module specification
COPY package.json package.json
COPY yarn.lock yarn.lock
# install node modules and build assets
RUN yarn install --production
# Copy all files from current directory to working dir in image
# Except the one defined in '.dockerignore'
COPY . .
# Create production build of React App
RUN yarn build
# Choose NGINX as our base Docker image
FROM nginx:alpine
# 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=builder /app/build .
# Entry point when Docker container has started
ENTRYPOINT ["nginx", "-g", "daemon off;"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment