Browse Source

more docker config tuning

Christian Winther 1 year ago
parent
commit
ead7c33275
2 changed files with 37 additions and 7 deletions
  1. 30 0
      .env.docker
  2. 7 7
      docker-compose.yml

+ 30 - 0
.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"

+ 7 - 7
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