chore(deploy): 本地部署脚本、容器配置与运行说明

PostgreSQL/pgvector 与 Redis 独立容器,后端、worker、前端可一键启停;不覆盖既有密钥。
This commit is contained in:
WangShen007 committed 2026-10-19 21:30:00 +08:00
1 parent 83a16ed07d
commit 5be5ca3376
18 files changed
+1796

No files matched your search

+64
View File
@@ -0,0 +1,64 @@
# Build stage
FROM node:22-slim AS builder
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y \
wget \
curl \
&& rm -rf /var/lib/apt/lists/*
# Copy package files first
COPY frontend/package*.json ./
# Copy frontend source code
COPY frontend/ .
# Install dependencies with legacy peer deps
RUN npm install
# Build the application, widget, and webclient. Use the :prod webclient build so
# the shipped loader bakes the production fallback URL (the real backend URL is
# resolved at runtime via window.chattermateBaseUrl / APP_CONFIG regardless).
RUN npm run build-only && \
npm run build:widgetdocker && \
npm run build:webclient:prod && \
if [ ! -f dist/index.html ]; then \
echo "<!DOCTYPE html><html><head><meta charset='utf-8'><title>ChatterMate</title><link rel='icon' href='/favicon.ico'></head><body><div id='app'></div><script type='module' src='/src/main.ts'></script></body></html>" > dist/index.html; \
fi
# Production stage
FROM nginx:alpine
# Remove default nginx static assets
RUN rm -rf /usr/share/nginx/html/*
# Copy the built files to nginx
COPY --from=builder /app/dist/ /usr/share/nginx/html/
# Also serve the docker-built widget (widget.js/widget.css). build:widgetdocker
# emits these to /app/backend-assets; without this they are discarded and a
# frontend-served widget (VITE_WIDGET_URL -> frontend) falls back to the stale
# checked-in bundle. Fixed filenames, so this won't clobber hashed dashboard assets.
COPY --from=builder /app/backend-assets/ /usr/share/nginx/html/assets/
# Copy nginx configuration
COPY frontend/nginx.conf /etc/nginx/conf.d/default.conf
# Copy entrypoint script
COPY frontend/docker-entrypoint.sh /docker-entrypoint.sh
RUN chmod +x /docker-entrypoint.sh
# Expose port
EXPOSE 80
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://localhost/ || exit 1
# Use entrypoint script
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["nginx", "-g", "daemon off;"]