forked from javayhu/free-directory-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
35 lines (27 loc) · 908 Bytes
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# https://github.com/someu/aigotools/blob/main/packages/aigotools/Dockerfile
FROM node:20-alpine AS base
# Install dependencies only when needed
FROM base AS builder
WORKDIR /app
COPY . .
RUN apk add --no-cache libc6-compat \
&& npm config set strict-ssl false \
&& npm config set fetch-retries 10 \
&& corepack enable pnpm \
&& pnpm i \
&& mv next.config.docker.js next.config.js \
&& pnpm run build
# Production image, copy all the files and run next
FROM base AS runner
WORKDIR /app
ENV NODE_ENV production
RUN addgroup --system --gid 1001 nodejs \
&& adduser --system --uid 1001 nextjs \
&& mkdir .next \
&& chown nextjs:nodejs .next
COPY --from=builder /app/public ./public
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
USER nextjs
EXPOSE 3000
CMD HOSTNAME="0.0.0.0" node server.js