-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathcompose.yaml
More file actions
251 lines (237 loc) · 8.9 KB
/
compose.yaml
File metadata and controls
251 lines (237 loc) · 8.9 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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
name: lcp
services:
# Nginx reverse proxy
nginx:
image: nginx:1.27-alpine
restart: unless-stopped
ports:
- "80:80"
- "443:443"
volumes:
# Reads the nginx configuration file in the config folder of the host machine
- ./config/nginx.conf:/etc/nginx/nginx.conf:ro
# Uncomment for SSL certificates:
# - ./config/ssl:/etc/ssl:ro
depends_on:
server:
condition: service_healthy
healthcheck:
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
# LCP Encrypt service
encrypt:
build:
context: .
target: final
command: ["/app/lcpencrypt", "-serve"]
volumes:
# Where LCP Encrypt finds input files (comment if using lcpencrypt as a separate service)
# A Bind Mount is necessary, as the FTP Server is running outside Docker
- ${LCPENCRYPT_INPUT_PATH:-./input}:/input
# Where LCP Encrypt stores encrypted publications and covers (comment if the resources are stored on a Cloud server)
# A Bind Mount makes it easier to backup the resources folder from the host system
- ${LCPENCRYPT_STORAGE_PATH:-./resources}:/resources
environment:
- LCPENCRYPT_PROVIDER_URI=${LCPENCRYPT_PROVIDER_URI}
# Paths inside the container (mounted via volumes above)
- LCPENCRYPT_INPUT_PATH=/input
- LCPENCRYPT_STORAGE_PATH=/resources
- LCPENCRYPT_STORAGE_URL=${LCPENCRYPT_STORAGE_URL}
- LCPENCRYPT_LCPSERVER_URL=${LCPENCRYPT_LCPSERVER_URL}
- LCPENCRYPT_VERBOSE=${LCPENCRYPT_VERBOSE}
- LCPENCRYPT_USE_FILENAME_AS=${LCPENCRYPT_USE_FILENAME_AS}
- LCPENCRYPT_V2=${LCPENCRYPT_V2}
- LCPENCRYPT_COVER=${LCPENCRYPT_COVER}
- LCPENCRYPT_PDF_NO_META=${LCPENCRYPT_PDF_NO_META}
- LCPENCRYPT_CMS_URL=${LCPENCRYPT_CMS_URL}
# Activate the following lines to run LCP Encrypt only when needed
# using 'docker compose --profile encrypt up'
# profiles:
# - encrypt
depends_on:
server:
condition: service_healthy
# LCP Server service
server:
build:
context: .
target: final
# Only accessible through nginx
expose:
- "8989"
# Temporarily expose port for testing without nginx - to be commented
#ports:
# - "8989:8989"
volumes:
# Activate if using SQLite
#- db-data:/database
# Where the service finds encrypted publications and covers (comment if the resources are stored on a Cloud server)
- ${LCPENCRYPT_STORAGE_PATH:-./resources}:/resources
environment:
# --- LCP Server Configuration ---
# Values are sourced from the .env file at the root of the project.
# See pkg/conf/config.go for all available environment variables.
- LCPSERVER_LOGLEVEL=${LCPSERVER_LOGLEVEL}
- LCPSERVER_PUBLICBASEURL=${LCPSERVER_PUBLICBASEURL}
- LCPSERVER_PORT=${LCPSERVER_PORT}
- LCPSERVER_DSN=${LCPSERVER_DSN}
- LCPSERVER_CERTIFICATE_CERT=${LCPSERVER_CERTIFICATE_CERT}
- LCPSERVER_CERTIFICATE_PRIVATEKEY=${LCPSERVER_CERTIFICATE_PRIVATEKEY}
- LCPSERVER_LICENSE_PROVIDER=${LCPSERVER_LICENSE_PROVIDER}
- LCPSERVER_LICENSE_PROFILE=${LCPSERVER_LICENSE_PROFILE}
- LCPSERVER_LICENSE_HINTLINK=${LCPSERVER_LICENSE_HINTLINK}
- LCPSERVER_STATUS_FRESHLICENSELINK=${LCPSERVER_STATUS_FRESHLICENSELINK}
- LCPSERVER_STATUS_ALLOWRENEWONEXPIREDLICENSES=${LCPSERVER_STATUS_ALLOWRENEWONEXPIREDLICENSES}
- LCPSERVER_STATUS_RENEWDEFAULTDAYS=${LCPSERVER_STATUS_RENEWDEFAULTDAYS}
- LCPSERVER_STATUS_RENEWMAXDAYS=${LCPSERVER_STATUS_RENEWMAXDAYS}
- LCPSERVER_STATUS_RENEWLINK=${LCPSERVER_STATUS_RENEWLINK}
- LCPSERVER_DASHBOARD_EXCESSIVESHARINGTHRESHOLD=${LCPSERVER_DASHBOARD_EXCESSIVESHARINGTHRESHOLD}
- LCPSERVER_DASHBOARD_LIMITTOLAST12MONTHS=${LCPSERVER_DASHBOARD_LIMITTOLAST12MONTHS}
# Path inside the container (mounted via volume above)
- LCPSERVER_RESOURCES=/resources
# Path to the access file for basic authentication and JWT admin accounts
- LCPSERVER_ACCESS_FILE=/run/secrets/access
# Path to MySQL password file for secure DSN construction
- MYSQL_PASSWORD_FILE=/run/secrets/mysql-password
# Path to JWT secret key file for secure token signing
- JWT_SECRETKEY_FILE=/run/secrets/jwt-secretkey
secrets:
- access
- mysql-password
- jwt-secretkey
depends_on:
mysql:
condition: service_healthy
healthcheck:
test: ["CMD", "wget", "--quiet", "--tries=1", "-O", "-", "http://localhost:8989/health"]
interval: 10s
timeout: 5s
retries: 5
start_period: 5s
# LCP Dashboard service
dashboard:
image: llemeur/lcp-dashboard:latest-arm64
expose:
- "8080"
depends_on:
- server
# MySQL database for LCP Server
mysql:
image: mysql:8.4.7
restart: always
environment:
- MYSQL_ROOT_PASSWORD_FILE=/run/secrets/mysql-root-password
- MYSQL_DATABASE=${MYSQL_DATABASE}
- MYSQL_USER=${MYSQL_USER}
- MYSQL_PASSWORD_FILE=/run/secrets/mysql-password
secrets:
- mysql-root-password
- mysql-password
volumes:
- db-data:/var/lib/mysql
ports:
- "3307:3306"
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-p$$(cat /run/secrets/mysql-root-password)"]
interval: 10s
timeout: 5s
retries: 5
start_period: 30s
# Uncomment and adapt if your application is using a PostgreSQL database.
# You must create `db/password.txt` and add a password
# of your choosing to it before running `docker compose up`.
# depends_on:
# db:
# condition: service_healthy
# db:
# image: postgres
# restart: always
# user: postgres
# secrets:
# - db-password
# volumes:
# - db-data:/var/lib/postgresql/data
# environment:
# - POSTGRES_DB=example
# - POSTGRES_PASSWORD_FILE=/run/secrets/db-password
# expose:
# - 5432
# healthcheck:
# test: [ "CMD", "pg_isready" ]
# interval: 10s
# timeout: 5s
# retries: 5
#
# Hot backup service - minimal service impact (run with: docker compose --profile backup run --rm hot-backup)
hot-backup:
image: mysql:8.4.7
restart: "no"
profiles:
- backup
environment:
- MYSQL_ROOT_PASSWORD_FILE=/run/secrets/mysql-root-password
volumes:
- ./backups:/backup
- db-data:/var/lib/mysql:ro
secrets:
- mysql-root-password
command: >
bash -c "
mkdir -p /backup &&
BACKUP_FILE=/backup/hot_backup_$$(date +%Y%m%d_%H%M%S).sql.gz &&
echo 'Creating HOT MySQL dump (service remains available)...' &&
mysqldump -h mysql -u root -p$$(cat /run/secrets/mysql-root-password) --single-transaction --quick --lock-tables=false --no-autocommit --routines --triggers --events --complete-insert --extended-insert=false --set-gtid-purged=OFF --default-character-set=utf8mb4 --hex-blob --order-by-primary lcpserver | gzip > \$$BACKUP_FILE &&
echo 'Cleaning old backups...' &&
find /backup -name 'hot_backup_*.sql.gz' -mtime +30 -delete &&
echo 'HOT backup completed: '\$$BACKUP_FILE &&
echo 'Service impact: MINIMAL - Service remained available' &&
ls -lah /backup/hot_backup_*.sql.gz 2>/dev/null | tail -3 || true
"
depends_on:
mysql:
condition: service_healthy
# Cold backup service (run with: docker compose --profile backup run --rm cold-backup)
cold-backup:
image: mysql:8.4.7
restart: "no"
profiles:
- backup
environment:
- MYSQL_ROOT_PASSWORD_FILE=/run/secrets/mysql-root-password
volumes:
- ./backups:/backup
- db-data:/var/lib/mysql:ro
secrets:
- mysql-root-password
command: >
bash -c "
mkdir -p /backup &&
BACKUP_FILE=/backup/cold_backup_$$(date +%Y%m%d_%H%M%S).sql &&
echo 'Creating COLD MySQL dump...' &&
mysqldump -h mysql -u root -p$$(cat /run/secrets/mysql-root-password) --single-transaction --routines --triggers --events --complete-insert --extended-insert --set-gtid-purged=OFF --source-data=2 --default-character-set=utf8mb4 --hex-blob --order-by-primary lcpserver > \$$BACKUP_FILE &&
echo 'Compressing backup...' &&
gzip \$$BACKUP_FILE &&
echo 'Cleaning old backups...' &&
find /backup -name 'cold_backup_*.sql.gz' -mtime +30 -delete &&
echo 'Backup completed: '\$$BACKUP_FILE.gz &&
ls -lah /backup/cold_backup_*.sql.gz 2>/dev/null | tail -5 || true
"
depends_on:
mysql:
condition: service_healthy
volumes:
db-data:
resources:
input:
secrets:
access:
file: config/access.txt
mysql-root-password:
file: config/mysql-root-password.txt
mysql-password:
file: config/mysql-password.txt
jwt-secretkey:
file: config/jwt-secretkey.txt