From ead7c33275d8a85b675a8ecd5cfdf898099faaa4 Mon Sep 17 00:00:00 2001 From: Christian Winther Date: Wed, 17 Jan 2024 16:11:36 +0000 Subject: [PATCH] more docker config tuning --- .env.docker | 30 ++++++++++++++++++++++++++++++ docker-compose.yml | 14 +++++++------- 2 files changed, 37 insertions(+), 7 deletions(-) diff --git a/.env.docker b/.env.docker index fe6c19d4b..9c440d37e 100644 --- a/.env.docker +++ b/.env.docker @@ -260,6 +260,11 @@ LETSENCRYPT_EMAIL="__CHANGE_ME__" # Database configuration ################################################################################ +# Database version to use (as Docker tag) +# +# See: https://hub.docker.com/_/mariadb +#DB_VERSION="11.2" + # Here you may specify which of the database connections below # you wish to use as your default connection for all database work. # @@ -376,6 +381,11 @@ MAIL_FROM_NAME="Pixelfed @ ${APP_DOMAIN}" # Redis configuration ################################################################################ +# Redis version to use as Docker tag +# +# See: https://hub.docker.com/_/redis +#REDIS_VERSION="7.2" + # Defaults to "phpredis". # # See: https://docs.pixelfed.org/technical-documentation/config/#redis_client @@ -992,6 +1002,11 @@ DOCKER_APP_STORAGE_PATH="${DOCKER_DATA_ROOT}/pixelfed/storage" # Path is relative (./some/other/path) to the docker-compose.yml or absolute (/some/other/path) DOCKER_APP_CACHE_PATH="${DOCKER_DATA_ROOT}/pixelfed/cache" +# How often Docker health check should run for all services +# +# Can be overridden by individual [DOCKER_*_HEALTHCHECK_INTERVAL] settings further down +DOCKER_DEFAULT_HEALTHCHECK_INTERVAL="10s" + # Port that Redis will listen on *outside* the container (e.g. the host machine) DOCKER_REDIS_PORT_EXTERNAL="${REDIS_PORT:-6379}" @@ -1004,11 +1019,17 @@ DOCKER_REDIS_PORT_EXTERNAL="${REDIS_PORT:-6379}" # Defaults to "" #DOCKER_REDIS_CONFIG_FILE="/etc/redis/redis.conf" +# How often Docker health check should run for [redis] service +DOCKER_REDIS_HEALTHCHECK_INTERVAL="${DOCKER_DEFAULT_HEALTHCHECK_INTERVAL}" + # Port that the database will listen on *outside* the container (e.g. the host machine) # # Use "3306" for MySQL/MariaDB and "5432" for PostgreeSQL DOCKER_DB_PORT_EXTERNAL="${DB_PORT}" +# How often Docker health check should run for [db] service +DOCKER_DB_HEALTHCHECK_INTERVAL="${DOCKER_DEFAULT_HEALTHCHECK_INTERVAL}" + # Port that the [proxy] will listen on *outside* the container (e.g. the host machine) for HTTP traffic DOCKER_PROXY_PORT_EXTERNAL_HTTP="80" @@ -1018,6 +1039,12 @@ DOCKER_PROXY_PORT_EXTERNAL_HTTPS="443" # Port to expose [web] container will listen on *outside* the container (e.g. the host machine) for *HTTP* traffic only DOCKER_WEB_PORT_EXTERNAL_HTTP="8080" +# How often Docker health check should run for [web] service +DOCKER_WEB_HEALTHCHECK_INTERVAL="${DOCKER_DEFAULT_HEALTHCHECK_INTERVAL}" + +# How often Docker health check should run for [worker] service +DOCKER_WORKER_HEALTHCHECK_INTERVAL="${DOCKER_DEFAULT_HEALTHCHECK_INTERVAL}" + # Path to the Docker socket on the *host* DOCKER_HOST_SOCKET_PATH="/var/run/docker.sock" @@ -1030,6 +1057,9 @@ DOCKER_PROXY_PROFILE="" # Set this to a non-empty value (e.g. "disabled") to disable the [proxy-acme] service DOCKER_PROXY_ACME_PROFILE="${DOCKER_PROXY_PROFILE}" +# How often Docker health check should run for [proxy] service +DOCKER_PROXY_HEALTHCHECK_INTERVAL="${DOCKER_DEFAULT_HEALTHCHECK_INTERVAL}" + # Automatically run "One-time setup tasks" commands. # # If you are migrating to this docker-compose setup or have manually run the "One time seutp" diff --git a/docker-compose.yml b/docker-compose.yml index b2a8aa806..4d5d6ac64 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -35,7 +35,7 @@ services: - "${DOCKER_PROXY_PORT_EXTERNAL_HTTPS}:443" healthcheck: test: "curl --fail https://$[APP_DOMAIN}/api/service/health-check" - interval: 10s + interval: "${DOCKER_PROXY_HEALTHCHECK_INTERVAL:-10s}" retries: 2 timeout: 5s @@ -99,7 +99,7 @@ services: - redis healthcheck: test: 'curl --header "Host: $[APP_DOMAIN}" --fail http://localhost/api/service/health-check' - interval: 10s + interval: "${DOCKER_WEB_HEALTHCHECK_INTERVAL:-10s}" retries: 2 timeout: 5s @@ -126,12 +126,12 @@ services: - redis healthcheck: test: gosu www-data php artisan horizon:status | grep running - interval: 10s + interval: "${DOCKER_WORKER_HEALTHCHECK_INTERVAL}" timeout: 5s retries: 2 db: - image: mariadb:11.2 + image: mariadb:${DB_VERSION:-11.2} container_name: "${DOCKER_CONTAINER_NAME_PREFIX}-db" command: --default-authentication-plugin=mysql_native_password restart: unless-stopped @@ -150,12 +150,12 @@ services: "--connect", "--innodb_initialized", ] - interval: 10s + interval: "${DOCKER_DB_HEALTHCHECK_INTERVAL:-10s}" retries: 2 timeout: 5s redis: - image: redis:7.2 + image: redis:${REDIS_VERSION:-7.2} container_name: "${DOCKER_CONTAINER_NAME_PREFIX}-redis" restart: unless-stopped command: "${DOCKER_REDIS_CONFIG_FILE:-} --requirepass '${REDIS_PASSWORD:-}'" @@ -170,6 +170,6 @@ services: - "${DOCKER_REDIS_PORT_EXTERNAL}:6379" healthcheck: test: ["CMD", "redis-cli", "-p", "6379", "ping"] - interval: 10s + interval: "${DOCKER_REDIS_HEALTHCHECK_INTERVAL}" retries: 2 timeout: 5s