From ef168fbcc8c86268c644640c5e47dd19bfed3843 Mon Sep 17 00:00:00 2001 From: Josh Kasten Date: Mon, 30 Mar 2020 18:13:36 -0700 Subject: [PATCH 1/4] Added docker files so a plugin dev an quickly test * Run ./docker.sh to start the process instead of running docker-compose up - This way the wordpress plugins folder can be directly edited from your host system --- .env | 2 ++ docker-compose.yml | 34 ++++++++++++++++++++++++++++++++++ docker.sh | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+) create mode 100644 .env create mode 100644 docker-compose.yml create mode 100755 docker.sh diff --git a/.env b/.env new file mode 100644 index 0000000..3a2df58 --- /dev/null +++ b/.env @@ -0,0 +1,2 @@ +CONTAINER=wordpress +WORDPRESS_HTTP_PORT=8000 \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..88ce7fe --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,34 @@ +version: '3.3' + +services: + db: + image: mysql:5.7 + volumes: + - db_data:/var/lib/mysql + restart: always + environment: + MYSQL_ROOT_PASSWORD: somewordpress + MYSQL_DATABASE: wordpress + MYSQL_USER: wordpress + MYSQL_PASSWORD: wordpress + + wordpress: + depends_on: + - db + image: wordpress:latest + ports: + - "${WORDPRESS_HTTP_PORT}:80" + restart: always + container_name: "${CONTAINER}" + environment: + WORDPRESS_DB_HOST: db:3306 + WORDPRESS_DB_USER: wordpress + WORDPRESS_DB_PASSWORD: wordpress + WORDPRESS_DB_NAME: wordpress + WORDPRESS_DEBUG: 1 + working_dir: /var/www/html + volumes: + - ./docker-instance-files/plugins:/var/www/html/wp-content/plugins + - ./docker-instance-files/uploads.ini:/usr/local/etc/php/conf.d/uploads.ini +volumes: + db_data: {} diff --git a/docker.sh b/docker.sh new file mode 100755 index 0000000..0545e1b --- /dev/null +++ b/docker.sh @@ -0,0 +1,34 @@ +# The purpose of this script is to provide write access to the wordpress plugins folder for +# both the host machine and the docker container itself. +# This makes plugin testing much easy as the the file in the plugins folder can be directly +# edited on the host machine's IDE. +# This means no more needing to copy files from host->container or using vim in the container! + +export $(xargs < .env) + +USER_ID=`id -u` +GROUP_ID=`id -g` + +# Starting docker images without allowing them to execute anything yet. +# This is so we can correctly set the permission below before it starts creating files +echo "Starting $CONTAINER in --no-start mode" +docker-compose up --no-start $CONTAINER +docker-compose up --detach $CONTAINER + +echo "Wait for all wordpress files to be comes available" +docker exec -ti $CONTAINER /bin/bash -c 'until [[ -f .htaccess ]]; do sleep 1; done' + +echo "Allowing Wordpress container to modify any files in the docker-instance-file/plugins folder" +docker exec -ti $CONTAINER /bin/bash -c "usermod -u ${USER_ID} www-data" +docker exec -ti $CONTAINER /bin/bash -c "groupmod -g ${GROUP_ID} www-data" +echo "Restart container for permsision settings to take effect" +docker container restart $CONTAINER + +echo "Updating '/var/www' folder ownership" +docker exec -ti $CONTAINER /bin/bash -c 'chown -R www-data:www-data /var/www' + +echo "Started Scuessfully!" +echo "──────────────────────────────────────────────────────" + +echo "Tailing logs" +docker-compose up \ No newline at end of file From 2bb1919838dc2dd7fbeb94d5db96fcdb88367222 Mon Sep 17 00:00:00 2001 From: Josh Kasten Date: Mon, 30 Mar 2020 18:15:47 -0700 Subject: [PATCH 2/4] Dev docker, added plugin size limit override --- docker-instance-files/uploads.ini | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 docker-instance-files/uploads.ini diff --git a/docker-instance-files/uploads.ini b/docker-instance-files/uploads.ini new file mode 100644 index 0000000..c09282b --- /dev/null +++ b/docker-instance-files/uploads.ini @@ -0,0 +1,5 @@ +file_uploads = On +memory_limit = 64M +upload_max_filesize = 64M +post_max_size = 64M +max_execution_time = 600 \ No newline at end of file From 6b467b06f723a914645ad2b83d1c3cc17d18e59d Mon Sep 17 00:00:00 2001 From: Josh Kasten Date: Mon, 30 Mar 2020 18:16:09 -0700 Subject: [PATCH 3/4] Dev docker, added gitignore for docker files --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index 91b5ccd..3c0bc62 100644 --- a/.gitignore +++ b/.gitignore @@ -60,3 +60,7 @@ crashlytics-build.properties .DS_Store onesignal-extra.php + +docker-instance-files/* +# Expection to the rule as we need this files to modify plugin upload limits +!uploads.ini \ No newline at end of file From a729e9837e74905b2c11c5353097ca624b61f15e Mon Sep 17 00:00:00 2001 From: Josh Kasten Date: Mon, 30 Mar 2020 18:17:02 -0700 Subject: [PATCH 4/4] Added guide on using docker and editing files --- PluginDevDockerUsage.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 PluginDevDockerUsage.md diff --git a/PluginDevDockerUsage.md b/PluginDevDockerUsage.md new file mode 100644 index 0000000..fa00e08 --- /dev/null +++ b/PluginDevDockerUsage.md @@ -0,0 +1,16 @@ +## Setup +1. Run `./docker.sh` +2. Go to http://localhost:8000/ in your browser. +3. Follow the WordPress page's setup guide create your user +4. After logging in to the WordPress admin go to "Plugins" > "Add New" > "Upload Plugin" +5. Zip up all file in this directory expect "docker-instance-files" +6. Upload this on the page from step 4. above +7. Make sure to active the plugin on the Plugins page +8. Your done, happy editing! + +## Editing +1. Test changes by editing files under docker-instance-files/plugins/ + - Modify these directly on your host machine, changes take effect immediately! +2. Make sure to get your changes in to the original source to commit + - Careful not to re-upload your plugin, it will overwrite files docker-instance-files/plugins/ + \ No newline at end of file