Created
August 22, 2019 16:54
-
-
Save tsuz/c9e1c9c6af90e963b97b00ce165de430 to your computer and use it in GitHub Desktop.
Multi-stage Dockerfile for building gatsbyjs 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
# 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