-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
65 lines (61 loc) · 2.2 KB
/
Copy pathdocker-compose.yml
File metadata and controls
65 lines (61 loc) · 2.2 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
# Docker Compose for teaching multi-container applications
# This file demonstrates:
# - Service orchestration
# - Container networking
# - Volume management
# - Environment configuration
# - Service dependencies
services:
# Application service
app:
build: . # Build from Dockerfile
container_name: landmark-app # Container name
ports:
- "3000:3000" # Map port 3000
environment:
# Database connection string
# Format: mysql://user:password@host:port/database
# 'db' is the service name (DNS resolution)
- DATABASE_URL=mysql://landmark:landmark123@db:3306/landmark_devops
- NODE_ENV=development
depends_on:
- db # Wait for db service to start
networks:
- landmark-network # Connect to custom network
# Uncomment for development with hot reload
# volumes:
# - ./client:/app/client
# - ./server:/app/server
# Database service
db:
image: mysql:8.0 # Use official MySQL image
container_name: landmark-db # Container name
environment:
# MySQL root password
- MYSQL_ROOT_PASSWORD=root123
# Database to create
- MYSQL_DATABASE=landmark_devops
# Non-root user for application
- MYSQL_USER=landmark
- MYSQL_PASSWORD=landmark123
ports:
- "3307:3306" # Map port 3307 -> 3306
volumes:
# Named volume for persistent data
# Data survives container restart
- db_data:/var/lib/mysql
networks:
- landmark-network # Connect to custom network
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
interval: 10s
timeout: 5s
retries: 5
# Named volumes for persistent storage
volumes:
db_data:
driver: local
# Custom network for service communication
networks:
landmark-network:
driver: bridge