refactor(docker): simplify to single compose + dynamic build default

This commit is contained in:
rbetree
2026-02-20 00:52:23 +08:00
parent b2aeb0b355
commit f45df870d7
5 changed files with 98 additions and 66 deletions

38
Dockerfile.static Normal file
View File

@@ -0,0 +1,38 @@
# 静态构建版本(可选):构建阶段生成 dist运行阶段仅 nginx 提供静态文件。
# 默认 Docker 方案请使用仓库根目录的 Dockerfile动态构建可挂载配置并通过重启生效
FROM node:22-alpine AS builder
WORKDIR /app
ENV HUSKY=0
COPY package.json package-lock.json ./
RUN npm ci
COPY . .
ARG MENAV_ENABLE_SYNC=false
ARG MENAV_IMPORT_BOOKMARKS=false
RUN if [ "${MENAV_IMPORT_BOOKMARKS}" = "true" ]; then \
MENAV_BOOKMARKS_DETERMINISTIC=1 npm run import-bookmarks; \
fi \
&& if [ "${MENAV_ENABLE_SYNC}" = "true" ]; then \
npm run build; \
else \
PROJECTS_ENABLED=false HEATMAP_ENABLED=false RSS_ENABLED=false npm run build; \
fi
FROM nginx:1.27-alpine AS runtime
WORKDIR /usr/share/nginx/html
COPY docker/nginx/default.conf /etc/nginx/conf.d/default.conf
COPY --from=builder /app/dist ./
EXPOSE 80
STOPSIGNAL SIGQUIT
CMD ["nginx", "-g", "daemon off;"]