diff --git a/docker-compose.template.yml b/docker-compose.template.yml index 57e489c..e7d1e46 100644 --- a/docker-compose.template.yml +++ b/docker-compose.template.yml @@ -40,7 +40,7 @@ services: wordpress_${SERVICE_SUFFIX}: image: ${IMAGE_WEB:-wordpress} - container_name: ${COMPOSE_PROJECT_NAME}_wordpress + container_name: ${COMPOSE_PROJECT_NAME}_wordpress volumes: - html:/var/www/html - content:/var/www/html/wp-content @@ -54,7 +54,7 @@ services: - VIRTUAL_HOST=${VIRTUAL_HOST:-wordpress} - LETSENCRYPT_HOST=${LETSENCRYPT_HOST:-wordpress} - LETSENCRYPT_EMAIL=${LETSENCRYPT_EMAIL:-me} - - LETSENCRYPT_TEST=${LETSENCRYPT_TEST:-true} + - LETSENCRYPT_TEST=${LETSENCRYPT_TEST:-true} logging: driver: "json-file" options: @@ -88,7 +88,28 @@ services: - LETSENCRYPT_TEST=${LETSENCRYPT_TEST:-true} networks: - custom_network - - letsencrypt + - letsencrypt + + wpcli_${SERVICE_SUFFIX}: + image: wordpress:cli + container_name: ${COMPOSE_PROJECT_NAME}_wpcli + depends_on: + - database_${SERVICE_SUFFIX} + - wordpress_${SERVICE_SUFFIX} + command: tail -f /dev/null # Keeps the container running for CLI commands + volumes: + - html:/var/www/html + - content:/var/www/html/wp-content + - ./wp-config.php:/var/www/html/wp-config.php + user: "33:${HOST_GID}" + environment: + - WORDPRESS_DB_HOST=database_${COMPOSE_PROJECT_NAME}:3306 + - WORDPRESS_DB_PASSWORD=${WORDPRESS_DB_PASSWORD:-fake} + - MYSQL_DATABASE=${MYSQL_DATABASE:-wordpress} + - MYSQL_USER=${MYSQL_USER:-wordpress} + - TABLE_PREFIX=${TABLE_PREFIX:-wp_} + networks: + - custom_network # No variable substition for volumes in this version volumes: diff --git a/generate-compose-nginx.sh b/generate-compose-nginx.sh index be69307..c598df5 100755 --- a/generate-compose-nginx.sh +++ b/generate-compose-nginx.sh @@ -11,10 +11,13 @@ # Load variables from .env file if [ -f .env ]; then source .env + chmod 0664 wp-config.php fi export SERVICE_SUFFIX=${COMPOSE_PROJECT_NAME:-main} export COMPOSE_PROJECT_NAME +export HOST_UID=$(id -u) +export HOST_GID=$(id -g) envsubst < docker-compose.template.yml > docker-compose.yml # Define the new value for the database host