31 lines
607 B
Docker
31 lines
607 B
Docker
# 第一阶段: 构建
|
||
FROM node:22-alpine AS builder
|
||
WORKDIR /app
|
||
|
||
# 安装必要的系统依赖(Prisma 需要)
|
||
RUN apk add --no-cache openssl
|
||
|
||
COPY package*.json ./
|
||
RUN npm ci
|
||
|
||
COPY . .
|
||
RUN npx prisma generate
|
||
RUN npx tsc
|
||
|
||
# 第二阶段: 运行
|
||
FROM node:22-alpine
|
||
WORKDIR /app
|
||
|
||
# 安装 OpenSSL(Prisma 运行时依赖)
|
||
RUN apk add --no-cache openssl
|
||
|
||
COPY --from=builder /app/package*.json ./
|
||
COPY --from=builder /app/node_modules ./node_modules
|
||
COPY --from=builder /app/dist ./dist
|
||
COPY --from=builder /app/prisma ./prisma
|
||
COPY start.sh ./
|
||
RUN chmod +x start.sh
|
||
|
||
EXPOSE 3001
|
||
CMD ["./start.sh"]
|