Commit f56393de by Administrator

Update Dockerfile,优化构建速度

1 parent 5b138bcf
Showing 1 changed file with 17 additions and 14 deletions
......@@ -4,7 +4,10 @@
# ---- 构建前端 ----
FROM harbortest.glsx.com.cn/node/node:22.21.1-alpine3.21 AS builder
WORKDIR /app
ENV NODE_ENV=production
ENV SERVER_PORT=8787
RUN corepack enable
RUN npm config set registry https://registry.npmmirror.com/
COPY . .
RUN pnpm install
......@@ -13,20 +16,20 @@ RUN pnpm install
RUN pnpm build
# ---- 运行 ----
FROM harbortest.glsx.com.cn/node/node:22.21.1-alpine3.21 AS runner
WORKDIR /app
ENV NODE_ENV=production
ENV SERVER_PORT=8787
RUN corepack enable
# 只拷运行所需源码与前端产物,重新解析依赖(含 tsx 以运行 .ts)
COPY pnpm-lock.yaml package.json pnpm-workspace.yaml ./
COPY packages ./packages
COPY src ./src
COPY public ./public
COPY index.html vite.config.ts tsconfig.json tsconfig.node.json ./
COPY --from=builder /app/dist ./dist
RUN pnpm install
# FROM harbortest.glsx.com.cn/node/node:22.21.1-alpine3.21 AS runner
# WORKDIR /app
# ENV NODE_ENV=production
# ENV SERVER_PORT=8787
# RUN corepack enable
# # 只拷运行所需源码与前端产物,重新解析依赖(含 tsx 以运行 .ts)
# COPY pnpm-lock.yaml package.json pnpm-workspace.yaml ./
# COPY packages ./packages
# COPY src ./src
# COPY public ./public
# COPY index.html vite.config.ts tsconfig.json tsconfig.node.json ./
# COPY --from=builder /app/dist ./dist
# RUN pnpm install
# 账号目录挂为 volume(见 docker-compose.yml),避免写入镜像层
VOLUME ["/app/packages/server/data"]
EXPOSE 8787
CMD ["pnpm", "--filter", "@hm/server", "start"]
CMD ["pnpm", "--filter", "@hm/server", "start"]
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!