[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
No known key found for this signature in database
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) 3>&1 1>&2 2>&3)
validate_exit $? validate_exit $?
case ${SERVICES} in 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') 'mixed')
DOCKER=$(${WHIPTAIL} --title 'GNU social Docker services' --clear --backtitle 'GNU social' \ 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 \ --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 \ db 'Configure a DBMS*' on \
redis 'Configure Redis (optional, recommended)' on \ redis 'Configure Redis (optional, recommended)' on \
mail 'Confugure a mail server*' on \ mail 'Confugure a mail server*' on \
worker 'Confugure container with worker queues' on \
3>&1 1>&2 2>&3) 3>&1 1>&2 2>&3)
validate_exit $? validate_exit $?
;; ;;
@ -141,6 +142,7 @@ fi
if echo "${DOCKER}" | grep -Fq '"php"'; then if echo "${DOCKER}" | grep -Fq '"php"'; then
${WHIPTAIL} --title "Build PHP container locally?" --clear --backtitle 'GNU social' \ ${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 \ --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 3>&1 1>&2 2>&3
BUILD_PHP=$((1-$?)) # Invert output BUILD_PHP=$((1-$?)) # Invert output
fi fi

View File

@ -17,7 +17,7 @@ services:
# Certbot # Certbot
- ./docker/certbot/www:/var/www/certbot - ./docker/certbot/www:/var/www/certbot
- ./docker/certbot/.files:/etc/letsencrypt - ./docker/certbot/.files:/etc/letsencrypt
# Social # social
- ./public:/var/www/social/public - ./public:/var/www/social/public
env_file: env_file:
- ./docker/bootstrap/bootstrap.env - ./docker/bootstrap/bootstrap.env
@ -43,7 +43,7 @@ services:
- ./docker/certbot/.files:/etc/letsencrypt - ./docker/certbot/.files:/etc/letsencrypt
php: php:
build: docker/php image: gsocial/php
restart: always restart: always
tty: true tty: true
ports: ports:
@ -55,25 +55,7 @@ services:
- ./docker/social/install.sh:/var/entrypoint.d/social_install.sh - ./docker/social/install.sh:/var/entrypoint.d/social_install.sh
# Main files # Main files
- .:/var/www/social - .:/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
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
env_file: env_file:
- ./docker/social/social.env - ./docker/social/social.env
- ./docker/db/db.env - ./docker/db/db.env
@ -84,32 +66,41 @@ services:
restart: always restart: always
tty: false tty: false
ports: ports:
- 3306:3306 - 5432:5432
environment:
- PGDATA=/var/lib/postgres/data
env_file: env_file:
- ./docker/db/db.env - ./docker/db/db.env
volumes:
- database:/var/lib/postgres/data
redis: redis:
image: redis:alpine image: redis:alpine
restart: always restart: always
tty: false tty: false
volumes:
- ./docker/redis/redis.conf:/etc/redis/redis.conf
ports: ports:
- 6379:6379 - 6379:6379
command: redis-server /etc/redis/redis.conf
mail: worker:
build: docker/mail image: gsocial/php
env_file: restart: always
- ./docker/mail/mail.env tty: true
ports:
- 25:25
- 110:110
- 143:143
- 587:587
- 993:993
volumes: volumes:
- ./docker/mail/mail:/var/mail # Entrypoint
- ./docker/mail/config:/etc/mail - ./docker/php/entrypoint.sh:/entrypoint.sh
# Certbot - ./docker/db/wait_for_db.sh:/wait_for_db.sh
- ./docker/certbot/www:/var/www/certbot - ./docker/social/install.sh:/var/entrypoint.d/social_install.sh
- ./docker/certbot/.files:/etc/letsencrypt - ./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: volumes:
database: database:

View File

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