-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
55 lines (51 loc) · 1.62 KB
/
docker-compose.yml
File metadata and controls
55 lines (51 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
version: '3.9'
services:
# PostgreSQL Database
postgres:
image: postgres:16-alpine
container_name: halolight-postgres-node
restart: unless-stopped
ports:
- '${POSTGRES_PORT:-5433}:5432'
environment:
POSTGRES_DB: ${POSTGRES_DB:-halolight}
POSTGRES_USER: ${POSTGRES_USER:-halolight}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-halolight_password}
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ['CMD-SHELL', 'pg_isready -U ${POSTGRES_USER:-halolight}']
interval: 10s
timeout: 5s
retries: 5
# 如果使用外部数据库,注释掉整个 postgres 服务
# API Service
api:
build:
context: .
dockerfile: Dockerfile
container_name: halolight-api-node
env_file:
- .env.docker
restart: unless-stopped
ports:
- '${PORT:-3001}:3001'
environment:
NODE_ENV: ${NODE_ENV:-production}
PORT: 3001
DATABASE_URL: postgresql://${POSTGRES_USER:-halolight}:${POSTGRES_PASSWORD:-halolight_password}@postgres:5432/${POSTGRES_DB:-halolight}?schema=public
JWT_SECRET: ${JWT_SECRET}
JWT_EXPIRES_IN: ${JWT_EXPIRES_IN:-7d}
REFRESH_TOKEN_SECRET: ${REFRESH_TOKEN_SECRET}
REFRESH_TOKEN_EXPIRES_IN: ${REFRESH_TOKEN_EXPIRES_IN:-30d}
CORS_ORIGIN: ${CORS_ORIGIN:-*}
depends_on:
postgres:
condition: service_healthy
command: sh -c "pnpm prisma generate && pnpm prisma migrate deploy && node dist/index.js"
volumes:
postgres_data:
# 共享数据库场景:
# 1. 注释掉 postgres 服务
# 2. 修改 DATABASE_URL 指向外部数据库
# 3. 移除 depends_on