-
-
Save ilhamarrouf/a3280802b739d74bbf470048d304cc18 to your computer and use it in GitHub Desktop.
Nuxt.js with SSR featuring “Docker Multi-stage build” and “node-prune"
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.5' | |
services: | |
app: | |
build: . | |
volumes: | |
- '.:/app' | |
ports: | |
- '3000:80' | |
environment: | |
- NODE_ENV=development |
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
FROM node:10.11.0-alpine as builder | |
WORKDIR /app | |
RUN apk add --no-cache curl git && cd /tmp && \ | |
curl -#L https://github.com/tj/node-prune/releases/download/v1.0.1/node-prune_1.0.1_linux_amd64.tar.gz | tar -xvzf- && \ | |
mv -v node-prune /usr/local/bin && rm -rvf * && \ | |
echo "yarn cache clean && node-prune" > /usr/local/bin/node-clean && chmod +x /usr/local/bin/node-clean | |
ADD package.json ./ | |
RUN yarn --frozen-lockfile --non-interactive | |
ADD . ./ | |
RUN yarn build | |
ENV NODE_ENV=production | |
RUN yarn --frozen-lockfile --non-interactive --production && node-clean | |
FROM node:10.11.0-alpine | |
WORKDIR /app | |
ENV HOST=0.0.0.0 | |
ADD package.json ./ | |
ADD nuxt.config.js ./ | |
COPY --from=builder ./app/node_modules ./node_modules/ | |
COPY --from=builder ./app/.nuxt ./.nuxt/ | |
COPY --from=builder ./app/src/static ./src/static/ | |
EXPOSE 8080 | |
CMD ["yarn", "start", "-p", "8080"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment