-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
90 lines (84 loc) · 2.47 KB
/
docker-compose.yml
File metadata and controls
90 lines (84 loc) · 2.47 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
name: labtasker
services:
mongo-init-keyfile: # 1. setup keyfile
image: mongo:latest
restart: no
volumes:
- ./docker/mongodb/init.d:/init.d:ro
- mongo-keyfile:/data/configdb:rw
entrypoint: [ "/bin/bash", "-c", 'exec "$@"', "--" ]
command: [ "/init.d/init-keyfile.sh" ]
mongodb: # 2. start mongodb
image: mongo:latest
container_name: labtasker-mongodb
depends_on:
mongo-init-keyfile:
condition: service_completed_successfully
environment:
- MONGO_INITDB_ROOT_USERNAME=${DB_USER}
- MONGO_INITDB_ROOT_PASSWORD=${DB_PASSWORD}
- MONGO_INITDB_DATABASE=${DB_NAME:-labtasker_db}
command: [ "--bind_ip_all", "--replSet", "rs0", "--keyFile", "/data/configdb/mongo-keyfile" ]
volumes:
- mongo-data:/data/db:rw
- mongo-keyfile:/data/configdb:rw
ports:
- ${EXPOSE_DB:+${DB_PORT:-27017}:27017}
networks:
- labtasker-network
healthcheck:
test: echo 'db.runCommand("ping").ok' | mongosh localhost:27017/test --quiet
interval: 10s
timeout: 10s
retries: 5
start_period: 60s
restart: unless-stopped
mongo-post-init: # 3. setup replica set and database
image: mongo:latest
restart: no
depends_on:
mongodb:
condition: service_healthy
volumes:
- ./docker/mongodb/post-init.d:/post-init.d:ro
environment:
- MONGO_INITDB_ROOT_USERNAME=${DB_USER}
- MONGO_INITDB_ROOT_PASSWORD=${DB_PASSWORD}
- MONGO_INITDB_DATABASE=${DB_NAME:-labtasker_db}
entrypoint: [ "/bin/bash", "-c", 'exec "$@"', "--" ]
command: [ "/post-init.d/init-mongo.sh" ]
networks:
- labtasker-network
api:
build:
context: .
dockerfile: Dockerfile
network: host
image: ghcr.io/luocfprime/labtasker-api
container_name: labtasker-api
environment:
- DB_USER=${DB_USER}
- DB_PASSWORD=${DB_PASSWORD}
- DB_NAME=${DB_NAME:-labtasker_db}
- DB_HOST=mongodb
- DB_PORT=${DB_PORT:-27017}
- API_HOST=${API_HOST:-0.0.0.0}
- API_PORT=${API_PORT:-9321}
- PERIODIC_TASK_INTERVAL=${PERIODIC_TASK_INTERVAL:-30}
ports:
- "${API_PORT:-9321}:${API_PORT:-9321}"
depends_on:
mongodb:
condition: service_healthy
networks:
- labtasker-network
restart: unless-stopped
volumes:
mongo-data:
name: labtasker-mongo-data
mongo-keyfile:
name: labtasker-mongo-keyfile
networks:
labtasker-network:
name: labtasker-network
driver: bridge