-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
64 lines (61 loc) · 1.62 KB
/
Copy pathdocker-compose.yml
File metadata and controls
64 lines (61 loc) · 1.62 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
# Local development stack for express-ready-server.
#
# Both databases are provided so DB_TYPE can be switched without editing this file.
# In your .env, point the app at the right service:
# DB_TYPE=mongodb -> DB_HOST=mongo DB_PORT=27017
# DB_TYPE=mysql -> DB_HOST=mysql DB_PORT=3306
#
# Start: docker compose up --build
services:
app:
build: .
restart: unless-stopped
env_file:
- .env
environment:
# Override host/port so the app reaches the DB containers by service name.
DB_HOST: ${DB_HOST:-mongo}
DB_PORT: ${DB_PORT:-27017}
ports:
- "${PORT:-3000}:3000"
depends_on:
mongo:
condition: service_healthy
mysql:
condition: service_healthy
mongo:
image: mongo:7
restart: unless-stopped
ports:
- "27017:27017"
environment:
MONGO_INITDB_DATABASE: ${DB_NAME:-app}
volumes:
- mongo-data:/data/db
healthcheck:
test: ["CMD", "mongosh", "--quiet", "--eval", "db.adminCommand('ping')"]
interval: 10s
timeout: 5s
retries: 5
start_period: 20s
mysql:
image: mysql:8
restart: unless-stopped
ports:
- "3306:3306"
environment:
MYSQL_DATABASE: ${DB_NAME:-app}
MYSQL_USER: ${DB_USERNAME:-app}
MYSQL_PASSWORD: ${DB_PASSWORD:-app}
MYSQL_ROOT_PASSWORD: ${DB_PASSWORD:-rootpass}
volumes:
- mysql-data:/var/lib/mysql
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-uroot", "-p${DB_PASSWORD:-rootpass}"]
interval: 10s
timeout: 5s
retries: 5
start_period: 30s
volumes:
mongo-data:
mysql-data: