generated from MarkFontenot/flask-mysql-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-compose.yml
64 lines (48 loc) · 1.81 KB
/
docker-compose.yml
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
version: "3.9"
# We are setting up 2 services: web and
services:
##################################################################
# configure the webserver container
web:
# Set up the web server according to the Dockerfile inside the api/ folder
build: flask-app/
# connect the src folder in on the host machine to the code folder in the container.
# note that the code folder in contaier is the working directory (see DockerFile).
volumes: ['./flask-app:/code', './secrets:/secrets']
# have the container restart if it fails for some reason.
restart: unless-stopped
# map host port 8001 to container port 4000 (see the EXPOSE command in api/Dockerfile)
ports:
- "8001:4000"
links:
- db
##################################################################
# configure the mysql container
db:
# We are using the base image of MySQL v.8
image: mysql:8
volumes:
# anything in (or mounted in) /docker-entrypoint-initdb.d in the container
# will automatically be executed when the container is created
- ./db:/docker-entrypoint-initdb.d/:ro
ports:
# mapping host port 3200 to container port 3306
- 3200:3306
restart: unless-stopped
# Setting up some environment variables for secrets.
# Here we are setting the root password
# as well as creating an additional user called
# webapp. webapp user password is stored in a secret
# file as well.
environment:
MYSQL_USER: webapp
MYSQL_PASSWORD_FILE: /run/secrets/secret_db_pw
MYSQL_ROOT_PASSWORD_FILE: /run/secrets/secret_db_root_pw
secrets:
- secret_db_pw
- secret_db_root_pw
secrets:
secret_db_pw:
file: ./secrets/db_password.txt
secret_db_root_pw:
file: ./secrets/db_root_password.txt