-
-
Notifications
You must be signed in to change notification settings - Fork 25
/
docker-compose.yaml
79 lines (73 loc) · 2.52 KB
/
docker-compose.yaml
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
version: "3"
volumes:
db_data: {}
services:
# The PostgreSQL container creates the codebuddies database on first launch.
# All data is stored in the db_data volume on the host machine. This ensures
# data is persisted across container restarts.
db:
image: postgres:11-alpine
container_name: db
restart: on-failure
ports:
- "5432:5432"
volumes:
- db_data:/var/lib/postgresql/data
environment:
- POSTGRES_PASSWORD=mysecretpassword
- POSTGRES_USER=babyyoda
- POSTGRES_DB=codebuddies
# The app container uses uwsgi to run the Django application. It is configured
# to run migrations on first start-up and to use Mailhog as the mail server.
# The application is not exposed to the host as all traffic is proxied through
# nginx. The local project folder is mounted into the container as a volume to
# allow development to be done on the host machine.
app:
build: ./project
container_name: app
restart: on-failure
command: >
sh -c "python /opt/codebuddies/manage.py collectstatic --clear --no-input &&
python /opt/codebuddies/manage.py migrate &&
uwsgi --ini /opt/codebuddies/uwsgi.ini"
working_dir: /opt/codebuddies
volumes:
- ./project:/opt/codebuddies
environment:
- DATABASE_URL=postgres://babyyoda:mysecretpassword@db:5432/codebuddies
- EMAIL_HOST=mailhog
depends_on:
- db
# The nginx front-end is configured to proxy all traffic to the Django application.
# We may want to use this to host static content. It is configured to reload
# configuration every 6 hours.
web:
image: nginx:1.17-alpine
container_name: web
restart: on-failure
ports:
- "8000:80"
volumes:
- ./nginx:/etc/nginx/conf.d
- ./project/staticfiles/:/static
command: '/bin/sh -c ''while :; do sleep 6h & wait $${!}; nginx -s reload; done & nginx -g "daemon off;"'''
depends_on:
- app
# Adminer is a front-end for PostgreSQL.
# It isn't required to run CodeBuddies but may be useful as a graphical interface
# to the database.
adminer:
image: adminer:latest
container_name: adminer
restart: on-failure
ports:
- 8001:8080
# Mailhog is a mail server that traps all outbound mail and presents it in a web
# interface that is easily browsable. This may prove useful when testing functionality
# that results in emails to users.
mailhog:
image: mailhog/mailhog:latest
container_name: mailhog
restart: on-failure
ports:
- 8025:8025