Created
October 23, 2019 21:26
-
-
Save dre1080/418d45913e7537ccb5542efd4940a960 to your computer and use it in GitHub Desktop.
Nuxt.js Multi-Stage Dockerfile
This file contains 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
version: '3.7' | |
services: | |
nuxt: | |
build: | |
context: . | |
target: dev-env | |
volumes: | |
- .:/src | |
ports: | |
- '3000:3000' |
This file contains 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 | |
FROM node:latest as build-env | |
ENV NODE_ENV production | |
WORKDIR /src | |
COPY . . | |
RUN yarn install \ | |
--prefer-offline \ | |
--frozen-lockfile \ | |
--non-interactive \ | |
--production=false | |
RUN yarn build | |
# Dev | |
FROM node:alpine as dev-env | |
ENV HOST 0.0.0.0 | |
WORKDIR /src | |
COPY . . | |
COPY --from=build-env /src/node_modules ./ | |
EXPOSE 3000 | |
CMD ["yarn", "dev"] | |
# Prod | |
FROM node:alpine | |
ENV HOST 0.0.0.0 | |
WORKDIR /src | |
COPY . /src | |
COPY --from=build-env /src/.nuxt ./ | |
RUN yarn install \ | |
--prefer-offline \ | |
--pure-lockfile \ | |
--non-interactive \ | |
--production=true | |
EXPOSE 3000 | |
CMD ["yarn", "start"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment