From 36976d8fe7fd5845216562cc2221ccf6634b6cf3 Mon Sep 17 00:00:00 2001 From: Hugo Sales Date: Mon, 20 Dec 2021 20:39:54 +0000 Subject: [PATCH] [DOCKER] Update configuration script to include the worker container --- bin/configure | 4 +- docker-compose.yaml.default | 65 ++++++++++-------------- docker/php/docker-compose.fragment.sh | 2 +- docker/worker/docker-compose.fragment.sh | 40 +++++++++++++++ docker/{social => worker}/worker.sh | 0 5 files changed, 72 insertions(+), 39 deletions(-) create mode 100644 docker/worker/docker-compose.fragment.sh rename docker/{social => worker}/worker.sh (100%) diff --git a/bin/configure b/bin/configure index 8dfe527ec6..bcf68e23c8 100755 --- a/bin/configure +++ b/bin/configure @@ -47,7 +47,7 @@ Choose whether you prefer social to handle all the services it needs though dock 3>&1 1>&2 2>&3) validate_exit $? case ${SERVICES} in - 'docker') DOCKER='"nginx" "certbot" "php" "db" "redis"' ;; # TODO enable and configure "mail" + 'docker') DOCKER='"nginx" "certbot" "php" "db" "redis" "worker"' ;; # TODO enable and configure "mail" 'mixed') DOCKER=$(${WHIPTAIL} --title 'GNU social Docker services' --clear --backtitle 'GNU social' \ --checklist "\nPick which of the following services you'd like to add to docker-compose.\n* indicates a service that has extra configuration" 0 0 0 \ @@ -57,6 +57,7 @@ case ${SERVICES} in db 'Configure a DBMS*' on \ redis 'Configure Redis (optional, recommended)' on \ mail 'Confugure a mail server*' on \ + worker 'Confugure container with worker queues' on \ 3>&1 1>&2 2>&3) validate_exit $? ;; @@ -141,6 +142,7 @@ fi if echo "${DOCKER}" | grep -Fq '"php"'; then ${WHIPTAIL} --title "Build PHP container locally?" --clear --backtitle 'GNU social' \ --yesno "\nDo you want to compile the needed PHP extensions and build the container locally? (May provide better performance but requires more than 1GiB of RAM)" 0 0 \ + --defaultno \ 3>&1 1>&2 2>&3 BUILD_PHP=$((1-$?)) # Invert output fi diff --git a/docker-compose.yaml.default b/docker-compose.yaml.default index 31785c1d07..a3e627024f 100644 --- a/docker-compose.yaml.default +++ b/docker-compose.yaml.default @@ -17,7 +17,7 @@ services: # Certbot - ./docker/certbot/www:/var/www/certbot - ./docker/certbot/.files:/etc/letsencrypt - # Social + # social - ./public:/var/www/social/public env_file: - ./docker/bootstrap/bootstrap.env @@ -43,7 +43,7 @@ services: - ./docker/certbot/.files:/etc/letsencrypt php: - build: docker/php + image: gsocial/php restart: always tty: true ports: @@ -55,25 +55,7 @@ services: - ./docker/social/install.sh:/var/entrypoint.d/social_install.sh # Main files - .:/var/www/social - - /var/www/social/docker # don't map docker folder - env_file: - - ./docker/social/social.env - - ./docker/db/db.env - command: /entrypoint.sh - - worker: - build: docker/php - restart: always - tty: true - volumes: - # Entrypoint - - ./docker/php/entrypoint.sh:/entrypoint.sh - - ./docker/db/wait_for_db.sh:/wait_for_db.sh - - ./docker/social/install.sh:/var/entrypoint.d/10_social_install.sh - - ./docker/social/worker.sh:/var/entrypoint.d/20_social_worker.sh - # Main files - - .:/var/www/social - - /var/www/social/docker # don't map docker folder + - /var/www/social/docker # exclude docker folder env_file: - ./docker/social/social.env - ./docker/db/db.env @@ -84,32 +66,41 @@ services: restart: always tty: false ports: - - 3306:3306 + - 5432:5432 + environment: + - PGDATA=/var/lib/postgres/data env_file: - ./docker/db/db.env + volumes: + - database:/var/lib/postgres/data redis: image: redis:alpine restart: always tty: false + volumes: + - ./docker/redis/redis.conf:/etc/redis/redis.conf ports: - 6379:6379 + command: redis-server /etc/redis/redis.conf - mail: - build: docker/mail - env_file: - - ./docker/mail/mail.env - ports: - - 25:25 - - 110:110 - - 143:143 - - 587:587 - - 993:993 + worker: + image: gsocial/php + restart: always + tty: true volumes: - - ./docker/mail/mail:/var/mail - - ./docker/mail/config:/etc/mail - # Certbot - - ./docker/certbot/www:/var/www/certbot - - ./docker/certbot/.files:/etc/letsencrypt + # Entrypoint + - ./docker/php/entrypoint.sh:/entrypoint.sh + - ./docker/db/wait_for_db.sh:/wait_for_db.sh + - ./docker/social/install.sh:/var/entrypoint.d/social_install.sh + - ./docker/social/worker.sh:/var/entrypoint.d/social_worker.sh + # Main files + - .:/var/www/social + - /var/www/social/docker # exclude docker folder + env_file: + - ./docker/social/social.env + - ./docker/db/db.env + command: /entrypoint.sh + volumes: database: diff --git a/docker/php/docker-compose.fragment.sh b/docker/php/docker-compose.fragment.sh index 77f4f48073..4c57e9e55c 100644 --- a/docker/php/docker-compose.fragment.sh +++ b/docker/php/docker-compose.fragment.sh @@ -1,6 +1,6 @@ #!/usr/bin/sh -if [ "${LE_CERT}" -ne 0 ]; then +if [ "${BUILD_PHP}" -ne 0 ]; then cat <