mirror of
https://github.com/Aviortheking/next-template.git
synced 2025-06-21 08:59:18 +00:00
v3.1: Upgraded to NextJS 12
Static Dockerfile Signed-off-by: Avior <github@avior.me>
This commit is contained in:
44
Dockerfile.static
Normal file
44
Dockerfile.static
Normal file
@ -0,0 +1,44 @@
|
||||
# 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 ./
|
Reference in New Issue
Block a user