generated from NEARBuilders/project-template
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathdocker-compose.yml
86 lines (79 loc) · 2.21 KB
/
docker-compose.yml
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
services:
# DB service (shared configuration)
postgres:
image: postgres:15
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 5s
timeout: 5s
retries: 5
# Dev-specific postgres config
postgres_dev:
extends: postgres
container_name: postgres_dev
environment:
POSTGRES_DB: curatedotfun
ports:
- "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data # dev persists volumes, so you don't lose your setup
profiles: ["dev"]
# Test-specific postgres config
postgres_test:
extends: postgres
container_name: postgres_test
environment:
POSTGRES_DB: test
ports:
- "54321:5432"
# No volume for a fresh DB each time
profiles: ["test"]
# DB initialization (shared configuration)
db-init:
image: oven/bun:latest # we need bun to run the .ts scripts
working_dir: /app
volumes:
- ./backend:/app
# Development-specific initialization
db-init-dev:
extends: db-init
environment:
DATABASE_URL: postgresql://postgres:postgres@postgres_dev:5432/curatedotfun
depends_on:
postgres_dev:
condition: service_healthy
command: sh -c "bun add -g pnpm && pnpm install && pnpm run db:migrate && pnpm run db:seed:dev"
profiles: ["dev"]
# Test-specific initialization
db-init-test:
extends: db-init
environment:
DATABASE_URL: postgresql://postgres:postgres@postgres_test:5432/test
depends_on:
postgres_test:
condition: service_healthy
command: sh -c "bun add -g pnpm && pnpm install && pnpm run db:migrate && pnpm run db:seed:test"
profiles: ["test"]
# Application service
app:
build:
context: .
dockerfile: Dockerfile
depends_on:
postgres:
condition: service_healthy
environment:
DATABASE_URL: postgresql://postgres:postgres@postgres_dev:5432/curatedotfun
volumes:
- ./backend:/app/backend
- ./frontend:/app/frontend
env_file:
- ./backend/.env
ports:
- "3000:3000"
profiles: ["prod"] # we can run the app profile to test a production run
volumes:
postgres_data: