fix: bug
This commit is contained in:
20
Dockerfile
20
Dockerfile
@@ -1,11 +1,23 @@
|
||||
# 仅后端 API 镜像(前端自行部署)
|
||||
# 前端 + 后端合一镜像:构建阶段产出 dist,运行阶段提供静态与 API(含修订页 /edit)
|
||||
# 国内服务器拉取慢时,可加 --build-arg REGISTRY=docker.m.daocloud.io/library
|
||||
ARG REGISTRY=
|
||||
|
||||
# ---------- 阶段 1:构建前端 ----------
|
||||
FROM ${REGISTRY}node:20-slim AS frontend-builder
|
||||
WORKDIR /app
|
||||
RUN npm config set registry https://registry.npmmirror.com
|
||||
COPY package*.json ./
|
||||
RUN npm ci
|
||||
COPY vite.config.ts index.html tsconfig.json tsconfig.app.json ./
|
||||
COPY postcss.config.js tailwind.config.js ./
|
||||
COPY src ./src
|
||||
RUN npm run build
|
||||
|
||||
# ---------- 阶段 2:运行(API + 静态) ----------
|
||||
FROM ${REGISTRY}node:20-slim
|
||||
|
||||
RUN npm config set registry https://registry.npmmirror.com
|
||||
|
||||
# Debian 12 使用 sources.list.d,改为国内源避免 build 时连接超时
|
||||
RUN rm -f /etc/apt/sources.list.d/debian.sources && \
|
||||
echo 'deb http://mirrors.aliyun.com/debian bookworm main' > /etc/apt/sources.list && \
|
||||
echo 'deb http://mirrors.aliyun.com/debian bookworm-updates main' >> /etc/apt/sources.list && \
|
||||
@@ -13,13 +25,11 @@ RUN rm -f /etc/apt/sources.list.d/debian.sources && \
|
||||
apt-get update && apt-get install -y --no-install-recommends python3 make g++ && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY package*.json ./
|
||||
RUN npm ci --omit=dev
|
||||
|
||||
COPY server ./server
|
||||
COPY --from=frontend-builder /app/dist ./dist
|
||||
|
||||
ENV NODE_ENV=production
|
||||
ENV API_PORT=3001
|
||||
|
||||
Reference in New Issue
Block a user