forked from DAnikeyev/Linteum
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
170 lines (164 loc) · 4.91 KB
/
Copy pathdocker-compose.yml
File metadata and controls
170 lines (164 loc) · 4.91 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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
services:
linteum-db:
image: postgres:16
shm_size: 256M
container_name: ${DB_CONTAINER_NAME}
restart: unless-stopped
deploy:
resources:
limits:
memory: 512M
command: >
postgres
-c shared_buffers=256MB
-c work_mem=4MB
-c effective_cache_size=512MB
-c wal_buffers=16MB
-c checkpoint_completion_target=0.9
-c max_connections=100
environment:
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB}
ports:
- "${DB_HOST_PORT}:${DB_CONTAINER_PORT}"
networks:
- linteum_prod1
volumes:
- db_data:/var/lib/postgresql/data
healthcheck:
test: [ "CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}" ]
interval: 5s
timeout: 5s
retries: 10
# `daily.dump` (pg_dump -Fc): refreshed every time this loop runs (~24h). `weekly.dump`: copy of
# that day's `daily` on WEEKLY_BACKUP_WEEKDAY (date +%w, default 0=Sunday, TZ for calendar).
# Temp + mv for daily; copy to weekly.new + mv for weekly so a crash does not clobber a good weekly.
linteum-db-backup:
image: postgres:16
container_name: linteum-db-backup
restart: unless-stopped
deploy:
resources:
limits:
memory: 256M
environment:
PGPASSWORD: ${POSTGRES_PASSWORD}
PGUSER: ${POSTGRES_USER}
PGDATABASE: ${POSTGRES_DB}
PGHOST: ${DB_CONTAINER_NAME}
PGPORT: ${DB_CONTAINER_PORT}
TZ: ${TZ:-UTC}
WEEKLY_BACKUP_WEEKDAY: ${WEEKLY_BACKUP_WEEKDAY:-0}
BACKUP_INITIAL_DELAY_SECONDS: ${BACKUP_INITIAL_DELAY_SECONDS:-120}
depends_on:
linteum-db:
condition: service_healthy
networks:
- linteum_prod1
volumes:
- db_backups:/backups
entrypoint: [ "/bin/bash", "-c" ]
command:
- |
trap 'exit 0' SIGTERM
sleep "$${BACKUP_INITIAL_DELAY_SECONDS}"
while true; do
if pg_dump -Fc -f /backups/backup_in_progress.dump 2>>/backups/pg_dump.log; then
mv -f /backups/backup_in_progress.dump /backups/daily.dump
if [ "$$(date +%w)" = "$$WEEKLY_BACKUP_WEEKDAY" ]; then
cp -a /backups/daily.dump /backups/weekly.new.dump
mv -f /backups/weekly.new.dump /backups/weekly.dump
fi
else
rm -f /backups/backup_in_progress.dump
fi
sleep 86400 & wait $!
done
linteum-api:
build:
context: .
dockerfile: Linteum.Api/Dockerfile
container_name: ${API_CONTAINER_NAME}
restart: unless-stopped
deploy:
resources:
limits:
memory: 2048M
ports:
- "${API_HOST_PORT}:${API_CONTAINER_PORT}"
environment:
- ConnectionStrings__DefaultConnection=Host=${DB_CONTAINER_NAME};Database=${POSTGRES_DB};Username=${POSTGRES_USER};Password=${POSTGRES_PASSWORD};Maximum Pool Size=40;Minimum Pool Size=4;Timeout=30;Command Timeout=30
- MASTER_PASSWORD=${MASTER_PASSWORD}
- MASTER_USER=${MASTER_USER}
- MASTER_EMAIL=${MASTER_EMAIL}
- PASSWORD_SALT=${PASSWORD_SALT}
- GOOGLE_CLIENT_ID=${GOOGLE_CLIENT_ID}
- GOOGLE_CLIENT_SECRET=${GOOGLE_CLIENT_SECRET}
- NLOG_CONSOLE_MIN_LEVEL=${NLOG_CONSOLE_MIN_LEVEL}
- ASPNETCORE_HTTP_PORTS=${API_CONTAINER_PORT}
- CorsOrigins__0=http://localhost:${BLAZOR_HOST_PORT}
- CorsOrigins__1=http://${BLAZOR_CONTAINER_NAME}:${BLAZOR_CONTAINER_PORT}
depends_on:
linteum-db:
condition: service_healthy
networks:
- linteum_prod1
pull_policy: build
blazor:
build:
context: .
dockerfile: Linteum.BlazorApp/Dockerfile
restart: unless-stopped
deploy:
replicas: 3
resources:
limits:
memory: 256M
environment:
- PASSWORD_SALT=${PASSWORD_SALT}
- API_CONTAINER_NAME=${API_CONTAINER_NAME}
- API_CONTAINER_PORT=${API_CONTAINER_PORT}
- VERSION=${VERSION}
- HUB_LINK=${HUB_LINK}
- GOOGLE_CLIENT_ID=${GOOGLE_CLIENT_ID}
- ASPNETCORE_HTTP_PORTS=${BLAZOR_CONTAINER_PORT}
- ApiBaseUrl=http://${API_CONTAINER_NAME}:${API_CONTAINER_PORT}
ports:
- "5010-5012:${BLAZOR_CONTAINER_PORT}"
depends_on:
- linteum-api
networks:
- linteum_prod1
pull_policy: build
volumes:
- blazor_keys:/app/keys
linteum-bots:
build:
context: .
dockerfile: Linteum.Bots/Dockerfile
container_name: linteum-bots
restart: unless-stopped
deploy:
resources:
limits:
memory: 256M
environment:
- BOT_API_URL=http://${API_CONTAINER_NAME}:${API_CONTAINER_PORT}
- BOT_MASTER_PASSWORD=${MASTER_PASSWORD}
- BOT_TIMEOUT_MINUTES=10
depends_on:
- linteum-api
networks:
- linteum_prod1
profiles:
- bots
pull_policy: build
networks:
linteum_prod1:
name: linteum_prod1
driver: bridge
volumes:
db_data:
blazor_keys:
db_backups: