From 0b3998489df7359dd69656bb78635bd06d9f543f Mon Sep 17 00:00:00 2001 From: tonytech Date: Sat, 28 Feb 2026 19:32:54 +0800 Subject: [PATCH] =?UTF-8?q?feat(deploy):=20=E6=B7=BB=E5=8A=A0=20docker-com?= =?UTF-8?q?pose=20=E4=B8=80=E9=94=AE=E9=83=A8=E7=BD=B2=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 定义 backend 和 frontend 两个服务: - backend 监听 3001 端口,设置 Prisma OpenSSL 3.x 环境变量, JWT_SECRET 通过宿主机环境变量注入避免硬编码 - frontend 监听 8080 端口,depends_on backend 保证启动顺序 使用方式: JWT_SECRET=your-secret docker-compose up -d --- docker-compose.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 docker-compose.yml diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..be0ef63 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,28 @@ +version: '3.8' + +services: + backend: + build: + context: ./reading-platform-backend + container_name: kindergarten-backend + restart: unless-stopped + ports: + - "3001:3001" + environment: + - PORT=3001 + - NODE_ENV=production + - DATABASE_URL=file:/app/prisma/dev.db + - JWT_SECRET=${JWT_SECRET:-change-this-secret} + - JWT_EXPIRES_IN=7d + - FRONTEND_URL=http://localhost:8080 + - PRISMA_QUERY_ENGINE_LIBRARY=/app/node_modules/.prisma/client/libquery_engine-linux-musl-openssl-3.0.x.so.node + + frontend: + build: + context: ./reading-platform-frontend + container_name: kindergarten-frontend + restart: unless-stopped + ports: + - "8080:80" + depends_on: + - backend