-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
60 lines (45 loc) · 1.35 KB
/
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# -------------------- Base Image --------------------
FROM node:22-bookworm AS base
# -------------------- Dependencies Stage --------------------
FROM base AS deps
WORKDIR /app
ARG USE_CHINA_NPM_REGISTRY=1
RUN \
set -ex && \
corepack enable pnpm && \
if [ "$USE_CHINA_NPM_REGISTRY" = 1 ]; then \
echo 'use npm mirror' && \
npm config set registry https://registry.npmmirror.com && \
yarn config set registry https://registry.npmmirror.com && \
pnpm config set registry https://registry.npmmirror.com ; \
fi;
COPY ./package.json /app/
COPY ./pnpm-lock.yaml /app/
RUN \
set -ex && \
pnpm install --frozen-lockfile && \
pnpm rebuild
# -------------------- Build Stage --------------------
FROM node:22-bookworm-slim AS builder
WORKDIR /app
COPY . /app
COPY --from=deps /app /app
RUN \
set -ex && \
npm run build && \
ls -la /app && \
du -hd1 /app
# -------------------- Runner Stage --------------------
FROM node:22-bookworm-slim AS runner
WORKDIR /app
COPY --from=builder /app/public ./public
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
COPY --from=builder /app/.next/server ./.next/server
ENV PORT=3000
ENV HOSTNAME="0.0.0.0"
ENV NEXT_SHARP_PATH=node_modules/sharp
# 暴露端口
EXPOSE 3000
# 启动应用
ENTRYPOINT ["node", "server.js"]