-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
98 lines (93 loc) · 3.5 KB
/
Copy pathdocker-compose.yml
File metadata and controls
98 lines (93 loc) · 3.5 KB
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
# Mapforge stack: app, MongoDB, Redis. See README.md#quick-start-with-docker-compose
# Start with: cp .env.example .env && docker compose up -d
name: mapforge
services:
mapforge:
image: ghcr.io/mapforge-org/mapforge:main
# To run a locally built image instead, comment out `image` above and use:
# build:
# context: ..
# dockerfile: deploy/Dockerfile
env_file: .env
environment:
MONGO_URL: mongo:27017
REDIS_URL: redis://redis:6379/1
# Set to true when a reverse proxy terminates TLS in front of the app.
FORCE_SSL: "false"
ports:
# Host port 3000 maps to Thruster in the container. Behind a reverse
# proxy, drop this mapping and route the proxy to port 3001 instead.
- "3000:3001"
volumes:
# The `z` flag relabels the directory for SELinux. Docker ignores it on
# systems without SELinux.
- ./volumes/storage:/rails/storage:z
# Geolocation of new maps, see README.md
# - ./GeoLite2-City.mmdb:/rails/db/GeoLite2-City.mmdb:ro
# Map preview pictures, written by the previews service.
- ./volumes/previews:/rails/public/previews:z
depends_on:
volumes-init:
condition: service_completed_successfully
mongo:
condition: service_healthy
redis:
condition: service_healthy
# The image defines the same healthcheck, see deploy/Dockerfile. It is
# repeated here because Podman does not report the healthcheck of an image
# to compose, and `depends_on: service_healthy` then fails.
healthcheck:
test: ["CMD-SHELL", "curl --connect-timeout 5 --max-time 5 -f http://localhost:$$HTTP_PORT/up || exit 1"]
interval: 10s
timeout: 5s
start_period: 30s
retries: 3
restart: unless-stopped
# Refreshes the map preview pictures every 3 minutes. Compose has no
# scheduler, so the job is a sleep loop. It needs no port and no volume of
# its own beyond the shared previews directory.
previews:
image: ghcr.io/mapforge-org/mapforge:main
env_file: .env
environment:
MONGO_URL: mongo:27017
REDIS_URL: redis://redis:6379/1
# The app container inside the compose network. Override it in .env if a
# reverse proxy terminates TLS, for example https://maps.example.com
MAPFORGE_HOST: ${MAPFORGE_HOST:-http://mapforge:3001}
command: ["sh", "-c", "while true; do bin/rake maps:screenshots; sleep 180; done"]
volumes:
- ./volumes/previews:/rails/public/previews:z
depends_on:
mapforge:
condition: service_healthy
restart: unless-stopped
# Docker creates a missing bind mount directory as root. The app container
# runs as the non-root `rails` user (UID 1000) and mongo as UID 999, so
# neither can chown its own directory.
volumes-init:
image: busybox
command: ["sh", "-c", "mkdir -p /volumes/storage /volumes/previews /volumes/mongodb && chown -R 1000:1000 /volumes/storage /volumes/previews && chown -R 999:999 /volumes/mongodb"]
volumes:
- ./volumes:/volumes:z
mongo:
image: mongo:8.2
volumes:
- ./volumes/mongodb:/data/db:z
depends_on:
volumes-init:
condition: service_completed_successfully
healthcheck:
test: ["CMD", "mongosh", "--quiet", "--eval", "db.adminCommand('ping')"]
interval: 10s
timeout: 10s
retries: 5
restart: unless-stopped
redis:
image: redis:7
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 5
restart: unless-stopped