add mariadb support

This commit is contained in:
knoflook 2024-06-20 15:36:08 +02:00
parent 96faa55289
commit 9ab54dbf8d
4 changed files with 81 additions and 3 deletions

View File

@ -5,4 +5,7 @@ DOMAIN=uptime-kuma.example.com
## Domain aliases
#EXTRA_DOMAINS=', `www.uptime-kuma.example.com`'
SECRET_DB_PASSWORD_VERSION=v1
SECRET_DB_ROOT_PASSWORD_VERSION=v1
LETS_ENCRYPT_ENV=production

1
abra.sh Normal file
View File

@ -0,0 +1 @@
export APP_ENTRYPOINT_VERSION=v1

View File

@ -3,12 +3,25 @@ version: "3.8"
services:
app:
image: louislam/uptime-kuma:1.23.11-alpine
image: louislam/uptime-kuma:1.23.11
volumes:
- data:/app/data
- db:/app/db
networks:
- internal
- proxy
environment:
- UPTIME_KUMA_GH_REPO=louislam:uptime-kuma
- UPTIME_KUMA_DB_TYPE=mariadb
- UPTIME_KUMA_DB_HOSTNAME=db
- UPTIME_KUMA_DB_PORT=3306
- UPTIME_KUMA_DB_NAME=kuma
- UPTIME_KUMA_DB_USERNAME=kuma
- UPTIME_KUMA_DB_PASSWORD_FILE=/run/secrets/db_password
configs:
- source: app_entrypoint
target: /docker-entrypoint.sh
mode: 0555
entrypoint: /docker-entrypoint.sh
deploy:
update_config:
failure_action: rollback
@ -30,11 +43,40 @@ services:
timeout: 10s
retries: 5
start_period: 2m
db:
image: mariadb:10.8
environment:
- MYSQL_ROOT_PASSWORD_FILE=/run/secrets/db_root_password
- MYSQL_PASSWORD_FILE=/run/secrets/db_password
- MYSQL_USER=kuma
- MYSQL_DATABASE=kuma
volumes:
- mariadb:/var/lib/mysql
networks:
- internal
secrets:
- db_password
- db_root_password
volumes:
mariadb:
data:
db:
networks:
proxy:
external: true
internal:
secrets:
db_password:
external: true
name: ${STACK_NAME}_db_password_${DB_PASSWORD_VERSION}
db_root_password:
external: true
name: ${STACK_NAME}_db_root_password_${DB_ROOT_PASSWORD_VERSION}
configs:
app_entrypoint:
name: ${STACK_NAME}_app_entrypoint_${APP_ENTRYPOINT_VERSION}
file: entrypoint.sh.tmpl
template_driver: golang

32
entrypoint.sh.tmpl Normal file
View File

@ -0,0 +1,32 @@
#!/bin/bash
set -e
file_env() {
local var="$1"
local fileVar="${var}_FILE"
local def="${2:-}"
if [ "${!var:-}" ] && [ "${!fileVar:-}" ]; then
echo >&2 "error: both $var and $fileVar are set (but are exclusive)"
exit 1
fi
local val="$def"
if [ "${!var:-}" ]; then
val="${!var}"
elif [ "${!fileVar:-}" ]; then
val="$(< "${!fileVar}")"
fi
export "$var"="$val"
unset "$fileVar"
}
file_env "UPTIME_KUMA_DB_PASSWORD"
# upstream startup command
cd /app
node server/server.js