-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
71 lines (52 loc) · 2.32 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
61
62
63
64
65
66
67
68
69
70
71
FROM node:20-alpine AS base
FROM base AS builder
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
# ENV NODE_ENV=production \
# APP_PATH=/app
RUN corepack enable
# prisma:warn Prisma failed to detect the libssl/openssl version to use, and may not work as expected. Defaulting to "openssl-1.1.x".
# NOTE: node:20-alpine 镜像没有 apt-get 命令,所以无法安装 openssl
# FIXME: bcrypt
# RUN apk update && apk add --no-cache --virtual .gyp python3 make g++
WORKDIR /app
# WORKDIR ${APP_PATH}
COPY . .
# RUN apk add --update python3 make g++ && rm -rf /var/cache/apk/*
# --registry=https://registry.npmmirror.com
RUN npm cache clean --force && rm -rf node_modules && pnpm i --frozen-lockfile
# --no-engine
RUN npx prisma generate
RUN npm run build
FROM base AS runner
WORKDIR /app
ENV PORT=3000
# RUN sudo addgroup -g 1001 -S nodejs
# RUN sudo adduser -S nextjs -u 1001
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/content ./content
# COPY --from=builder /app/.contentlayer ./.contentlayer
COPY --from=builder /app/prisma ./prisma
COPY --from=builder /app/public ./public
COPY --from=builder /app/snippets ./snippets
COPY --from=builder /app/src ./src
# NOTE: 在 zeabur 中手动创建环境变量,不要在代码仓库中暴露敏感信息
# COPY --from=builder /app/.env ./.env
COPY --from=builder /app/.next ./.next
# COPY --from=builder --chown=nextjs:nodejs /app/.next ./.next
COPY --from=builder /app/mdx-components.tsx ./mdx-components.tsx
COPY --from=builder /app/next.config.mjs ./next.config.mjs
COPY --from=builder /app/package.json ./package.json
COPY --from=builder /app/tailwind.config.ts ./tailwind.config.ts
COPY --from=builder /app/postcss.config.js ./postcss.config.js
COPY --from=builder /app/tsconfig.json ./tsconfig.json
# USER nextjs
EXPOSE 3000
ENV NEXT_TELEMETRY_DISABLED 1
# COPY startup.sh ./startup.sh
# RUN chmod +x /app/startup.sh
# ENTRYPOINT ["sh", "/app/startup.sh"]
# NOTE: "next start" does not work with "output: standalone" configuration. Use "node .next/standalone/server.js" instead.
CMD ["node_modules/.bin/next", "start"]
# 构建镜像 docker build --progress=plain --no-cache -t yangtze-app:0.1.0 -f Dockerfile . 或 docker build --no-cache -t yangtze-app:0.1.0 . 或 docker build --no-cache . -t yangtze-app:0.1.0
# 运行镜像 docker run -p 3000:3000 yangtze-app:0.1.0