Skip to content

Instantly share code, notes, and snippets.

@tsuz
Created August 22, 2019 16:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsuz/c9e1c9c6af90e963b97b00ce165de430 to your computer and use it in GitHub Desktop.
Save tsuz/c9e1c9c6af90e963b97b00ce165de430 to your computer and use it in GitHub Desktop.
Multi-stage Dockerfile for building gatsbyjs app
# stage: 1
FROM node:11-alpine AS build
ARG GATSBY_API_BASE_HOST
ENV GATSBY_API_BASE_HOST $GATSBY_API_BASE_HOST
ARG GATSBY_BASE_URL
ENV GATSBY_BASE_URL $GATSBY_BASE_URL
ARG GA_CODE
ENV GA_CODE $GA_CODE
RUN apk add --no-cache --virtual .gyp python make g++
WORKDIR /app
ENV NODE_ENV=production
COPY package.json yarn.lock ./
RUN yarn --frozen-lockfile --non-interactive
COPY . .
RUN yarn build
# stage: 2 — the production environment
FROM nginx:alpine
COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=build /app/public /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