-
Notifications
You must be signed in to change notification settings - Fork 9
/
docker-compose.yml
89 lines (69 loc) · 2.47 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
87
88
89
# docker-compose version : the latest and recommended version, cross compatible between compose and Docker Engine's swarm mode
version: '3'
# services : define the services that are going to be instantiated with docker-compose
services:
# defining our flask web application
flaskapp:
# build the Dockerfile that is in the web directory: http://bit.ly/2BpBPXq
build: ./web
# always restart the container regardless of the exit status; try and restart the container indefinitely
restart: always
# expose port 8000 to other containers (not to the host of the machine
expose:
- "8000"
# mount the web directory (http://bit.ly/2BbJO6k) within the container at /home/flask/app/web
volumes:
- ./web:/home/flask/app/web
# don't create this container until the redis and postgres containers (below) have been created
depends_on:
- redis
- postgres
# link the redis and postgres containers together so that they can talk to one another
links:
- redis
- postgres
# pass environment variables to the flask container (this debug lets us see more useful information)
environment:
FLASK_DEBUG: 1
# deploy with 3 replicas in the case of failure of one of the containers
deploy:
mode: replicated
replicas: 3
# defining the redis docker container for our web application
redis:
# use the redis:alpine image: https://hub.docker.com/_/redis/
image: redis:alpine
restart: always
deploy:
mode: replicated
replicas: 3
# defining the redis NGINX forward proxy container for our web application
nginx:
# build the nginx Dockerfile: http://bit.ly/2kuYaIv
build: nginx/
restart: always
# Expose port 80 to the host machine
ports:
- "80:80"
deploy:
mode: replicated
replicas: 3
# Our flask application needs to be available for NGINX to make successful proxy requests
depends_on:
- flaskapp
# defining our postgres database for our web application
postgres:
restart: always
# use the postgres alpine image: https://hub.docker.com/_/postgres/
image: postgres:alpine
# Mount an initialization script and the persistent postgresql data volume
volumes:
- ./postgres/init.sql:/docker-entrypoint-initdb.d/init.sql
- ./postgres/data:/var/lib/postgresql/data
# Pass postgres environment variables
environment:
POSTGRES_PASSWORD: linode123
POSTGRES_DB: linode
# Expose port 5432 to other docker containers
expose:
- "5432"