Skip to content

Instantly share code, notes, and snippets.

@dre1080
Created October 23, 2019 21:26
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 dre1080/418d45913e7537ccb5542efd4940a960 to your computer and use it in GitHub Desktop.
Save dre1080/418d45913e7537ccb5542efd4940a960 to your computer and use it in GitHub Desktop.
Nuxt.js Multi-Stage Dockerfile
version: '3.7'
services:
nuxt:
build:
context: .
target: dev-env
volumes:
- .:/src
ports:
- '3000:3000'
# 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