-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
61 lines (59 loc) · 1.68 KB
/
docker-compose.yml
File metadata and controls
61 lines (59 loc) · 1.68 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
# Main docker-compose file
# runs the actions for our GitHub workflows
services:
# creating database container
db:
build:
# context to point to correct folder
context: ./semgroup4-db
dockerfile: Dockerfile
# healthcheck before creating app container
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
# every 5s the container should run a healthcheck
interval: 5s
# the container should start after 10s of being built
start_period: 10s
# the healthcheck should run 20 times before exiting
retries: 20
restart: always
ports:
# fallback port for app and database
- "3306:3306"
# shared bridge between app and database
networks:
- semgroup4
environment:
# Sets the root password, % stands for root user
MYSQL_ROOT_PASSWORD: semgroup4
MYSQL_ROOT_HOST: "%"
MYSQL_DATABASE: world
# builds app container
app:
build: .
healthcheck:
test: ["CMD", "curl", "-h", "localhost"]
interval: 50s
# added so that the app only starts AFTER the database container is up and running
start_period: 40s
retries: 10
# We need to note this because this might break our app
restart: on-failure
stdin_open: true
tty: true
# app container will only start if database container passes the healthcheck
depends_on:
db:
condition: service_healthy
networks:
- semgroup4
environment:
DB_HOST: db
DB_PORT: 3306
DB_USER: root
DB_PASSWORD: semgroup4
DB_NAME: world
# creates the shared bridge network for both app and database containers
networks:
semgroup4:
driver: bridge