-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.dev.yml
More file actions
152 lines (146 loc) · 5.67 KB
/
Copy pathdocker-compose.dev.yml
File metadata and controls
152 lines (146 loc) · 5.67 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
services:
# ─────────────────────────────────────────
# PostgreSQL Database
# ─────────────────────────────────────────
postgres:
image: postgres:16-alpine
container_name: albumz_dev_postgres
restart: unless-stopped
ports:
- '5432:5432'
environment:
- POSTGRES_USER=${POSTGRES_USER:-admin}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-password}
- POSTGRES_DB=${POSTGRES_DB:-albumz}
volumes:
- postgres_dev_data:/var/lib/postgresql/data
healthcheck:
test:
[
'CMD-SHELL',
'pg_isready -U ${POSTGRES_USER:-admin} -d ${POSTGRES_DB:-albumz}',
]
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
networks:
- dev_network
# ─────────────────────────────────────────
# Database Migrations (runs once on startup)
# ─────────────────────────────────────────
migrate:
build:
context: ./api
dockerfile: Dockerfile
target: development
container_name: albumz_dev_migrate
command: ['pnpm', 'drizzle-kit', 'migrate']
environment:
- DATABASE_URL=postgresql://${POSTGRES_USER:-admin}:${POSTGRES_PASSWORD:-password}@postgres:5432/${POSTGRES_DB:-albumz}
depends_on:
postgres:
condition: service_healthy
networks:
- dev_network
restart: 'no'
# ─────────────────────────────────────────
# Database Seeding (runs once after migrations)
# ─────────────────────────────────────────
seed:
build:
context: ./api
dockerfile: Dockerfile
target: development
container_name: albumz_dev_seed
command: ['pnpm', 'db:seed']
environment:
- DATABASE_URL=postgresql://${POSTGRES_USER:-admin}:${POSTGRES_PASSWORD:-password}@postgres:5432/${POSTGRES_DB:-albumz}
depends_on:
migrate:
condition: service_completed_successfully
networks:
- dev_network
restart: 'no'
# ─────────────────────────────────────────
# tRPC + Fastify Backend API (Development)
# ─────────────────────────────────────────
api:
build:
context: ./api
dockerfile: Dockerfile
target: development
container_name: albumz_dev_api
restart: unless-stopped
ports:
- '3000:3000'
environment:
- NODE_ENV=development
- PORT=3000
- DATABASE_URL=postgresql://${POSTGRES_USER:-admin}:${POSTGRES_PASSWORD:-password}@postgres:5432/${POSTGRES_DB:-albumz}
- CORS_ORIGIN=http://localhost:5173
- JWT_SECRET=${JWT_SECRET}
# Optional integrations — set these in your root .env to enable them
- LASTFM_API_KEY=${LASTFM_API_KEY:-}
- SPOTIFY_CLIENT_ID=${SPOTIFY_CLIENT_ID:-}
- SPOTIFY_CLIENT_SECRET=${SPOTIFY_CLIENT_SECRET:-}
volumes:
# Mount source code for hot reload
- ./api/src:/app/src:cached
- ./api/package.json:/app/package.json:cached
- ./api/tsconfig.json:/app/tsconfig.json:cached
- ./api/.env:/app/.env:cached
- ./api/.env.schema:/app/.env.schema:cached
# Exclude node_modules to use container's version
- /app/node_modules
depends_on:
postgres:
condition: service_healthy
seed:
condition: service_completed_successfully
networks:
- dev_network
# ─────────────────────────────────────────
# SvelteKit Frontend (Development)
# ─────────────────────────────────────────
client:
build:
context: ./client
dockerfile: Dockerfile
target: development
container_name: albumz_dev_client
restart: unless-stopped
ports:
- '5173:5173'
environment:
- NODE_ENV=development
- PUBLIC_API_URL=http://localhost:3000
- API_URL=http://api:3000
volumes:
# Mount source code for hot reload
- ./client/src:/app/src:cached
- ./client/static:/app/static:cached
- ./client/package.json:/app/package.json:cached
- ./client/svelte.config.js:/app/svelte.config.js:cached
- ./client/vite.config.ts:/app/vite.config.ts:cached
- ./client/tsconfig.json:/app/tsconfig.json:cached
# Note: .env file is NOT mounted - using docker-compose environment variables instead
# Exclude node_modules and .svelte-kit to use container's version
- /app/node_modules
- /app/.svelte-kit
depends_on:
- api
networks:
- dev_network
# ─────────────────────────────────────────
# Volumes
# ─────────────────────────────────────────
volumes:
postgres_dev_data:
driver: local
# ─────────────────────────────────────────
# Networks
# ─────────────────────────────────────────
networks:
dev_network:
driver: bridge