-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
114 lines (108 loc) · 2.77 KB
/
Copy pathdocker-compose.yml
File metadata and controls
114 lines (108 loc) · 2.77 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
# Local end-to-end stack.
#
# Usage:
# cp backend/.env.example backend/.env
# cp frontend/.env.example frontend/.env
# docker compose up --build
#
# Frontend: http://localhost:3000
# Backend: http://localhost:4000/api
# Swagger: http://localhost:4000/docs
# Postgres: localhost:5432 (jsstack/jsstack)
services:
postgres:
image: postgres:16-alpine
container_name: jsstack-local-postgres
restart: unless-stopped
environment:
POSTGRES_DB: jsstack
POSTGRES_USER: jsstack
POSTGRES_PASSWORD: jsstack
ports:
- "5432:5432"
volumes:
- jsstack_local_pg_data:/var/lib/postgresql/data
healthcheck:
test: [ "CMD-SHELL", "pg_isready -U jsstack" ]
interval: 5s
timeout: 5s
retries: 10
networks:
- jsstack_local
redis:
image: redis:7-alpine
container_name: jsstack-local-redis
restart: unless-stopped
ports:
- "6379:6379"
healthcheck:
test: [ "CMD", "redis-cli", "ping" ]
interval: 5s
timeout: 5s
retries: 10
networks:
- jsstack_local
api:
build:
context: ./backend
dockerfile: Dockerfile
target: app
container_name: jsstack-local-api
restart: unless-stopped
env_file:
- ./backend/.env
environment:
# Override host-specific values so the API talks to the
# *containers* on this network, not localhost.
PG_HOST: postgres
REDIS_HOST: redis
ports:
- "4000:4000"
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
migrate:
condition: service_completed_successfully
healthcheck:
test: [ "CMD", "wget", "-qO-", "http://localhost:4000/health" ]
interval: 15s
timeout: 5s
retries: 5
start_period: 20s
networks:
- jsstack_local
web:
build:
context: ./frontend
dockerfile: Dockerfile
target: app
args:
# Baked into the client bundle — must be the URL *your browser*
# can reach. localhost:4000 works because we publish that port above.
NEXT_PUBLIC_API_URL: http://localhost:4000/api
container_name: jsstack-local-web
restart: unless-stopped
environment:
# Server-side fetches (Server Components) go straight to the
# api container over the Docker network — mirrors API_BASE_URL_SERVER
API_BASE_URL_SERVER: http://api:4000/api
ports:
- "3000:3000"
depends_on:
- api
healthcheck:
test: [ "CMD", "wget", "-qO-", "http://localhost:3000/" ]
interval: 15s
timeout: 5s
retries: 5
start_period: 20s
networks:
- jsstack_local
networks:
jsstack_local:
name: jsstack_local
volumes:
jsstack_local_pg_data:
name: jsstack_local_pg_data