forked from imsyy/DailyHotApi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
50 lines (36 loc) · 1.09 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
FROM node:20-alpine AS base
ENV NODE_ENV=docker
# 安装 Puppeteer 所需的依赖库
RUN apk add libc6-compat
# RUN apk add chromium nss freetype harfbuzz ca-certificates
# 配置 Chromium
# ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
# ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser
FROM base AS builder
RUN npm install -g pnpm
WORKDIR /app
COPY package*json tsconfig.json pnpm-lock.yaml .env ./
COPY src ./src
COPY public ./public
RUN pnpm install
RUN pnpm build
RUN pnpm prune --production
FROM base AS runner
WORKDIR /app
# 创建用户和组
RUN addgroup --system --gid 114514 nodejs
RUN adduser --system --uid 114514 hono
# 创建日志目录
RUN mkdir -p /app/logs && chown -R hono:nodejs /app/logs
# 复制文件
COPY --from=builder --chown=hono:nodejs /app/node_modules /app/node_modules
COPY --from=builder --chown=hono:nodejs /app/dist /app/dist
COPY --from=builder /app/public /app/public
COPY --from=builder /app/.env /app/.env
COPY --from=builder /app/package.json /app/package.json
# 切换用户
USER hono
# 暴露端口
EXPOSE 6688
# 运行
CMD ["node", "/app/dist/index.js"]