mirror of
https://github.com/Aviortheking/next-template.git
synced 2025-04-25 03:52:09 +00:00
45 lines
856 B
Docker
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 ./
|