-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.server
60 lines (47 loc) · 1.05 KB
/
Dockerfile.server
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
# 构建阶段
FROM oven/bun:1 as builder
# 安装构建依赖
RUN apt-get update && apt-get install -y \
python3 \
build-essential \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# 复制 package.json 和 lock 文件
COPY package*.json ./
COPY bun.lockb ./
# 安装依赖
RUN bun install
# 复制源代码
COPY . .
# 运行阶段
FROM oven/bun:1-slim
# 安装 Playwright 依赖
RUN apt-get update && apt-get install -y \
python3 \
libnss3 \
libnspr4 \
libatk1.0-0 \
libatk-bridge2.0-0 \
libcups2 \
libdrm2 \
libxkbcommon0 \
libxcomposite1 \
libxdamage1 \
libxfixes3 \
libxrandr2 \
libgbm1 \
libasound2 \
&& rm -rf /var/lib/apt/lists/*
# 安装 Playwright 浏览器
RUN bunx playwright install --with-deps
WORKDIR /app
# 从构建阶段复制必要文件
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/hono ./hono
# 设置环境变量
ENV NODE_ENV=production
ENV PYTHON=/usr/bin/python3
# 暴露端口
EXPOSE 3001
# 启动应用
CMD ["bun", "./hono/index.ts"]