...
Codeblock |
---|
language | yml |
---|
title | docker-compose.yml (Auszug) |
---|
|
database:
image: mariadb:10.11
volumes:
- db_data:/var/lib/mysql
- ./mariadb/conf:/etc/mysql/conf.d
env_file:
- brandbox.docker.env
environment:
MYSQL_HOST: database.${COMPOSE_PROJECT_NAME}
entrypoint: /etc/mysql/conf.d/entrypoint.sh # >> Custom-Entrypoint definieren
labels:
traefik.enable: "false"
healthcheck:
test: ["CMD", "mysql", "-u", "root", "-proot", "-e", "SELECT version();"]
interval: 1m
timeout: 10s
retries: 3
ports:
- "3306"
cpus: 0.75
mem_limit: 1000M
networks:
internal:
aliases:
- database.${COMPOSE_PROJECT_NAME} |
Die Datei entrypoint.sh muss dazu im definierten Bind-Mount-Ordner abgelegt werden (mariadb/conf) und wie folgt aussehen:
Codeblock |
---|
|
#!/usr/bin/env bash
set -euo pipefail
##
# This script exists to work-around the fact that
# mysql does not support logging to stdout
#
# This will tail the file logs configured in ./my.cnf
##
LOG_PATHS=(
'/var/log/mysql/slow.log'
'/var/log/mysql/query.log'
)
for LOG_PATH in "${LOG_PATHS[@]}"; do
( umask 0 && truncate -s0 "$LOG_PATH" )
tail --pid $$ -n0 -F "$LOG_PATH" &
done
/usr/local/bin/docker-entrypoint.sh mariadbd |
Cluster-Konfiguration (Kubernetes)