Adjustments for pnmp and Linux build
This commit is contained in:
parent
4a98dff754
commit
df713a6a51
45
Dockerfile
Normal file
45
Dockerfile
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
FROM node:18-alpine AS build
|
||||||
|
# Install dependencies only when needed
|
||||||
|
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
|
||||||
|
RUN apk add --no-cache libc6-compat
|
||||||
|
COPY . /app
|
||||||
|
WORKDIR /app
|
||||||
|
# Copy and install the dependencies for the project
|
||||||
|
COPY package.json pnpm-lock.yaml ./
|
||||||
|
|
||||||
|
# Run the next build process and generate the artifacts
|
||||||
|
# RUN npm install @next/swc-linux-x64-musl @swc/cli @swc/core --save-dev
|
||||||
|
|
||||||
|
RUN npm install -g pnpm
|
||||||
|
|
||||||
|
# @next/swc-linux-x64-musl not needed and problematic
|
||||||
|
RUN pnpm install --frozen-lockfile && pnpm --filter "swc-linux-x64-musl" run build
|
||||||
|
|
||||||
|
# Copy all other project files to working directory
|
||||||
|
#COPY * ./
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# we are using multi stage build process to keep the image size as small as possible
|
||||||
|
FROM node:18-alpine
|
||||||
|
# update and install latest dependencies, add dumb-init package
|
||||||
|
# add a non root user
|
||||||
|
RUN apk update && apk upgrade && apk add --no-cache dumb-init && adduser -D nextuser && rm -rf /**var**/lib/apt/lists/* && rm -rf /var/cache/apk/*
|
||||||
|
|
||||||
|
# set work dir as app
|
||||||
|
WORKDIR /app
|
||||||
|
# copy the public folder from the project as this is not included in the build process
|
||||||
|
COPY --from=build --chown=nextuser:nextuser /app/public ./public
|
||||||
|
# copy the standalone folder inside the .next folder generated from the build process
|
||||||
|
COPY --from=build --chown=nextuser:nextuser /app/.next/standalone ./
|
||||||
|
# copy the static folder inside the .next folder generated from the build process
|
||||||
|
COPY --from=build --chown=nextuser:nextuser /app/.next/static ./.next/static
|
||||||
|
# set non root user
|
||||||
|
USER nextuser
|
||||||
|
# expose 3000 on container
|
||||||
|
EXPOSE 3000
|
||||||
|
|
||||||
|
# set app host ,port and node env
|
||||||
|
ENV HOST=0.0.0.0 PORT=3000 NODE_ENV=production
|
||||||
|
# start the app with dumb init to spawn the Node.js runtime process
|
||||||
|
# with signal support
|
||||||
|
CMD ["dumb-init","node","server.js"]
|
@ -1,4 +1,6 @@
|
|||||||
/** @type {import('next').NextConfig} */
|
/** @type {import('next').NextConfig} */
|
||||||
const nextConfig = {}
|
const nextConfig = {
|
||||||
|
output: 'standalone',
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = nextConfig
|
module.exports = nextConfig
|
||||||
|
4356
package-lock.json
generated
4356
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
5
pnpm-lock.yaml
generated
5
pnpm-lock.yaml
generated
@ -45,6 +45,11 @@ dependencies:
|
|||||||
specifier: ^1.0.7
|
specifier: ^1.0.7
|
||||||
version: 1.0.7(tailwindcss@3.3.5)
|
version: 1.0.7(tailwindcss@3.3.5)
|
||||||
|
|
||||||
|
optionalDependencies:
|
||||||
|
'@next/swc-linux-x64-musl':
|
||||||
|
specifier: ^14.0.3
|
||||||
|
version: 14.0.3
|
||||||
|
|
||||||
devDependencies:
|
devDependencies:
|
||||||
'@types/node':
|
'@types/node':
|
||||||
specifier: ^20
|
specifier: ^20
|
||||||
|
Loading…
x
Reference in New Issue
Block a user