[DOCKER] Update configuration script to include the worker container

This commit is contained in:
Hugo Sales 2021-12-20 20:39:54 +00:00
parent e27f2dd202
commit 36976d8fe7
Signed by untrusted user: someonewithpc
GPG Key ID: 7D0C7EAFC9D835A0
5 changed files with 72 additions and 39 deletions

4
bin/configure vendored
View File

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

View File

@ -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:

View File

@ -1,6 +1,6 @@
#!/usr/bin/sh
if [ "${LE_CERT}" -ne 0 ]; then
if [ "${BUILD_PHP}" -ne 0 ]; then
cat <<EOF
php:
build: docker/php

View File

@ -0,0 +1,40 @@
#!/usr/bin/sh
if [ "${BUILD_PHP}" -ne 0 ]; then
cat <<EOF
worker:
build: docker/php
EOF
else
cat <<EOF
worker:
image: gsocial/php
EOF
fi
# If the user wants a DB docker container
if echo "${DOCKER}" | grep -Fvq '"db"'; then
cat <<EOF
depends_on:
- db
EOF
fi
cat <<EOF
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/social_install.sh
- ./docker/worker/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
EOF