-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdocker-compose.yaml
142 lines (130 loc) · 5.38 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# Ben Payne
# Physics Derivation Graph
# https://allofphysics.com
# Creative Commons Attribution 4.0 International License
# https://creativecommons.org/licenses/by/4.0/
# https://docs.docker.com/compose/compose-file/
services:
flask:
build:
context: ./flask
dockerfile: Dockerfile.gunicorn
restart: unless-stopped
environment:
- GOOGLE_CLIENT_ID=${GOOGLE_CLIENT_ID}
- GOOGLE_CLIENT_SECRET=${GOOGLE_CLIENT_SECRET}
- SECRET_KEY=${SECRET_KEY}
# https://docs.gunicorn.org/en/stable/settings.html
# https://pythonspeed.com/articles/gunicorn-in-docker/
command: >
gunicorn
--reload
--bind 0.0.0.0:5000
--forwarded-allow-ips="*"
--log-level debug
wsgi:app
--capture-output
--log-file=logs/gunicorn_logs.log
--access-logformat='{"ip":"%({X-Forwarded-For}i)s", "reqtime":"%(L)s", "uname":"%(u)s", "date":"%(t)s", "statline":"%(r)s", "stat":"%(s)s", "resplen":"%(b)s", "ref":"%(f)s", "ua":"%(a)s"}'
--access-logfile=logs/gunicorn_access.log
--error-logfile=logs/gunicorn_error.log
--worker-tmp-dir /dev/shm
--workers=2
--threads=4
--worker-class=gthread
# --enable-stdio-inheritance
expose:
- 5000
# using "ports" makes flask/gunicorn accessible without going through nginx
# ports:
# - "5000:5000"
depends_on:
neo4j_docker:
# https://docs.docker.com/compose/compose-file/05-services/#healthcheck
condition: service_healthy
networks:
neo4j-internal:
aliases:
- neo4j-network
volumes:
- ${PWD}/:/scratch
- './dumping_grounds:/code/static/dumping_grounds'
- ${PWD}/flask/logs:/home/appuser/app/logs/
- ${PWD}/flask/users_sqlite.db:/home/appuser/app/users_sqlite.db
- ${PWD}/flask/data.json:/home/appuser/app/data.json
- /var/log/auth.log:/home/appuser/app/logs/auth.log
# healthcheck:
# test: wget http://localhost:5000 || exit 1
# interval: 3s
# timeout: 10s
# retries: 20
# start_period: 3s
# see https://neo4j.com/docs/operations-manual/current/docker/introduction/
# https://neo4j.com/docs/operations-manual/current/docker/clustering/
# https://stackoverflow.com/questions/48465046/run-neo4j-with-docker-compose-neo4j-not-accessible-from-localhost7474
# https://medium.com/@faaizhussain/neo4j-4-0-docker-compose-9bead6634c8
neo4j_docker:
image: neo4j:4.4.4-community # https://hub.docker.com/_/neo4j/tags
restart: unless-stopped
hostname: neo4j_host
#network_mode: "bridge"
# https://stackoverflow.com/a/48637671/1164295
networks:
neo4j-internal:
aliases:
- neo4j-network
# The ports that will be accessible from outside the container
# 7474=HTTP, 7473=HTTPS, 7687=Bolt; as per https://neo4j.com/developer/docker-run-neo4j/
expose:
- "7474:7474"
- "7473:7473"
- "7687:7687"
# as per https://neo4j.com/docs/operations-manual/current/docker/clustering/
volumes:
- './neo4j_pdg/data:/var/lib/neo4j/data'
- './neo4j_pdg/logs:/var/lib/neo4j/logs'
- './neo4j_pdg/conf:/var/lib/neo4j/conf'
- './neo4j_pdg/plugins:/var/lib/neo4j/plugins'
- './dumping_grounds:/var/lib/neo4j/dumping_grounds'
# https://docs.docker.com/compose/compose-file/compose-file-v3/#environment
# see https://neo4j.com/docs/operations-manual/current/docker/ref-settings/
# https://community.neo4j.com/t/docker-compose-setting-for-apoc-installation/11621/9
# https://linuxtut.com/en/a37f1ee0e486658d10de/
# https://neo4j.com/labs/apoc/4.1/installation/
environment:
- NEO4J_dbms_allow__upgrade=true
- NEO4J_AUTH=none
- NEO4J_apoc_export_file_enabled=true
- NEO4J_apoc_import_file_enabled=true
- NEO4J_apoc_import_file_use__neo4j__config=true
- NEO4J_dbms_directories_import=dumping_grounds # relative to /var/lib/neo4j
- NEO4J_dbms_security_procedures_allowlist=gds.*, apoc.*
# - NEO4JLABS_PLUGINS=["apoc"] # downloads from gitlab everytime the container is started
# https://docs.docker.com/reference/dockerfile/#healthcheck -- official documentation
# https://stackoverflow.com/a/74689805/1164295 -- a concise and relevant example
healthcheck:
test: wget http://localhost:7474 || exit 1
interval: 120s # The health check will first run interval seconds after the container is started, and then again interval seconds after each previous check completes.
timeout: 60s # If a single run of the check takes longer than timeout seconds then the check is considered to have failed.
retries: 10 # It takes retries consecutive failures of the health check for the container to be considered unhealthy.
start_period: 120s # provides initialization time for containers that need time to bootstrap. Probe failure during that period will not be counted towards the maximum number of retries. However, if a health check succeeds during the start period, the container is considered started and all consecutive failures will be counted towards the maximum number of retries.
nginx:
build: ./services/nginx
restart: on-failure
ports:
- "80:80"
- "443:443"
# - 1337:80
volumes:
- ${PWD}/flask/logs/:/logs/
- ${PWD}/certs/:/certs/
depends_on:
- flask
networks:
neo4j-internal:
aliases:
- neo4j-network
networks:
neo4j-internal:
driver: bridge
# EOF