-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-compose.yml
86 lines (79 loc) · 2.57 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# Docker compose file for local development
version: '3.9'
services:
django:
container_name: django
restart: always
build:
context: ./time_tracker # . means directory where we run docker-compose command from
dockerfile: Dockerfile
volumes:
- ./time_tracker:/home/time_tracker # Bind mount: reflects source code changes in container
- /home/time_tracker/venv # Avoid copying virtual environment set up in the container to localhost
- static:/home/time_tracker/static_root # Named volume shared with the nginx container
ports:
- '127.0.0.1:8000:8000'
depends_on:
- mysql
- redis
env_file:
- ./env/django.env
command:
- bash
- -c
- |
flake8
python3.10 manage.py wait_for_db --wait-interval 0.5
python3.10 manage.py makemigrations
python3.10 manage.py migrate
# coverage run manage.py test
# coverage report | grep TOTAL | awk '{print $$6}' > coverage.txt
# coverage html
# coverage-badge -f -o coverage.svg
if ! [[ $$(mysql --user="$${MYSQL_USER}" --password="$${MYSQL_PASSWORD}" -h mysql -ss -e "select * from time_tracker_db.classic_tracker_user" 2> /dev/null) ]]; then
echo "No user found in database, creating superuser"
python3.10 manage.py createsuperuser --noinput
fi
python3.10 manage.py collectstatic --no-input
gunicorn -c gunicorn_conf.py time_tracker.wsgi
# python3.10 manage.py runserver 0.0.0.0:8000
mysql:
container_name: mysql
restart: always
image: mysql:8.0.30
volumes:
- mysql_data:/var/lib/mysql
# - ./mysql/general-log.log:/var/lib/mysql/general-log.log
ports:
- '3306:3306' # So that data can be viewed in IDE
env_file:
- ./env/mysql.env
# command:
# --general-log=1
# --general-log-file=/var/lib/mysql/general-log.log
# # Use --log-output='table' in order to log to mysql.general_log table
redis:
container_name: redis
restart: always
image: redis:7.0.5-alpine
volumes:
- redis_data:/data
ports:
- '6379:6379' # So that data can be viewed using redis-cli
nginx:
container_name: nginx
restart: always
build:
context: ./nginx
dockerfile: Dockerfile
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf # Bind mount: reflects source code changes in container
- static:/static # Named volume shared with the django container
ports:
- '80:80'
depends_on:
- django
volumes:
mysql_data:
redis_data:
static: