Repository navigation
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
143 lines (136 loc) · 4.18 KB
/
Copy pathdocker-compose.yml
File metadata and controls
143 lines (136 loc) · 4.18 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
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
143
# ----------------------------------------------------------------------------------------
# TMA Cloud | Docker Compose Configuration
# Installation Guide: https://tma-cloud.github.io/Wiki/docs/getting-started/installation/
# Prerequisites: '.env' and 'secrets/file_encryption_key' in the same directory.
# setup.sh creates both with random values:
# curl -fsSL https://raw.githubusercontent.com/TMA-Cloud/TMA/main/setup.sh | bash
# Update with ./update.sh. Rotate the master key and the database and Redis
# passwords with ./rotate.sh. Put local changes in compose.override.yml.
# ----------------------------------------------------------------------------------------
services:
# TMA Cloud App
app:
image: ghcr.io/tma-cloud/tma:latest
container_name: tma-cloud-app
restart: unless-stopped
ports:
- '${PORT:-3000}:3000'
env_file:
- .env
environment:
- PORT=3000
- FILE_ENCRYPTION_KEY_FILE=/run/secrets/file_encryption_key
secrets:
- file_encryption_key
healthcheck:
test: ['CMD', 'tma-server', 'healthcheck']
interval: 30s
timeout: 5s
retries: 3
start_period: 40s
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
networks:
- tma-cloud-network
# PostgreSQL database
postgres:
image: postgres:18-alpine
container_name: tma-cloud-postgres
restart: unless-stopped
environment:
- DATABASE_URL=${DATABASE_URL}
- POSTGRES_INITDB_ARGS=--encoding=UTF8 --locale=C
entrypoint:
- sh
- -c
- |
url="$${DATABASE_URL#*://}"; auth="$${url%@*}"; db="$${url##*@}"; db="$${db#*/}"
export POSTGRES_USER="$${auth%%:*}" POSTGRES_PASSWORD="$${auth#*:}" POSTGRES_DB="$${db%%[?]*}"
exec docker-entrypoint.sh "$$@"
- sh
#ports:
#- "127.0.0.1:5432:5432"
volumes:
- postgres-data:/var/lib/postgresql
networks:
- tma-cloud-network
command: >
postgres
-c shared_buffers=512MB
-c work_mem=8MB
-c maintenance_work_mem=128MB
-c max_connections=100
-c wal_compression=zstd
healthcheck:
test: ['CMD-SHELL', 'pg_isready -q -d "$$DATABASE_URL"']
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
# Redis Cache
redis:
image: redis:8-alpine
container_name: tma-cloud-redis
restart: unless-stopped
environment:
- REDIS_URL=${REDIS_URL}
command:
- sh
- -c
- |
auth="$${REDIS_URL#*://}"; auth="$${auth%%/*}"; pass=""
case "$$auth" in *:*@*) auth="$${auth%@*}"; pass="$${auth#*:}" ;; esac
exec docker-entrypoint.sh redis-server $${pass:+--requirepass "$$pass"} \
--appendonly yes --maxmemory 512mb --maxmemory-policy allkeys-lru
volumes:
- redis-data:/data
networks:
- tma-cloud-network
healthcheck:
test:
['CMD-SHELL', 'redis-cli -u "$$REDIS_URL" -h 127.0.0.1 -p 6379 --no-auth-warning ping | grep -q PONG || exit 1']
interval: 10s
timeout: 3s
retries: 3
# TMA Cloud background worker
worker:
image: ghcr.io/tma-cloud/tma:latest
container_name: tma-cloud-worker
restart: unless-stopped
env_file:
- .env
environment:
- FILE_ENCRYPTION_KEY_FILE=/run/secrets/file_encryption_key
secrets:
- file_encryption_key
command: ['tma-server', 'worker']
# The image's check calls the API port, which the worker does not serve. A
# crashed worker exits, and the restart policy brings it back.
healthcheck:
disable: true
depends_on:
app:
condition: service_started
postgres:
condition: service_healthy
redis:
condition: service_healthy
networks:
- tma-cloud-network
# The master key for every stored file, mounted at /run/secrets/file_encryption_key
# so it never appears in the environment or `docker inspect`. The app runs as uid
# 1001, so the file must be readable by it (setup.sh sets the permissions).
secrets:
file_encryption_key:
file: ./secrets/file_encryption_key
volumes:
postgres-data:
driver: local
redis-data:
driver: local
networks:
tma-cloud-network:
driver: bridge