-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-compose.yaml
39 lines (36 loc) · 1.07 KB
/
docker-compose.yaml
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
services:
app:
build:
context: .
dockerfile: Dockerfile
container_name: api
working_dir: /usr/src/app
volumes:
- .:/usr/src/app
- /usr/src/app/node_modules # Avoid overwriting node_modules
ports:
- "3000:3000"
environment:
- DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres-db:5432/${POSTGRES_DB}
depends_on:
db:
condition: service_healthy # Wait until the db is healthy
command: npm run dev # Use the correct command to start your app in dev mode
db:
image: postgres:16-alpine
container_name: postgres_db
environment:
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB}
volumes:
- pgdata:/var/lib/postgresql/data # Persist Postgres data
ports:
- "5432:5432" # Expose PostgreSQL port to host
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER}"]
interval: 10s
timeout: 5s
retries: 5
volumes:
pgdata: # Define a persistent volume for PostgreSQL