-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
69 lines (57 loc) · 1.4 KB
/
Dockerfile
File metadata and controls
69 lines (57 loc) · 1.4 KB
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
# 使用 Node.js 18 作为基础镜像
FROM node:18-alpine
# 设置工作目录
WORKDIR /app
# 设置 Alpine 国内镜像源
RUN echo "https://mirrors.aliyun.com/alpine/v3.18/main" > /etc/apk/repositories && \
echo "https://mirrors.aliyun.com/alpine/v3.18/community" >> /etc/apk/repositories
# 安装 canvas 依赖和字体
RUN apk add --update --no-cache \
make \
g++ \
jpeg-dev \
cairo-dev \
giflib-dev \
pango-dev \
libtool \
autoconf \
automake \
python3 \
pixman-dev \
freetype-dev \
fontconfig-dev \
pkgconfig \
build-base \
gcc \
musl-dev \
libpng-dev \
librsvg-dev \
ttf-dejavu \
ttf-droid \
ttf-freefont \
ttf-liberation \
font-noto \
font-noto-cjk
# 设置国内镜像源
RUN npm config set registry https://registry.npmmirror.com
# 安装 pnpm 和 node-gyp
RUN npm install -g pnpm node-gyp && \
pnpm config set registry https://registry.npmmirror.com
# 复制 package.json 和 pnpm-lock.yaml
COPY package.json pnpm-lock.yaml ./
# 安装项目依赖并重新构建 canvas
RUN pnpm install && \
cd node_modules/canvas && \
node-gyp rebuild && \
cd ../..
# 复制源代码
COPY . .
# 构建 TypeScript 代码
RUN pnpm run build
# 暴露端口
EXPOSE 3008
# 设置环境变量
ENV NODE_ENV=production
ENV PKG_CONFIG_PATH=/usr/lib/pkgconfig:/usr/share/pkgconfig
# 启动应用
CMD ["pnpm", "start"]