diff --git a/.gitignore b/.gitignore index 2109de4..e5ba301 100644 --- a/.gitignore +++ b/.gitignore @@ -9,5 +9,15 @@ # Ignore the environment file with the DB credentials. .env +# Ignore the built config files. +config/containers/Dockerfile + # Don't share individual sites files. -/wordpress/ \ No newline at end of file +/wordpress/* +/plugins/* +/themes/* + +# But do keep some things. +!wordpress/.gitkeep +!plugins/.gitkeep +!themes/.gitkeep \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 183089f..dd9e7a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,16 @@ Changelog formatting (http://semver.org/) ### Project Management --> +## 1.1.1 (2020-07-29) + +### Bug Fixes + +:bug: Fix #1 modify file permissions to give system user access. + +### Enhancements + +- Use environment variable fallback values for when `.env` isn't found. + ## 1.0.0 (2020-07-24) ### Features diff --git a/.env-example b/config/.env-example similarity index 67% rename from .env-example rename to config/.env-example index 735da4e..402c419 100644 --- a/.env-example +++ b/config/.env-example @@ -6,13 +6,13 @@ # 2. Replace the sample credentials with your own. # The name of the database for WordPress -MYSQL_DATABASE=database_name_here +MYSQL_DATABASE= # MySQL database username -MYSQL_USER=username_here +MYSQL_USER= # MySQL database password -MYSQL_PASSWORD=mysql_password_here +MYSQL_PASSWORD= # MySQL root password -MYSQL_ROOT_PASSWORD=mysql_root_password_here \ No newline at end of file +MYSQL_ROOT_PASSWORD= \ No newline at end of file diff --git a/config/containers/Dockerfile.template b/config/containers/Dockerfile.template new file mode 100644 index 0000000..3a3895a --- /dev/null +++ b/config/containers/Dockerfile.template @@ -0,0 +1,4 @@ +FROM wordpress:latest + +RUN usermod -u $UID www-data +RUN groupmod -o -g $GID www-data \ No newline at end of file diff --git a/config/php/php.ini b/config/php/php.ini new file mode 100644 index 0000000..95a08e7 --- /dev/null +++ b/config/php/php.ini @@ -0,0 +1,9 @@ +error_reporting = E_ALL +display_startup_errors = On +display_errors = On + +upload_max_filesize = 100M +post_max_size = 100M + +max_execution_time = 3600 +request_terminate_timeout = 3600 \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 7b3d7ae..8eb53ea 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,29 +2,38 @@ version: "3" services: db: + container_name: db image: mariadb:10.5 volumes: - - db_data:/var/lib/mysql - restart: unless-stopped + - "db_data:/var/lib/mysql" + restart: always env_file: .env + environment: + MYSQL_DATABASE: ${MYSQL_DATABASE:-wordpress} + MYSQL_USER: ${MYSQL_USER:-root} + MYSQL_PASSWORD: ${MYSQL_PASSWORD:-password} + MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-root} wordpress: + container_name: wordpress depends_on: - db - image: wordpress:latest + build: "./config/containers" ports: - "8000:80" - restart: unless-stopped + restart: always env_file: .env environment: WORDPRESS_DB_HOST: db:3306 - WORDPRESS_DB_USER: $MYSQL_USER - WORDPRESS_DB_PASSWORD: $MYSQL_PASSWORD - WORDPRESS_DB_NAME: $MYSQL_DATABASE + WORDPRESS_DB_USER: ${MYSQL_USER:-root} + WORDPRESS_DB_PASSWORD: ${MYSQL_PASSWORD:-password} + WORDPRESS_DB_NAME: ${MYSQL_DATABASE:-wordpress} WORDPRESS_DEBUG: "true" volumes: - - ./wordpress:/var/www/html/ - - ./uploads.ini:/usr/local/etc/php/conf.d/uploads.ini + - "./wordpress:/var/www/html/" + - "./plugins:/var/www/html/wp-content/plugins" + - "./themes:/var/www/html/wp-content/themes" + - "./config/php/php.ini:/usr/local/etc/php/conf.d/custom.ini" volumes: db_data: {} diff --git a/plugins/.gitkeep b/plugins/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/start.sh b/start.sh new file mode 100755 index 0000000..4d3ab33 --- /dev/null +++ b/start.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +USER_ID=`id -u` +GROUP_ID=`id -g` + +if [ ! -f './config/containers/Dockerfile' ]; then + cp './config/containers/Dockerfile.template' './config/containers/Dockerfile' + sed -i '' -e "s/\$UID/${USER_ID}/g" './config/containers/Dockerfile' + sed -i '' -e "s/\$GID/${GROUP_ID}/g" './config/containers/Dockerfile' +fi + +if [ ! -f './.env' ]; then + cp './config/.env-example' './.env' +fi + +docker-compose up --detach + +docker exec -ti wordpress /bin/bash -c 'chown -R www-data: /var/www/html' \ No newline at end of file diff --git a/themes/.gitkeep b/themes/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/uploads.ini b/uploads.ini deleted file mode 100644 index d7f0e32..0000000 --- a/uploads.ini +++ /dev/null @@ -1,5 +0,0 @@ -file_uploads = On -memory_limit = 64M -upload_max_filesize = 20M -post_max_size = 20M -max_execution_time = 600 \ No newline at end of file diff --git a/wordpress/.gitkeep b/wordpress/.gitkeep new file mode 100644 index 0000000..e69de29