next-template/Dockerfile.static
Florian Bouillon b2ca46ffaf
v3.1: Upgraded to NextJS 12
Static Dockerfile

Signed-off-by: Avior <github@avior.me>
2022-10-02 22:10:54 +02:00

45 lines
856 B
Docker

# This Dockerfile allows you to run NextJS in a static container (no server side)
#########
# Build #
#########
FROM docker.io/node:alpine as BUILD_IMAGE
# inform software to be in production
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
# External deps (for node-gyp add: "python3 make g++")
# git is used to install the npm packages with git deps
RUN apk add --no-cache git
# run as non root user
USER node
# go to user repository
WORKDIR /home/node
# Add package json
ADD package.json package-lock.json ./
# install dependencies from package lock
RUN npm ci --omit=dev
# Add project files
ADD . .
# build
RUN npm run build &&\
npm run export
##############
# Production #
##############
FROM docker.io/nginx:alpine
# go to NGINX folder
WORKDIR /usr/share/nginx/html
# copy from build image
COPY --from=BUILD_IMAGE /home/node/out ./