Merge branch 'docker-optimizations' into 'v4.x'

Docker Healthchecks, loosen redis, NPM sqlite

See merge request allianceauth/allianceauth!1561
This commit is contained in:
Ariel Rin 2023-12-02 01:37:38 +00:00
commit 7eebf4d953
2 changed files with 77 additions and 27 deletions

View File

@ -0,0 +1,10 @@
#!/bin/bash
set -eo pipefail
host="$(hostname -i || echo '127.0.0.1')"
if ping="$(redis-cli -h "$host" ping)" && [ "$ping" = 'PONG' ]; then
exit 0
fi
exit 1

View File

@ -22,6 +22,11 @@ x-allianceauth-base: &allianceauth-base
- auth_mysql
working_dir: /home/allianceauth/myauth/
stop_grace_period: 10m
logging:
driver: "json-file"
options:
max-size: "50Mb"
max-file: "5"
x-allianceauth-health-check: &allianceauth-health-checks
healthcheck:
@ -46,12 +51,15 @@ services:
- ./setup.sql:/docker-entrypoint-initdb.d/setup.sql
environment:
- MYSQL_ROOT_PASSWORD=${AA_DB_ROOT_PASSWORD?err}
- MARIADB_MYSQL_LOCALHOST_USER=1
healthcheck:
test: ["CMD", "mysqladmin", "-uroot", "-proot", "-h", "localhost", "ping"]
interval: 5s
timeout: 10s
retries: 3
test: ["CMD", "healthcheck.sh", "--su=mysql", "--connect", "--innodb_initialized"]
restart: unless-stopped
logging:
driver: "json-file"
options:
max-size: "10Mb"
max-file: "5"
nginx:
image: nginx:1.25
@ -61,13 +69,26 @@ services:
- static-volume:/var/www/myauth/static
depends_on:
- allianceauth_gunicorn
logging:
driver: "json-file"
options:
max-size: "10Mb"
max-file: "5"
redis:
image: redis:7.0
image: redis:7
command: redis-server
restart: always
volumes:
- "redis-data:/data"
- ./conf/redis_healthcheck.sh:/usr/local/bin/redis_healthcheck.sh
healthcheck:
test: ["CMD", "bash", "/usr/local/bin/redis_healthcheck.sh"]
logging:
driver: "json-file"
options:
max-size: "10Mb"
max-file: "5"
allianceauth_gunicorn:
ports:
@ -122,36 +143,55 @@ services:
environment:
GF_INSTALL_PLUGINS: grafana-piechart-panel,grafana-clock-panel,grafana-simple-json-datasource
GF_AUTH_DATABASE_PASSWORD: ${GRAFANA_DB_PASSWORD}
logging:
driver: "json-file"
options:
max-size: "10Mb"
max-file: "5"
proxy:
image: 'jc21/nginx-proxy-manager:latest'
image: jc21/nginx-proxy-manager:latest
restart: always
ports:
- '${PROXY_HTTP_PORT:-80}:80'
- '${PROXY_DASH_PORT:-81}:81'
- '${PROXY_HTTPS_PORT:-443}:443'
environment:
DB_MYSQL_HOST: "proxy-db"
DB_MYSQL_PORT: 3306
DB_MYSQL_USER: "npm"
DB_MYSQL_PASSWORD: "${PROXY_MYSQL_PASS?err}"
DB_MYSQL_NAME: "npm"
- ${PROXY_HTTP_PORT:-80}:80
- ${PROXY_DASH_PORT:-81}:81
- ${PROXY_HTTPS_PORT:-443}:443
# Uncomment this section to use a dedicated database for Nginx Proxy Manager
# environment:
# DB_MYSQL_HOST: "proxy-db"
# DB_MYSQL_PORT: 3306
# DB_MYSQL_USER: "npm"
# DB_MYSQL_PASSWORD: "${PROXY_MYSQL_PASS?err}"
# DB_MYSQL_NAME: "npm"
volumes:
- proxy-data:/data
- proxy-le:/etc/letsencrypt
healthcheck:
test: ["CMD", "/bin/check-health"]
logging:
driver: "json-file"
options:
max-size: "10Mb"
max-file: "5"
proxy-db:
image: 'jc21/mariadb-aria:latest'
restart: always
environment:
MYSQL_ROOT_PASSWORD: "${PROXY_MYSQL_PASS_ROOT?err}"
MYSQL_DATABASE: 'npm'
MYSQL_USER: 'npm'
MYSQL_PASSWORD: "${PROXY_MYSQL_PASS?err}"
ports:
- 3306
volumes:
- proxy-db:/var/lib/mysql
# Uncomment this section to use a dedicated database for Nginx Proxy Manager
# proxy-db:
# image: 'jc21/mariadb-aria:latest'
# restart: always
# environment:
# MYSQL_ROOT_PASSWORD: "${PROXY_MYSQL_PASS_ROOT?err}"
# MYSQL_DATABASE: 'npm'
# MYSQL_USER: 'npm'
# MYSQL_PASSWORD: "${PROXY_MYSQL_PASS?err}"
# ports:
# - 3306
# volumes:
# - proxy-db:/var/lib/mysql
# logging:
# driver: "json-file"
# options:
# max-size: "1Mb"
# max-file: "5"
volumes:
redis-data: