-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
77 lines (72 loc) · 2.17 KB
/
docker-compose.yml
File metadata and controls
77 lines (72 loc) · 2.17 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
version: '3.8'
services:
pgadmin:
image: dpage/pgadmin4
container_name: inlab_pgadmin
restart: unless-stopped
environment:
PGADMIN_DEFAULT_EMAIL: admin@inlab.com
PGADMIN_DEFAULT_PASSWORD: admin
ports:
- "8080:80"
networks:
- inlab_network
depends_on:
- postgres
# Our PostgreSQL Database Service
postgres:
image: postgres:15-alpine
container_name: inlab_postgres
restart: unless-stopped
environment:
POSTGRES_DB: inlab_db
POSTGRES_USER: inlab_user
POSTGRES_PASSWORD: inlab_password
ports:
- "5432:5432" # Expose to host machine for external tools (optional)
volumes:
- ./backend/db/init.sql:/docker-entrypoint-initdb.d/01-init.sql
- postgres_data:/var/lib/postgresql/data
networks:
- inlab_network
# Health check is good practice for services that depend on each other
healthcheck:
test: ["CMD-SHELL", "pg_isready -U inlab_user -d inlab_db"]
interval: 5s
timeout: 5s
retries: 5
# Our Node.js Backend API Service
api:
build: ./backend # Tells Compose to build the image using the Dockerfile in this path
container_name: inlab_api
restart: unless-stopped
environment:
- NODE_ENV=production
# Update DB_HOST to use the service name! This is Docker's internal DNS.
- DB_HOST=postgres
- DB_PORT=5432
- DB_NAME=inlab_db
- DB_USER=inlab_user
- DB_PASSWORD=inlab_password
- PORT=3001
- JWT_SECRET=inlab_super_secret_jwt_key_change_in_production_123!
ports:
- "3001:3001" # Map host port 3001 to container port 3001
env_file:
- ./backend/.env
depends_on:
postgres:
condition: service_healthy # Wait for the DB to be healthy before starting the app
#volumes:
# Optional: Mount the source code for development with live reload.
# For now, we'll use the built image. We can add this later for development.
# - ./backend/src:/app/src
networks:
- inlab_network
# Use nodemon for development instead of 'npm start'
# command: npm run dev
volumes:
postgres_data:
networks:
inlab_network:
driver: bridge