forked from mathesar-foundation/mathesar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-compose.yml
100 lines (100 loc) · 3.77 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
90
91
92
93
94
95
96
97
98
99
100
version: "3.9"
# Please refer the documentation located at https://docs.mathesar.org/installation/docker-compose/ for the setting up Mathesar using this docker-compose.yml.
services:
db:
image: postgres:13
container_name: mathesar_db
environment:
# These environment variables are used to create a database and superuser when the `db` service starts.
# Refer to https://hub.docker.com/_/postgres for more information on these variables.
- POSTGRES_DB=${POSTGRES_DB-mathesar_django}
- POSTGRES_USER=${POSTGRES_USER-mathesar}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD-mathesar}
expose:
- "5432"
volumes:
- postgresql_data:/var/lib/postgresql/data
healthcheck:
test: [ "CMD-SHELL", "pg_isready -d $${POSTGRES_DB-mathesar_django} -U $${POSTGRES_USER-mathesar}"]
interval: 5s
timeout: 1s
retries: 30
start_period: 5s
# A caddy reverse proxy sitting in-front of all the services.
# It is responsible for routing traffic to the respective services
# It is also responsible for serving static files, automatically providing SSL certificate
# and preventing certain DDOS attacks
caddy-reverse-proxy:
image: mathesar/mathesar-caddy:latest
environment:
- DOMAIN_NAME=${DOMAIN_NAME-http://localhost}
# caddy container is exposed to the other containers, and the host.
ports:
- "${HTTP_PORT-80}:80"
- "${HTTPS_PORT-443}:443"
volumes:
- media:/mathesar/media
- static:/mathesar/static
- caddy_data:/data
- caddy_config:/config
labels:
- "com.centurylinklabs.watchtower.enable=true"
# A gunicorn WSGI HTTP Server that
# runs the Mathesar App.
# It depends on the `db` service
# and will start the `db` service automatically before starting itself.
service:
container_name: mathesar_service
image: mathesar/mathesar-prod:latest
environment:
- MODE=${MODE-PRODUCTION}
- DEBUG=${DEBUG-False}
- DJANGO_ALLOW_ASYNC_UNSAFE=true
- DJANGO_SETTINGS_MODULE=${DJANGO_SETTINGS_MODULE-config.settings.production}
- ALLOWED_HOSTS=${ALLOWED_HOSTS-*}
- SECRET_KEY=${SECRET_KEY}
- DJANGO_DATABASE_URL=${DJANGO_DATABASE_URL-postgres://mathesar:mathesar@mathesar_db:5432/mathesar_django}
- MATHESAR_DATABASES=${MATHESAR_DATABASES-(mathesar_tables|postgresql://mathesar:mathesar@mathesar_db:5432/mathesar)}
- DJANGO_SUPERUSER_PASSWORD=${DJANGO_SUPERUSER_PASSWORD}
entrypoint: ./run.sh
volumes:
- static:/code/static
- media:/code/media
depends_on:
# Comment the below field to disable starting the database service automatically
db:
condition: service_healthy
labels:
- "com.centurylinklabs.watchtower.enable=true"
healthcheck:
test: curl -f http://localhost:8000
interval: 10s
timeout: 5s
retries: 30
start_period: 5s
# On prod, the HTTP port is exposed to other containers, but not the host to prevent any unnecessary conflicts with external services.
# Do not make any changes to this port
expose:
- "8000"
# A webserver responsible for
# receiving upgrade requests and upgrading the Mathesar App docker image.
# It upgrades the docker image only when a http request is sent to it
# For more information refer https://containrrr.dev/watchtower/http-api-mode/
watchtower:
image: containrrr/watchtower
volumes:
- /var/run/docker.sock:/var/run/docker.sock
command: --http-api-update --label-enable --debug
environment:
- WATCHTOWER_HTTP_API_TOKEN=mytoken
labels:
- "com.centurylinklabs.watchtower.enable=false"
# Watchtower HTTP API is exposed to other containers, but not the host.
expose:
- "8080"
volumes:
postgresql_data:
media:
static:
caddy_data:
caddy_config: