-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompose.yml
More file actions
141 lines (134 loc) · 4.59 KB
/
Copy pathcompose.yml
File metadata and controls
141 lines (134 loc) · 4.59 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
# SPDX-License-Identifier: MIT
# Copyright (c) 2026 Netresearch DTT GmbH
#
# The whole stack: phpMyAdmin on php-fpm, nginx in front, and a MariaDB to
# point it at. Consumers who already run a database — the usual case, this is
# an admin UI for something that exists — start only what they need:
#
# docker compose up -d app-assets app web
#
# Less than that is fine too: the `app` image works on its own for anyone who
# already runs a web server, which is how the netresearch.de stack uses it.
name: phpmyadmin
x-logging: &default-logging
driver: json-file
options:
max-size: "10m"
max-file: "3"
services:
app:
image: ghcr.io/netresearch/phpmyadmin-php-fpm:${PMA_IMAGE_TAG:-latest}
build:
context: .
args:
PHP_VERSION: ${PHP_VERSION:-8.4}
PMA_VERSION: ${PMA_VERSION:-5.2.3}
logging: *default-logging
environment:
PMA_HOST: ${PMA_HOST:-db}
PMA_PORT: ${PMA_PORT:-3306}
# Keeps sessions alive across restarts. Generate once:
# tr -dc 'A-Za-z0-9' </dev/urandom | head -c 32
PMA_BLOWFISH_SECRET: ${PMA_BLOWFISH_SECRET:-}
PMA_ABSOLUTE_URI: ${PMA_ABSOLUTE_URI:-}
UPLOAD_LIMIT: ${UPLOAD_LIMIT:-256M}
MEMORY_LIMIT: ${MEMORY_LIMIT:-512M}
MAX_EXECUTION_TIME: ${MAX_EXECUTION_TIME:-600}
volumes:
# phpMyAdmin's scratch space, and where a generated blowfish secret is
# kept so it survives a restart. php-fpm reads the application code from
# its own image layer, so nothing else needs to be shared with it.
- pma-tmp:/var/www/html/tmp
restart: unless-stopped
security_opt:
- no-new-privileges:true
deploy:
resources:
limits:
memory: 512M
# nginx serves phpMyAdmin's static files itself instead of routing every
# asset through php-fpm, so it needs the same tree. Copying it on every
# start — rather than letting Docker seed an empty volume once — is what
# makes an image upgrade actually reach nginx: a volume seeded at creation
# would keep serving the old release forever.
app-assets:
image: ghcr.io/netresearch/phpmyadmin-php-fpm:${PMA_IMAGE_TAG:-latest}
logging: *default-logging
entrypoint: ["/bin/bash", "-c"]
command:
- |
set -eu
STAGE=/shared-html/.new
rm -rf "$$STAGE"; mkdir -p "$$STAGE"
# tmp/ is the app's own writable volume and must not be copied.
find /var/www/html -mindepth 1 -maxdepth 1 ! -name tmp \
-exec cp -a {} "$$STAGE"/ \;
# Swap entry by entry: mv within one mount is rename(2), so a request
# arriving mid-sync sees either the old or the new file, never half.
for entry in "$$STAGE"/* "$$STAGE"/.[!.]*; do
[ -e "$$entry" ] || continue
name=$$(basename "$$entry")
rm -rf "/shared-html/$$name"
mv "$$entry" "/shared-html/$$name"
done
rm -rf "$$STAGE"
echo "[app-assets] synced $$(ls /shared-html | wc -l) entries"
volumes:
- pma-html:/shared-html
restart: "no"
security_opt:
- no-new-privileges:true
web:
image: nginx:${NGINX_VERSION:-1.29-alpine}
logging: *default-logging
depends_on:
app-assets:
condition: service_completed_successfully
app:
condition: service_healthy
environment:
PMA_FPM_UPSTREAM: ${PMA_FPM_UPSTREAM:-app:9000}
ports:
- "${PMA_HTTP_PORT:-8080}:8080"
volumes:
- ./config/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
- ./config/nginx/templates:/etc/nginx/templates:ro
- ./config/nginx/snippets:/etc/nginx/snippets:ro
- pma-html:/var/www/html:ro
healthcheck:
test: ["CMD", "wget", "-q", "-O", "/dev/null", "http://127.0.0.1:8080/"]
interval: 30s
timeout: 5s
retries: 3
start_period: 10s
restart: unless-stopped
security_opt:
- no-new-privileges:true
deploy:
resources:
limits:
memory: 128M
# Only for running this stack standalone. Point PMA_HOST at your own
# database and leave this one out.
db:
image: ${DB_IMAGE:-mariadb}:${DB_IMAGE_VERSION:-11.8}
logging: *default-logging
profiles: ["standalone"]
environment:
MARIADB_ROOT_PASSWORD: ${MARIADB_ROOT_PASSWORD:?set MARIADB_ROOT_PASSWORD}
MARIADB_DATABASE: ${MARIADB_DATABASE:-demo}
volumes:
- db-data:/var/lib/mysql
healthcheck:
test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"]
interval: 10s
timeout: 5s
retries: 5
start_period: 30s
restart: unless-stopped
security_opt:
- no-new-privileges:true
volumes:
pma-tmp:
pma-html:
db-data: