-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
34 lines (31 loc) · 949 Bytes
/
Copy pathDockerfile
File metadata and controls
34 lines (31 loc) · 949 Bytes
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
# ---- 构建前端 ----
FROM node:20-alpine AS client-build
WORKDIR /app/client
COPY client/package*.json ./
RUN npm ci
COPY client/ ./
RUN npm run build
# ---- 构建后端 ----
FROM node:20-alpine AS server-build
WORKDIR /app/server
COPY server/package*.json ./
RUN npm ci
COPY server/ ./
RUN npm run build
# ---- 运行环境 ----
FROM node:20-alpine
# 安装时区数据
RUN apk add --no-cache tzdata
WORKDIR /app
# 复制编译后的代码
COPY --from=server-build /app/server/dist ./dist
COPY --from=server-build /app/server/node_modules ./node_modules
COPY --from=server-build /app/server/package*.json ./
# [新增] 复制 Drizzle 配置文件和源码(用于建表)
COPY --from=server-build /app/server/drizzle.config.ts ./
COPY --from=server-build /app/server/tsconfig.json ./
COPY --from=server-build /app/server/src ./src
# 复制前端静态文件
COPY --from=client-build /app/client/dist ./public
EXPOSE 3001
CMD ["npm", "start"]