Use multistage build in Dockerfile to shrink image size
Co-Authored-By: betanummeric <40263343+betanummeric@users.noreply.github.com>
This commit is contained in:
parent
db88a42897
commit
482c500d9f
12
Dockerfile
12
Dockerfile
|
|
@ -1,13 +1,19 @@
|
||||||
FROM node:8-alpine
|
### STAGE 1: Build ###
|
||||||
|
FROM node:8-alpine as build
|
||||||
|
WORKDIR /srv
|
||||||
COPY js /srv/js
|
COPY js /srv/js
|
||||||
COPY pages /srv/pages
|
COPY pages /srv/pages
|
||||||
COPY static /srv/static
|
COPY static /srv/static
|
||||||
COPY next.config.js package.json package-lock.json server.js style.css yarn.lock /srv/
|
COPY next.config.js package.json package-lock.json server.js style.css yarn.lock /srv/
|
||||||
WORKDIR /srv
|
|
||||||
RUN yarn install
|
RUN yarn install
|
||||||
RUN yarn build
|
RUN yarn build
|
||||||
|
RUN yarn cache clean
|
||||||
|
|
||||||
|
### STAGE 2: Productive Container ###
|
||||||
|
FROM alpine
|
||||||
|
WORKDIR /srv
|
||||||
|
COPY --from=build /srv /srv
|
||||||
|
RUN apk --no-cache add yarn && rm -rf /var/cache/apk/*
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
ENV TURNIERE_API_URL=https://api.turnie.re
|
ENV TURNIERE_API_URL=https://api.turnie.re
|
||||||
CMD yarn start
|
CMD yarn start
|
||||||
Loading…
Reference in New Issue