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