From 9991b728e0029c99f94b810d68fce02546c422a6 Mon Sep 17 00:00:00 2001 From: Tung Du Date: Mon, 29 Jun 2020 17:29:55 +0700 Subject: [PATCH 01/26] build: add vscode remote container support --- .devcontainer/Dockerfile | 47 +++++++++++++ .devcontainer/config/nginx/default.conf | 70 +++++++++++++++++++ .../config/php-fpm/docker-php-ext-xdebug.ini | 7 ++ .devcontainer/devcontainer.json | 18 +++++ .devcontainer/docker-compose.yml | 48 +++++++++++++ .devcontainer/setup.sh | 30 ++++++++ 6 files changed, 220 insertions(+) create mode 100644 .devcontainer/Dockerfile create mode 100755 .devcontainer/config/nginx/default.conf create mode 100755 .devcontainer/config/php-fpm/docker-php-ext-xdebug.ini create mode 100644 .devcontainer/devcontainer.json create mode 100644 .devcontainer/docker-compose.yml create mode 100755 .devcontainer/setup.sh diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 00000000..3f91e10f --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,47 @@ +#------------------------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information. +#------------------------------------------------------------------------------------------------------------- + +FROM php:7-cli + +# This Dockerfile adds a non-root user with sudo access. Use the "remoteUser" +# property in devcontainer.json to use it. On Linux, the container user's GID/UIDs +# will be updated to match your local UID/GID (when using the dockerFile property). +# See https://aka.ms/vscode-remote/containers/non-root-user for details. +ARG USERNAME=vscode +ARG USER_UID=1000 +ARG USER_GID=$USER_UID + +# Configure apt and install packages +RUN apt-get update \ + && export DEBIAN_FRONTEND=noninteractive \ + && apt-get -y install --no-install-recommends apt-utils dialog 2>&1 \ + # + # [Optional] Install MariaDB client to manage database directly from dev container's shell + && apt-get install -y mariadb-client \ + # + # install git iproute2, procps, lsb-release (useful for CLI installs) + && apt-get -y install git openssh-client less iproute2 procps iproute2 lsb-release \ + # + # Install xdebug + && yes | pecl install xdebug \ + && echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini \ + && echo "xdebug.remote_enable=on" >> /usr/local/etc/php/conf.d/xdebug.ini \ + && echo "xdebug.remote_autostart=on" >> /usr/local/etc/php/conf.d/xdebug.ini \ + # + # Create a non-root user to use if preferred - see https://aka.ms/vscode-remote/containers/non-root-user. + && groupadd --gid $USER_GID $USERNAME \ + && useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \ + # [Optional] Add sudo support for the non-root user + && apt-get install -y sudo \ + && echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME\ + && chmod 0440 /etc/sudoers.d/$USERNAME \ + # + # [Optional] Install NPM to assist with frontend development (Dramatically increases build time on slower connections) + && apt-get install -y npm \ + # + # Clean up + && apt-get autoremove -y \ + && apt-get clean -y \ + && rm -rf /var/lib/apt/lists/* diff --git a/.devcontainer/config/nginx/default.conf b/.devcontainer/config/nginx/default.conf new file mode 100755 index 00000000..0defccf1 --- /dev/null +++ b/.devcontainer/config/nginx/default.conf @@ -0,0 +1,70 @@ +map $http_x_forwarded_proto $fe_https { + default off; + https on; +} + +# Docker DNS resolver, so we can resolve things like "elasticsearch" +resolver 127.0.0.11 valid=10s; + +server { + listen 80 default_server; + + # Doesn't really matter because default server, but this way email doesn't throw errors + server_name localhost; + + access_log /var/log/nginx/access.log; + error_log /var/log/nginx/error.log; + + root /var/www/html; + index index.php; + + if (!-e $request_filename) { + rewrite /wp-admin$ $scheme://$host$uri/ permanent; + rewrite ^(/[^/]+)?(/wp-.*) $2 last; + rewrite ^(/[^/]+)?(/.*\.php) $2 last; + } + + #location /__memcacheadmin/ { + # rewrite ^/__memcacheadmin/(.*) /$1 break; + # proxy_pass http://memcacheadmin:80; + #} + + location /__elasticsearch/ { + # Variable, so that it does not error when ES not included with the environment + set $es_host http://elasticsearch:9200; + + rewrite ^/__elasticsearch/(.*) /$1 break; + proxy_pass $es_host; + } + + location / { + try_files $uri $uri/ /index.php?$args; + } + + location ~ \.php$ { + try_files $uri =404; + fastcgi_split_path_info ^(.+\.php)(/.+)$; + + include /etc/nginx/fastcgi_params; + # Long timeout to allow more time with Xdebug + fastcgi_read_timeout 3600s; + fastcgi_buffer_size 128k; + fastcgi_buffers 4 128k; + fastcgi_pass phpfpm:9000; + fastcgi_index index.php; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_param HTTPS $fe_https; + } + + location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ { + access_log off; log_not_found off; expires max; + + add_header Access-Control-Allow-Origin *; + #{TRY_PROXY} + } + + #{PROXY_URL} + + # This should match upload_max_filesize in php.ini + client_max_body_size 150m; +} diff --git a/.devcontainer/config/php-fpm/docker-php-ext-xdebug.ini b/.devcontainer/config/php-fpm/docker-php-ext-xdebug.ini new file mode 100755 index 00000000..72c89aa7 --- /dev/null +++ b/.devcontainer/config/php-fpm/docker-php-ext-xdebug.ini @@ -0,0 +1,7 @@ +# Note that Xdebug is disabled in the php container by default. If you +# wish to enable it modify the docker-compose.yml file for this project +xdebug.remote_enable = 1 +xdebug.remote_autostart = 1 +xdebug.remote_host = host.docker.internal +xdebug.profiler_enable = 0 +xdebug.profiler_output_dir = /var/www/html/wordpress/ diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000..a7741af8 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,18 @@ +{ + "name": "WordPress", + "dockerComposeFile": "docker-compose.yml", + "service": "phpfpm", + // Set *default* container specific settings.json values on container create. + "settings": { + "terminal.integrated.shell.linux": "/bin/bash", + "php.suggest.basic": false + }, + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + "felixfbecker.php-debug", + "mtxr.sqltools" + ], + "workspaceFolder": "/var/www/html/", + "postCreateCommand": "/var/www/html/wp-content/plugins/simple-podcasting/.devcontainer/setup.sh", + "remoteUser": "www-data", +} \ No newline at end of file diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml new file mode 100644 index 00000000..82f8e2d4 --- /dev/null +++ b/.devcontainer/docker-compose.yml @@ -0,0 +1,48 @@ +version: "3" + +services: + nginx: + image: 'nginx:latest' + ports: + - '8080:80' + depends_on: + - phpfpm + volumes: + - wordpress:/var/www/html + - './config/nginx/default.conf:/etc/nginx/conf.d/default.conf:cached' + networks: + - default + restart: unless-stopped + phpfpm: + image: '10up/wp-php-fpm-dev:7.3' + environment: + ENABLE_XDEBUG: 'false' + volumes: + - wordpress:/var/www/html + - ../:/var/www/html/wp-content/plugins/simple-podcasting + - './config/php-fpm/docker-php-ext-xdebug.ini:/etc/php.d/docker-php-ext-xdebug.ini:cached' + depends_on: + - db + networks: + - default + restart: unless-stopped + db: + image: mariadb:10.4 + expose: + - "3306" + tty: true + environment: + MYSQL_DATABASE: wordpress + MYSQL_USER: admin + MYSQL_PASSWORD: password + MYSQL_ROOT_PASSWORD: password + volumes: + - data:/var/lib/mysql + networks: + - default + restart: unless-stopped +volumes: + wordpress: + data: +networks: + default: \ No newline at end of file diff --git a/.devcontainer/setup.sh b/.devcontainer/setup.sh new file mode 100755 index 00000000..4fff4bf0 --- /dev/null +++ b/.devcontainer/setup.sh @@ -0,0 +1,30 @@ +#! /bin/bash + +#Site configuration options +SITE_TITLE="Simple Podcasting Development Site" +ADMIN_USER=admin +ADMIN_PASS=password +ADMIN_EMAIL="admin@example.com" + +echo "Setting up WordPress" + +sudo chown www-data: -R /var/www/html + +cd /var/www/html + +rm -f wp-config.php + +wp core download --force +wp config create --dbhost="db" --dbname="wordpress" --dbuser="admin" --dbpass="password" --skip-check +wp db reset --yes +wp core install --url="http://localhost:8080" --title="$SITE_TITLE" --admin_user="$ADMIN_USER" --admin_email="$ADMIN_EMAIL" --admin_password="$ADMIN_PASS" --skip-email +wp plugin activate simple-podcasting + +echo "Install plugin dependencies" + +cd /var/www/html/wp-content/plugins/simple-podcasting +composer install +npm install 10 +nvm use 10 +npm install +npm run build \ No newline at end of file From 32fbb6302ee22bb2aedafc769c125a9095103b57 Mon Sep 17 00:00:00 2001 From: Tung Du Date: Mon, 29 Jun 2020 17:31:35 +0700 Subject: [PATCH 02/26] build: remove unused Dockerfile --- .devcontainer/Dockerfile | 47 ---------------------------------------- 1 file changed, 47 deletions(-) delete mode 100644 .devcontainer/Dockerfile diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile deleted file mode 100644 index 3f91e10f..00000000 --- a/.devcontainer/Dockerfile +++ /dev/null @@ -1,47 +0,0 @@ -#------------------------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information. -#------------------------------------------------------------------------------------------------------------- - -FROM php:7-cli - -# This Dockerfile adds a non-root user with sudo access. Use the "remoteUser" -# property in devcontainer.json to use it. On Linux, the container user's GID/UIDs -# will be updated to match your local UID/GID (when using the dockerFile property). -# See https://aka.ms/vscode-remote/containers/non-root-user for details. -ARG USERNAME=vscode -ARG USER_UID=1000 -ARG USER_GID=$USER_UID - -# Configure apt and install packages -RUN apt-get update \ - && export DEBIAN_FRONTEND=noninteractive \ - && apt-get -y install --no-install-recommends apt-utils dialog 2>&1 \ - # - # [Optional] Install MariaDB client to manage database directly from dev container's shell - && apt-get install -y mariadb-client \ - # - # install git iproute2, procps, lsb-release (useful for CLI installs) - && apt-get -y install git openssh-client less iproute2 procps iproute2 lsb-release \ - # - # Install xdebug - && yes | pecl install xdebug \ - && echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini \ - && echo "xdebug.remote_enable=on" >> /usr/local/etc/php/conf.d/xdebug.ini \ - && echo "xdebug.remote_autostart=on" >> /usr/local/etc/php/conf.d/xdebug.ini \ - # - # Create a non-root user to use if preferred - see https://aka.ms/vscode-remote/containers/non-root-user. - && groupadd --gid $USER_GID $USERNAME \ - && useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \ - # [Optional] Add sudo support for the non-root user - && apt-get install -y sudo \ - && echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME\ - && chmod 0440 /etc/sudoers.d/$USERNAME \ - # - # [Optional] Install NPM to assist with frontend development (Dramatically increases build time on slower connections) - && apt-get install -y npm \ - # - # Clean up - && apt-get autoremove -y \ - && apt-get clean -y \ - && rm -rf /var/lib/apt/lists/* From 898c9acdff9120124a675cdbe2ca617d3ebbceb0 Mon Sep 17 00:00:00 2001 From: Tung Du Date: Mon, 29 Jun 2020 13:24:51 +0000 Subject: [PATCH 03/26] build: fix nvm issue --- .devcontainer/devcontainer.json | 2 +- .devcontainer/setup.sh | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index a7741af8..c78fab3b 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -13,6 +13,6 @@ "mtxr.sqltools" ], "workspaceFolder": "/var/www/html/", - "postCreateCommand": "/var/www/html/wp-content/plugins/simple-podcasting/.devcontainer/setup.sh", + "postCreateCommand": "/var/www/html/wp-content/plugins/simple-podcasting/.devcontainer/setup.sh &> log.txt", "remoteUser": "www-data", } \ No newline at end of file diff --git a/.devcontainer/setup.sh b/.devcontainer/setup.sh index 4fff4bf0..33799539 100755 --- a/.devcontainer/setup.sh +++ b/.devcontainer/setup.sh @@ -23,8 +23,11 @@ wp plugin activate simple-podcasting echo "Install plugin dependencies" cd /var/www/html/wp-content/plugins/simple-podcasting -composer install -npm install 10 + +source ~/.nvm/nvm.sh +nvm install 10 nvm use 10 npm install -npm run build \ No newline at end of file +npm run build + +composer install \ No newline at end of file From 5f973fe4b3d7e76aca28ce3e2f959101e7656dc4 Mon Sep 17 00:00:00 2001 From: Tung Du Date: Mon, 29 Jun 2020 13:34:17 +0000 Subject: [PATCH 04/26] change default node version --- .devcontainer/setup.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/.devcontainer/setup.sh b/.devcontainer/setup.sh index 33799539..4dc0ef1a 100755 --- a/.devcontainer/setup.sh +++ b/.devcontainer/setup.sh @@ -27,6 +27,7 @@ cd /var/www/html/wp-content/plugins/simple-podcasting source ~/.nvm/nvm.sh nvm install 10 nvm use 10 +nvm alias default 10 npm install npm run build From ceff5a0e04d3a233df8399159facebad1398263b Mon Sep 17 00:00:00 2001 From: Tung Du Date: Tue, 30 Jun 2020 09:07:50 +0700 Subject: [PATCH 05/26] build: add forwardPorts --- .devcontainer/devcontainer.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index c78fab3b..72af3527 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,7 +1,8 @@ { "name": "WordPress", "dockerComposeFile": "docker-compose.yml", - "service": "phpfpm", + "service": "phpfpm", + "forwardPorts": [8080], // Set *default* container specific settings.json values on container create. "settings": { "terminal.integrated.shell.linux": "/bin/bash", @@ -15,4 +16,4 @@ "workspaceFolder": "/var/www/html/", "postCreateCommand": "/var/www/html/wp-content/plugins/simple-podcasting/.devcontainer/setup.sh &> log.txt", "remoteUser": "www-data", -} \ No newline at end of file +} From d3ccf7139059d0a00dfc4f335d23f835cb0a1304 Mon Sep 17 00:00:00 2001 From: Tung Du Date: Tue, 30 Jun 2020 02:49:49 +0000 Subject: [PATCH 06/26] build: update mariadb driver --- .devcontainer/devcontainer.json | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 72af3527..774f99cb 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,8 +1,8 @@ { "name": "WordPress", "dockerComposeFile": "docker-compose.yml", - "service": "phpfpm", - "forwardPorts": [8080], + "service": "phpfpm", + "forwardPorts": [ 8080 ], // Set *default* container specific settings.json values on container create. "settings": { "terminal.integrated.shell.linux": "/bin/bash", @@ -11,9 +11,11 @@ // Add the IDs of extensions you want installed when the container is created. "extensions": [ "felixfbecker.php-debug", - "mtxr.sqltools" + "bmewburn.vscode-intelephense-client", + "mtxr.sqltools", + "mtxr.sqltools-driver-mysql" ], "workspaceFolder": "/var/www/html/", "postCreateCommand": "/var/www/html/wp-content/plugins/simple-podcasting/.devcontainer/setup.sh &> log.txt", "remoteUser": "www-data", -} +} \ No newline at end of file From bd02bb6a40769955eb09ecce705630fe3716602c Mon Sep 17 00:00:00 2001 From: Tung Du Date: Tue, 30 Jun 2020 17:18:13 +0700 Subject: [PATCH 07/26] build: mount the plugin to nginx container --- .devcontainer/docker-compose.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml index 82f8e2d4..a9692056 100644 --- a/.devcontainer/docker-compose.yml +++ b/.devcontainer/docker-compose.yml @@ -9,6 +9,7 @@ services: - phpfpm volumes: - wordpress:/var/www/html + - ../:/var/www/html/wp-content/plugins/simple-podcasting - './config/nginx/default.conf:/etc/nginx/conf.d/default.conf:cached' networks: - default @@ -45,4 +46,4 @@ volumes: wordpress: data: networks: - default: \ No newline at end of file + default: From f5ccaf51c7463388570f5fc94268dc8eb6fa855c Mon Sep 17 00:00:00 2001 From: Tung Du Date: Thu, 16 Jul 2020 13:15:27 +0700 Subject: [PATCH 08/26] feat: config free devcontainer setup, allow simple copy and paste to add container support for other project. Work with both theme and plugin. --- .../config/php-fpm/docker-php-ext-xdebug.ini | 4 +- .devcontainer/createEnv.sh | 24 ++++++++ .devcontainer/devcontainer.json | 15 ++--- .devcontainer/docker-compose.yml | 26 ++++---- .devcontainer/setup.sh | 60 +++++++++++++------ .gitignore | 2 + 6 files changed, 91 insertions(+), 40 deletions(-) create mode 100644 .devcontainer/createEnv.sh diff --git a/.devcontainer/config/php-fpm/docker-php-ext-xdebug.ini b/.devcontainer/config/php-fpm/docker-php-ext-xdebug.ini index 72c89aa7..1a522ab6 100755 --- a/.devcontainer/config/php-fpm/docker-php-ext-xdebug.ini +++ b/.devcontainer/config/php-fpm/docker-php-ext-xdebug.ini @@ -1,7 +1,7 @@ -# Note that Xdebug is disabled in the php container by default. If you +# Note that Xdebug is disabled in the php container by default. If you # wish to enable it modify the docker-compose.yml file for this project xdebug.remote_enable = 1 xdebug.remote_autostart = 1 xdebug.remote_host = host.docker.internal xdebug.profiler_enable = 0 -xdebug.profiler_output_dir = /var/www/html/wordpress/ +xdebug.profiler_output_dir = /var/www/html/ diff --git a/.devcontainer/createEnv.sh b/.devcontainer/createEnv.sh new file mode 100644 index 00000000..9d66c12c --- /dev/null +++ b/.devcontainer/createEnv.sh @@ -0,0 +1,24 @@ +#! /bin/bash + +if test -f "style.css"; then + TYPE=theme +else + TYPE=plugin +fi + +/bin/cat < .env +SLUG=$1 +PROJECT_TYPE=$TYPE +SITE_HOST=http://localhost +ENABLE_XDEBUG=false +ADMIN_USER=admin +ADMIN_PASS=password +ADMIN_EMAIL=admin@example.com +MYSQL_DATABASE=wordpress +MYSQL_USER=admin +MYSQL_PASSWORD=password +MYSQL_ROOT_PASSWORD=password +NODE_VERSION=10 +USE_COMPOSER=true +USE_NODE=true +EOM diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 774f99cb..686b9251 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,8 +1,10 @@ { - "name": "WordPress", + "name": "${localWorkspaceFolderBasename}", "dockerComposeFile": "docker-compose.yml", "service": "phpfpm", - "forwardPorts": [ 8080 ], + "forwardPorts": [ + 8080 + ], // Set *default* container specific settings.json values on container create. "settings": { "terminal.integrated.shell.linux": "/bin/bash", @@ -10,12 +12,11 @@ }, // Add the IDs of extensions you want installed when the container is created. "extensions": [ - "felixfbecker.php-debug", - "bmewburn.vscode-intelephense-client", "mtxr.sqltools", "mtxr.sqltools-driver-mysql" ], "workspaceFolder": "/var/www/html/", - "postCreateCommand": "/var/www/html/wp-content/plugins/simple-podcasting/.devcontainer/setup.sh &> log.txt", - "remoteUser": "www-data", -} \ No newline at end of file + "postCreateCommand": "/var/www/html/wp-content/${PROJECT_TYPE}s/${localWorkspaceFolderBasename}/.devcontainer/setup.sh", + "initializeCommand": "bash .devcontainer/createEnv.sh ${localWorkspaceFolderBasename}", + "remoteUser": "www-data" +} diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml index a9692056..8c1884a9 100644 --- a/.devcontainer/docker-compose.yml +++ b/.devcontainer/docker-compose.yml @@ -2,41 +2,43 @@ version: "3" services: nginx: - image: 'nginx:latest' + image: "nginx:latest" ports: - - '8080:80' + - "8080:80" depends_on: - phpfpm volumes: - wordpress:/var/www/html - - ../:/var/www/html/wp-content/plugins/simple-podcasting - - './config/nginx/default.conf:/etc/nginx/conf.d/default.conf:cached' + - "../:/var/www/html/wp-content/${PROJECT_TYPE}s/${SLUG}" + - "./config/nginx/default.conf:/etc/nginx/conf.d/default.conf:cached" networks: - default restart: unless-stopped phpfpm: - image: '10up/wp-php-fpm-dev:7.3' + image: "10up/wp-php-fpm-dev:7.3" environment: - ENABLE_XDEBUG: 'false' + ENABLE_XDEBUG: "${ENABLE_XDEBUG}" volumes: - wordpress:/var/www/html - - ../:/var/www/html/wp-content/plugins/simple-podcasting - - './config/php-fpm/docker-php-ext-xdebug.ini:/etc/php.d/docker-php-ext-xdebug.ini:cached' + - "../:/var/www/html/wp-content/${PROJECT_TYPE}s/${SLUG}" + - "./config/php-fpm/docker-php-ext-xdebug.ini:/etc/php.d/docker-php-ext-xdebug.ini:cached" depends_on: - db networks: - default restart: unless-stopped + env_file: + - ../.env db: image: mariadb:10.4 expose: - "3306" tty: true environment: - MYSQL_DATABASE: wordpress - MYSQL_USER: admin - MYSQL_PASSWORD: password - MYSQL_ROOT_PASSWORD: password + MYSQL_DATABASE: "${MYSQL_DATABASE}" + MYSQL_USER: "${MYSQL_USER}" + MYSQL_PASSWORD: "${MYSQL_PASSWORD}" + MYSQL_ROOT_PASSWORD: "${MYSQL_ROOT_PASSWORD}" volumes: - data:/var/lib/mysql networks: diff --git a/.devcontainer/setup.sh b/.devcontainer/setup.sh index 4dc0ef1a..24cdb95a 100755 --- a/.devcontainer/setup.sh +++ b/.devcontainer/setup.sh @@ -1,34 +1,56 @@ #! /bin/bash -#Site configuration options -SITE_TITLE="Simple Podcasting Development Site" -ADMIN_USER=admin -ADMIN_PASS=password -ADMIN_EMAIL="admin@example.com" +sudo chown www-data: -R /var/www/html -echo "Setting up WordPress" +exec 3>&1 4>&2 +trap 'exec 2>&4 1>&3' 0 1 2 3 +exec 1>setup.log 2>&1 -sudo chown www-data: -R /var/www/html +# Prepare a nice name from project name for the site title. +function getTitleFromSlug() +{ + local _slug=${SLUG/-/ } + local __slug=${_slug/_/ } + local ___slug=( $__slug ) + echo "${___slug[@]^}" +} + +echo "Setting up WordPress" cd /var/www/html rm -f wp-config.php wp core download --force -wp config create --dbhost="db" --dbname="wordpress" --dbuser="admin" --dbpass="password" --skip-check +wp config create --dbhost="db" --dbname="$MYSQL_DATABASE" --dbuser="$MYSQL_USER" --dbpass="$MYSQL_PASSWORD" --skip-check wp db reset --yes -wp core install --url="http://localhost:8080" --title="$SITE_TITLE" --admin_user="$ADMIN_USER" --admin_email="$ADMIN_EMAIL" --admin_password="$ADMIN_PASS" --skip-email -wp plugin activate simple-podcasting +wp core install --url="$SITE_HOST:8080" --title="$(getTitleFromSlug) Development" --admin_user="$ADMIN_USER" --admin_email="$ADMIN_EMAIL" --admin_password="$ADMIN_PASS" --skip-email + +echo "Install project dependencies" + +# Install required node version +if [[ "$NODE_VERSION" != "12" ]] +then + source ~/.nvm/nvm.sh + nvm install $NODE_VERSION + nvm use $NODE_VERSION + nvm alias default $NODE_VERSION +fi + +cd /var/www/html/wp-content/${PROJECT_TYPE}s/$SLUG + +echo "Changed directory to $(pwd)" -echo "Install plugin dependencies" +if [[ "$USE_NODE" == "true" ]] +then + npm install +fi -cd /var/www/html/wp-content/plugins/simple-podcasting +if [[ "$USE_COMPOSER" == "true" ]] +then + composer install +fi -source ~/.nvm/nvm.sh -nvm install 10 -nvm use 10 -nvm alias default 10 -npm install -npm run build +echo "Activating theme/plugin" -composer install \ No newline at end of file +wp $PROJECT_TYPE activate $SLUG diff --git a/.gitignore b/.gitignore index 98a04d68..fed8b315 100755 --- a/.gitignore +++ b/.gitignore @@ -31,3 +31,5 @@ Session.vim # Windows Thumbs.db Desktop.ini + +.env From 85bfefa8db236ec022405e141ddb353a2a29f0c5 Mon Sep 17 00:00:00 2001 From: Tung Du Date: Thu, 16 Jul 2020 15:04:23 +0700 Subject: [PATCH 09/26] feat: detect composer and npm --- .devcontainer/createEnv.sh | 24 ++++++++++++++++++------ .devcontainer/setup.sh | 6 +++--- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/.devcontainer/createEnv.sh b/.devcontainer/createEnv.sh index 9d66c12c..39ea73ae 100644 --- a/.devcontainer/createEnv.sh +++ b/.devcontainer/createEnv.sh @@ -1,14 +1,26 @@ #! /bin/bash if test -f "style.css"; then - TYPE=theme + PROJECT_TYPE=theme else - TYPE=plugin + PROJECT_TYPE=plugin +fi + +if test -f "composer.json"; then + USE_COMPOSER=true +else + USE_COMPOSER=false +fi + +if test -f "package.json"; then + USE_NODE=true +else + USE_NODE=false fi /bin/cat < .env SLUG=$1 -PROJECT_TYPE=$TYPE +PROJECT_TYPE=$PROJECT_TYPE SITE_HOST=http://localhost ENABLE_XDEBUG=false ADMIN_USER=admin @@ -18,7 +30,7 @@ MYSQL_DATABASE=wordpress MYSQL_USER=admin MYSQL_PASSWORD=password MYSQL_ROOT_PASSWORD=password -NODE_VERSION=10 -USE_COMPOSER=true -USE_NODE=true +NODE_VERSION=12 +USE_COMPOSER=$USE_COMPOSER +USE_NODE=$USE_NODE EOM diff --git a/.devcontainer/setup.sh b/.devcontainer/setup.sh index 24cdb95a..d4314ed1 100755 --- a/.devcontainer/setup.sh +++ b/.devcontainer/setup.sh @@ -9,8 +9,8 @@ exec 1>setup.log 2>&1 # Prepare a nice name from project name for the site title. function getTitleFromSlug() { - local _slug=${SLUG/-/ } - local __slug=${_slug/_/ } + local _slug=${SLUG//-/ } + local __slug=${_slug//_/ } local ___slug=( $__slug ) echo "${___slug[@]^}" } @@ -29,7 +29,7 @@ wp core install --url="$SITE_HOST:8080" --title="$(getTitleFromSlug) Development echo "Install project dependencies" # Install required node version -if [[ "$NODE_VERSION" != "12" ]] +if [[ ! -z "$NODE_VERSION" ]] && [[ "$NODE_VERSION" != "12" ]] then source ~/.nvm/nvm.sh nvm install $NODE_VERSION From e51ecad39d55154f82703976f71781c9a3d94968 Mon Sep 17 00:00:00 2001 From: Tung Du Date: Thu, 16 Jul 2020 15:05:32 +0700 Subject: [PATCH 10/26] test: set node version to 10 --- .devcontainer/createEnv.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/createEnv.sh b/.devcontainer/createEnv.sh index 39ea73ae..17c28f2f 100644 --- a/.devcontainer/createEnv.sh +++ b/.devcontainer/createEnv.sh @@ -30,7 +30,7 @@ MYSQL_DATABASE=wordpress MYSQL_USER=admin MYSQL_PASSWORD=password MYSQL_ROOT_PASSWORD=password -NODE_VERSION=12 USE_COMPOSER=$USE_COMPOSER USE_NODE=$USE_NODE +NODE_VERSION=10 EOM From ad3d6f10b2c7438d67e3b08d3c28413eba2179e5 Mon Sep 17 00:00:00 2001 From: Tung Du Date: Thu, 16 Jul 2020 16:24:57 +0700 Subject: [PATCH 11/26] update: latest and greatest definition --- .../config/php-fpm/docker-php-ext-xdebug.ini | 3 ++- .devcontainer/createEnv.sh | 12 +++++++++--- .devcontainer/devcontainer.json | 6 ++++-- .devcontainer/docker-compose.yml | 2 +- .devcontainer/setup.sh | 2 +- 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/.devcontainer/config/php-fpm/docker-php-ext-xdebug.ini b/.devcontainer/config/php-fpm/docker-php-ext-xdebug.ini index 1a522ab6..4afd03f2 100755 --- a/.devcontainer/config/php-fpm/docker-php-ext-xdebug.ini +++ b/.devcontainer/config/php-fpm/docker-php-ext-xdebug.ini @@ -2,6 +2,7 @@ # wish to enable it modify the docker-compose.yml file for this project xdebug.remote_enable = 1 xdebug.remote_autostart = 1 -xdebug.remote_host = host.docker.internal +xdebug.remote_host = localhost xdebug.profiler_enable = 0 xdebug.profiler_output_dir = /var/www/html/ +xdebug.remote_port = 9001 diff --git a/.devcontainer/createEnv.sh b/.devcontainer/createEnv.sh index 17c28f2f..8203866d 100644 --- a/.devcontainer/createEnv.sh +++ b/.devcontainer/createEnv.sh @@ -21,16 +21,22 @@ fi /bin/cat < .env SLUG=$1 PROJECT_TYPE=$PROJECT_TYPE +USE_COMPOSER=$USE_COMPOSER +USE_NODE=$USE_NODE + SITE_HOST=http://localhost -ENABLE_XDEBUG=false + ADMIN_USER=admin ADMIN_PASS=password ADMIN_EMAIL=admin@example.com + MYSQL_DATABASE=wordpress MYSQL_USER=admin MYSQL_PASSWORD=password MYSQL_ROOT_PASSWORD=password -USE_COMPOSER=$USE_COMPOSER -USE_NODE=$USE_NODE + +PHP_VERSION=7.3 +ENABLE_XDEBUG=false + NODE_VERSION=10 EOM diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 686b9251..95cd51ea 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -12,8 +12,10 @@ }, // Add the IDs of extensions you want installed when the container is created. "extensions": [ - "mtxr.sqltools", - "mtxr.sqltools-driver-mysql" + "bmewburn.vscode-intelephense-client", + // "felixfbecker.php-debug", + // "mtxr.sqltools", + // "mtxr.sqltools-driver-mysql" ], "workspaceFolder": "/var/www/html/", "postCreateCommand": "/var/www/html/wp-content/${PROJECT_TYPE}s/${localWorkspaceFolderBasename}/.devcontainer/setup.sh", diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml index 8c1884a9..49ee0abe 100644 --- a/.devcontainer/docker-compose.yml +++ b/.devcontainer/docker-compose.yml @@ -15,7 +15,7 @@ services: - default restart: unless-stopped phpfpm: - image: "10up/wp-php-fpm-dev:7.3" + image: "10up/wp-php-fpm-dev:${PHP_VERSION}" environment: ENABLE_XDEBUG: "${ENABLE_XDEBUG}" volumes: diff --git a/.devcontainer/setup.sh b/.devcontainer/setup.sh index d4314ed1..f28b7e94 100755 --- a/.devcontainer/setup.sh +++ b/.devcontainer/setup.sh @@ -29,7 +29,7 @@ wp core install --url="$SITE_HOST:8080" --title="$(getTitleFromSlug) Development echo "Install project dependencies" # Install required node version -if [[ ! -z "$NODE_VERSION" ]] && [[ "$NODE_VERSION" != "12" ]] +if [[ ! -z "$NODE_VERSION" ]] && [[ "$NODE_VERSION" != "latest" ]] then source ~/.nvm/nvm.sh nvm install $NODE_VERSION From f20afdc45dd7bfa2959241f8da36dfbdd3a7aea6 Mon Sep 17 00:00:00 2001 From: Helen Hou-Sandi Date: Thu, 2 Sep 2021 12:51:22 -0600 Subject: [PATCH 12/26] Try adding port to SITE_HOST per suggestion from @dustinrue --- .devcontainer/createEnv.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/createEnv.sh b/.devcontainer/createEnv.sh index 8203866d..6ff6875c 100644 --- a/.devcontainer/createEnv.sh +++ b/.devcontainer/createEnv.sh @@ -24,7 +24,7 @@ PROJECT_TYPE=$PROJECT_TYPE USE_COMPOSER=$USE_COMPOSER USE_NODE=$USE_NODE -SITE_HOST=http://localhost +SITE_HOST=http://localhost:8080 ADMIN_USER=admin ADMIN_PASS=password From 87228c379d93321e39ab89677aabe5ff01f76e12 Mon Sep 17 00:00:00 2001 From: Helen Hou-Sandi Date: Thu, 2 Sep 2021 13:18:07 -0600 Subject: [PATCH 13/26] Hardcode values for now, some kind of error See https://gist.github.com/helen/e731608237d12f6f351662808cdbf2cc --- .devcontainer/docker-compose.yml | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml index 49ee0abe..2aaaab68 100644 --- a/.devcontainer/docker-compose.yml +++ b/.devcontainer/docker-compose.yml @@ -9,18 +9,22 @@ services: - phpfpm volumes: - wordpress:/var/www/html - - "../:/var/www/html/wp-content/${PROJECT_TYPE}s/${SLUG}" + # - "../:/var/www/html/wp-content/${PROJECT_TYPE}s/${SLUG}" + - "../:/var/www/html/wp-content/plugins/simple-podcasting" - "./config/nginx/default.conf:/etc/nginx/conf.d/default.conf:cached" networks: - default restart: unless-stopped phpfpm: - image: "10up/wp-php-fpm-dev:${PHP_VERSION}" + # image: "10up/wp-php-fpm-dev:${PHP_VERSION}" + image: "10up/wp-php-fpm-dev:7.4" environment: - ENABLE_XDEBUG: "${ENABLE_XDEBUG}" + #ENABLE_XDEBUG: "${ENABLE_XDEBUG}" + ENABLE_XDEBUG: false volumes: - wordpress:/var/www/html - - "../:/var/www/html/wp-content/${PROJECT_TYPE}s/${SLUG}" + #- "../:/var/www/html/wp-content/${PROJECT_TYPE}s/${SLUG}" + - "../:/var/www/html/wp-content/plugins/simple-podcasting" - "./config/php-fpm/docker-php-ext-xdebug.ini:/etc/php.d/docker-php-ext-xdebug.ini:cached" depends_on: - db @@ -35,10 +39,14 @@ services: - "3306" tty: true environment: - MYSQL_DATABASE: "${MYSQL_DATABASE}" - MYSQL_USER: "${MYSQL_USER}" - MYSQL_PASSWORD: "${MYSQL_PASSWORD}" - MYSQL_ROOT_PASSWORD: "${MYSQL_ROOT_PASSWORD}" + # MYSQL_DATABASE: "${MYSQL_DATABASE}" + # MYSQL_USER: "${MYSQL_USER}" + # MYSQL_PASSWORD: "${MYSQL_PASSWORD}" + # MYSQL_ROOT_PASSWORD: "${MYSQL_ROOT_PASSWORD}" + MYSQL_DATABASE: "wordpress" + MYSQL_USER: "admin" + MYSQL_PASSWORD: "password" + MYSQL_ROOT_PASSWORD: "password" volumes: - data:/var/lib/mysql networks: From 065d65e5812bb4c89e4b1a2917d4ebb849739389 Mon Sep 17 00:00:00 2001 From: Helen Hou-Sandi Date: Thu, 2 Sep 2021 13:19:18 -0600 Subject: [PATCH 14/26] Oops quotes --- .devcontainer/docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml index 2aaaab68..60d9f290 100644 --- a/.devcontainer/docker-compose.yml +++ b/.devcontainer/docker-compose.yml @@ -20,7 +20,7 @@ services: image: "10up/wp-php-fpm-dev:7.4" environment: #ENABLE_XDEBUG: "${ENABLE_XDEBUG}" - ENABLE_XDEBUG: false + ENABLE_XDEBUG: "false" volumes: - wordpress:/var/www/html #- "../:/var/www/html/wp-content/${PROJECT_TYPE}s/${SLUG}" From 271a87c63b2d16cb5443f99b19afbec3e0d2fbf2 Mon Sep 17 00:00:00 2001 From: Helen Hou-Sandi Date: Thu, 2 Sep 2021 13:33:18 -0600 Subject: [PATCH 15/26] Try using CODESPACE_NAME in SITE_HOST --- .devcontainer/createEnv.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.devcontainer/createEnv.sh b/.devcontainer/createEnv.sh index 6ff6875c..6c27969e 100644 --- a/.devcontainer/createEnv.sh +++ b/.devcontainer/createEnv.sh @@ -24,7 +24,8 @@ PROJECT_TYPE=$PROJECT_TYPE USE_COMPOSER=$USE_COMPOSER USE_NODE=$USE_NODE -SITE_HOST=http://localhost:8080 +# SITE_HOST=http://localhost:8080 +SITE_HOST=https://${CODESPACE_NAME}-8080.githubpreview.dev ADMIN_USER=admin ADMIN_PASS=password From 75731ed97f8a2c4da9a23786f409736502686193 Mon Sep 17 00:00:00 2001 From: Helen Hou-Sandi Date: Thu, 2 Sep 2021 15:54:28 -0600 Subject: [PATCH 16/26] Let's get setup.sh running --- .devcontainer/devcontainer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 95cd51ea..2c8cc24e 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -18,7 +18,7 @@ // "mtxr.sqltools-driver-mysql" ], "workspaceFolder": "/var/www/html/", - "postCreateCommand": "/var/www/html/wp-content/${PROJECT_TYPE}s/${localWorkspaceFolderBasename}/.devcontainer/setup.sh", + "postCreateCommand": "/var/www/html/wp-content/plugins/${localWorkspaceFolderBasename}/.devcontainer/setup.sh", "initializeCommand": "bash .devcontainer/createEnv.sh ${localWorkspaceFolderBasename}", "remoteUser": "www-data" } From 9b2047e93fda85b14fad4aefc6bcbca964e341ce Mon Sep 17 00:00:00 2001 From: Helen Hou-Sandi Date: Fri, 3 Sep 2021 03:18:30 +0000 Subject: [PATCH 17/26] Debug some vars --- .devcontainer/setup.sh | 32 ++++++++++++++++++++++++++++++++ .gitignore | 1 + 2 files changed, 33 insertions(+) diff --git a/.devcontainer/setup.sh b/.devcontainer/setup.sh index f28b7e94..3eda55f1 100755 --- a/.devcontainer/setup.sh +++ b/.devcontainer/setup.sh @@ -6,6 +6,38 @@ exec 3>&1 4>&2 trap 'exec 2>&4 1>&3' 0 1 2 3 exec 1>setup.log 2>&1 +# DEBUG STUFF +if [[ -z "$SLUG" ]]; then + echo "SLUG not set" +else + echo "SLUG is set to $SLUG" +fi + +if [[ -z "$NODE_VERSION" ]]; then + echo "NODE_VERSION not set" +else + echo "NODE_VERSION is set to $NODE_VERSION" +fi + +if [[ -z "$PROJECT_TYPE" ]]; then + echo "PROJECT_TYPE not set" +else + echo "PROJECT_TYPE is set to $PROJECT_TYPE" +fi + +if [[ -z "$SITE_HOST" ]]; then + echo "SITE_HOST not set" +else + echo "SITE_HOST is set to $SITE_HOST" +fi + +if [[ -z "$CODESPACE_NAME" ]]; then + echo "CODESPACE_NAME not set" +else + echo "CODESPACE_NAME is set to $CODESPACE_NAME" +fi +# END DEBUG STUFF + # Prepare a nice name from project name for the site title. function getTitleFromSlug() { diff --git a/.gitignore b/.gitignore index fed8b315..9a512d47 100755 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,4 @@ Thumbs.db Desktop.ini .env +setup.log From c8e2c51676f27459570a9423af9a412e6cda5546 Mon Sep 17 00:00:00 2001 From: Helen Hou-Sandi Date: Sun, 5 Sep 2021 04:22:08 +0000 Subject: [PATCH 18/26] Wait to install WP until after installing dependencies This seems to give the DB enough time to come up, although this seem pretty fragile and a little silly. --- .devcontainer/setup.sh | 43 +++++++++--------------------------------- 1 file changed, 9 insertions(+), 34 deletions(-) diff --git a/.devcontainer/setup.sh b/.devcontainer/setup.sh index 3eda55f1..9f083b06 100755 --- a/.devcontainer/setup.sh +++ b/.devcontainer/setup.sh @@ -6,37 +6,7 @@ exec 3>&1 4>&2 trap 'exec 2>&4 1>&3' 0 1 2 3 exec 1>setup.log 2>&1 -# DEBUG STUFF -if [[ -z "$SLUG" ]]; then - echo "SLUG not set" -else - echo "SLUG is set to $SLUG" -fi - -if [[ -z "$NODE_VERSION" ]]; then - echo "NODE_VERSION not set" -else - echo "NODE_VERSION is set to $NODE_VERSION" -fi - -if [[ -z "$PROJECT_TYPE" ]]; then - echo "PROJECT_TYPE not set" -else - echo "PROJECT_TYPE is set to $PROJECT_TYPE" -fi - -if [[ -z "$SITE_HOST" ]]; then - echo "SITE_HOST not set" -else - echo "SITE_HOST is set to $SITE_HOST" -fi - -if [[ -z "$CODESPACE_NAME" ]]; then - echo "CODESPACE_NAME not set" -else - echo "CODESPACE_NAME is set to $CODESPACE_NAME" -fi -# END DEBUG STUFF +SITE_HOST="https://${CODESPACE_NAME}-8080.githubpreview.dev" # Prepare a nice name from project name for the site title. function getTitleFromSlug() @@ -47,16 +17,15 @@ function getTitleFromSlug() echo "${___slug[@]^}" } -echo "Setting up WordPress" +echo "Downloading WordPress" cd /var/www/html rm -f wp-config.php wp core download --force + wp config create --dbhost="db" --dbname="$MYSQL_DATABASE" --dbuser="$MYSQL_USER" --dbpass="$MYSQL_PASSWORD" --skip-check -wp db reset --yes -wp core install --url="$SITE_HOST:8080" --title="$(getTitleFromSlug) Development" --admin_user="$ADMIN_USER" --admin_email="$ADMIN_EMAIL" --admin_password="$ADMIN_PASS" --skip-email echo "Install project dependencies" @@ -83,6 +52,12 @@ then composer install fi +echo "Setting up WordPress at $SITE_HOST" + +wp db check +wp db reset --yes +wp core install --url="$SITE_HOST" --title="$(getTitleFromSlug) Development" --admin_user="$ADMIN_USER" --admin_email="$ADMIN_EMAIL" --admin_password="$ADMIN_PASS" --skip-email + echo "Activating theme/plugin" wp $PROJECT_TYPE activate $SLUG From c0c9557a6d9ec534536b58381855c8eaddeecae0 Mon Sep 17 00:00:00 2001 From: Helen Hou-Sandi Date: Tue, 7 Sep 2021 15:36:23 -0600 Subject: [PATCH 19/26] Turn on XDEBUG --- .devcontainer/docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml index 60d9f290..b42cbf7d 100644 --- a/.devcontainer/docker-compose.yml +++ b/.devcontainer/docker-compose.yml @@ -20,7 +20,7 @@ services: image: "10up/wp-php-fpm-dev:7.4" environment: #ENABLE_XDEBUG: "${ENABLE_XDEBUG}" - ENABLE_XDEBUG: "false" + ENABLE_XDEBUG: "true" volumes: - wordpress:/var/www/html #- "../:/var/www/html/wp-content/${PROJECT_TYPE}s/${SLUG}" From 3e4cf4c3c7bb3b32c8f7a74674c981ae97a7c847 Mon Sep 17 00:00:00 2001 From: Tung Du Date: Sat, 11 Sep 2021 07:35:27 +0700 Subject: [PATCH 20/26] try: switch to wordpress image --- .devcontainer/config/nginx/default.conf | 70 ------------------- .../config/php-fpm/docker-php-ext-xdebug.ini | 8 --- .devcontainer/createEnv.sh | 43 ------------ .devcontainer/devcontainer.json | 13 +--- .devcontainer/docker-compose.yml | 68 ++++++------------ 5 files changed, 24 insertions(+), 178 deletions(-) delete mode 100755 .devcontainer/config/nginx/default.conf delete mode 100755 .devcontainer/config/php-fpm/docker-php-ext-xdebug.ini delete mode 100644 .devcontainer/createEnv.sh diff --git a/.devcontainer/config/nginx/default.conf b/.devcontainer/config/nginx/default.conf deleted file mode 100755 index 0defccf1..00000000 --- a/.devcontainer/config/nginx/default.conf +++ /dev/null @@ -1,70 +0,0 @@ -map $http_x_forwarded_proto $fe_https { - default off; - https on; -} - -# Docker DNS resolver, so we can resolve things like "elasticsearch" -resolver 127.0.0.11 valid=10s; - -server { - listen 80 default_server; - - # Doesn't really matter because default server, but this way email doesn't throw errors - server_name localhost; - - access_log /var/log/nginx/access.log; - error_log /var/log/nginx/error.log; - - root /var/www/html; - index index.php; - - if (!-e $request_filename) { - rewrite /wp-admin$ $scheme://$host$uri/ permanent; - rewrite ^(/[^/]+)?(/wp-.*) $2 last; - rewrite ^(/[^/]+)?(/.*\.php) $2 last; - } - - #location /__memcacheadmin/ { - # rewrite ^/__memcacheadmin/(.*) /$1 break; - # proxy_pass http://memcacheadmin:80; - #} - - location /__elasticsearch/ { - # Variable, so that it does not error when ES not included with the environment - set $es_host http://elasticsearch:9200; - - rewrite ^/__elasticsearch/(.*) /$1 break; - proxy_pass $es_host; - } - - location / { - try_files $uri $uri/ /index.php?$args; - } - - location ~ \.php$ { - try_files $uri =404; - fastcgi_split_path_info ^(.+\.php)(/.+)$; - - include /etc/nginx/fastcgi_params; - # Long timeout to allow more time with Xdebug - fastcgi_read_timeout 3600s; - fastcgi_buffer_size 128k; - fastcgi_buffers 4 128k; - fastcgi_pass phpfpm:9000; - fastcgi_index index.php; - fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; - fastcgi_param HTTPS $fe_https; - } - - location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ { - access_log off; log_not_found off; expires max; - - add_header Access-Control-Allow-Origin *; - #{TRY_PROXY} - } - - #{PROXY_URL} - - # This should match upload_max_filesize in php.ini - client_max_body_size 150m; -} diff --git a/.devcontainer/config/php-fpm/docker-php-ext-xdebug.ini b/.devcontainer/config/php-fpm/docker-php-ext-xdebug.ini deleted file mode 100755 index 4afd03f2..00000000 --- a/.devcontainer/config/php-fpm/docker-php-ext-xdebug.ini +++ /dev/null @@ -1,8 +0,0 @@ -# Note that Xdebug is disabled in the php container by default. If you -# wish to enable it modify the docker-compose.yml file for this project -xdebug.remote_enable = 1 -xdebug.remote_autostart = 1 -xdebug.remote_host = localhost -xdebug.profiler_enable = 0 -xdebug.profiler_output_dir = /var/www/html/ -xdebug.remote_port = 9001 diff --git a/.devcontainer/createEnv.sh b/.devcontainer/createEnv.sh deleted file mode 100644 index 6c27969e..00000000 --- a/.devcontainer/createEnv.sh +++ /dev/null @@ -1,43 +0,0 @@ -#! /bin/bash - -if test -f "style.css"; then - PROJECT_TYPE=theme -else - PROJECT_TYPE=plugin -fi - -if test -f "composer.json"; then - USE_COMPOSER=true -else - USE_COMPOSER=false -fi - -if test -f "package.json"; then - USE_NODE=true -else - USE_NODE=false -fi - -/bin/cat < .env -SLUG=$1 -PROJECT_TYPE=$PROJECT_TYPE -USE_COMPOSER=$USE_COMPOSER -USE_NODE=$USE_NODE - -# SITE_HOST=http://localhost:8080 -SITE_HOST=https://${CODESPACE_NAME}-8080.githubpreview.dev - -ADMIN_USER=admin -ADMIN_PASS=password -ADMIN_EMAIL=admin@example.com - -MYSQL_DATABASE=wordpress -MYSQL_USER=admin -MYSQL_PASSWORD=password -MYSQL_ROOT_PASSWORD=password - -PHP_VERSION=7.3 -ENABLE_XDEBUG=false - -NODE_VERSION=10 -EOM diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 2c8cc24e..3cbedde7 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,24 +1,17 @@ { "name": "${localWorkspaceFolderBasename}", "dockerComposeFile": "docker-compose.yml", - "service": "phpfpm", + "service": "wordpress", "forwardPorts": [ 8080 ], // Set *default* container specific settings.json values on container create. "settings": { - "terminal.integrated.shell.linux": "/bin/bash", "php.suggest.basic": false }, // Add the IDs of extensions you want installed when the container is created. - "extensions": [ - "bmewburn.vscode-intelephense-client", - // "felixfbecker.php-debug", - // "mtxr.sqltools", - // "mtxr.sqltools-driver-mysql" - ], + "extensions": [], "workspaceFolder": "/var/www/html/", - "postCreateCommand": "/var/www/html/wp-content/plugins/${localWorkspaceFolderBasename}/.devcontainer/setup.sh", - "initializeCommand": "bash .devcontainer/createEnv.sh ${localWorkspaceFolderBasename}", + // "postCreateCommand": "/var/www/html/wp-content/plugins/${localWorkspaceFolderBasename}/.devcontainer/setup.sh", "remoteUser": "www-data" } diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml index b42cbf7d..2c04aace 100644 --- a/.devcontainer/docker-compose.yml +++ b/.devcontainer/docker-compose.yml @@ -1,59 +1,33 @@ -version: "3" +version: '3.1' services: - nginx: - image: "nginx:latest" + + wordpress: + image: wordpress + restart: always ports: - - "8080:80" - depends_on: - - phpfpm - volumes: - - wordpress:/var/www/html - # - "../:/var/www/html/wp-content/${PROJECT_TYPE}s/${SLUG}" - - "../:/var/www/html/wp-content/plugins/simple-podcasting" - - "./config/nginx/default.conf:/etc/nginx/conf.d/default.conf:cached" - networks: - - default - restart: unless-stopped - phpfpm: - # image: "10up/wp-php-fpm-dev:${PHP_VERSION}" - image: "10up/wp-php-fpm-dev:7.4" + - 8080:80 environment: - #ENABLE_XDEBUG: "${ENABLE_XDEBUG}" - ENABLE_XDEBUG: "true" + WORDPRESS_DB_HOST: db + WORDPRESS_DB_USER: exampleuser + WORDPRESS_DB_PASSWORD: examplepass + WORDPRESS_DB_NAME: exampledb volumes: - wordpress:/var/www/html - #- "../:/var/www/html/wp-content/${PROJECT_TYPE}s/${SLUG}" - "../:/var/www/html/wp-content/plugins/simple-podcasting" - - "./config/php-fpm/docker-php-ext-xdebug.ini:/etc/php.d/docker-php-ext-xdebug.ini:cached" - depends_on: - - db - networks: - - default - restart: unless-stopped - env_file: - - ../.env + db: - image: mariadb:10.4 - expose: - - "3306" - tty: true + image: mysql:5.7 + restart: always environment: - # MYSQL_DATABASE: "${MYSQL_DATABASE}" - # MYSQL_USER: "${MYSQL_USER}" - # MYSQL_PASSWORD: "${MYSQL_PASSWORD}" - # MYSQL_ROOT_PASSWORD: "${MYSQL_ROOT_PASSWORD}" - MYSQL_DATABASE: "wordpress" - MYSQL_USER: "admin" - MYSQL_PASSWORD: "password" - MYSQL_ROOT_PASSWORD: "password" + MYSQL_DATABASE: exampledb + MYSQL_USER: exampleuser + MYSQL_PASSWORD: examplepass + MYSQL_RANDOM_ROOT_PASSWORD: '1' volumes: - - data:/var/lib/mysql - networks: - - default - restart: unless-stopped + - db:/var/lib/mysql + volumes: wordpress: - data: -networks: - default: + db: +version: "3" From c6b32c1ba6ee4bd475e8ae5cbb8785724527f589 Mon Sep 17 00:00:00 2001 From: Tung Du Date: Sat, 11 Sep 2021 14:53:20 +0700 Subject: [PATCH 21/26] ci: switch to wordpress image --- .devcontainer/devcontainer.json | 3 +- .devcontainer/docker-compose.yml | 3 +- .devcontainer/setup.sh | 68 +++++++++++++------------------- 3 files changed, 30 insertions(+), 44 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 3cbedde7..4515684a 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -12,6 +12,5 @@ // Add the IDs of extensions you want installed when the container is created. "extensions": [], "workspaceFolder": "/var/www/html/", - // "postCreateCommand": "/var/www/html/wp-content/plugins/${localWorkspaceFolderBasename}/.devcontainer/setup.sh", - "remoteUser": "www-data" + "postCreateCommand": "/var/www/html/wp-content/plugins/${localWorkspaceFolderBasename}/.devcontainer/setup.sh", } diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml index 2c04aace..0ed90513 100644 --- a/.devcontainer/docker-compose.yml +++ b/.devcontainer/docker-compose.yml @@ -17,7 +17,7 @@ services: - "../:/var/www/html/wp-content/plugins/simple-podcasting" db: - image: mysql:5.7 + image: mariadb restart: always environment: MYSQL_DATABASE: exampledb @@ -30,4 +30,3 @@ services: volumes: wordpress: db: -version: "3" diff --git a/.devcontainer/setup.sh b/.devcontainer/setup.sh index 9f083b06..d9601a33 100755 --- a/.devcontainer/setup.sh +++ b/.devcontainer/setup.sh @@ -1,13 +1,19 @@ #! /bin/bash -sudo chown www-data: -R /var/www/html +SLUG=simple-podcasting +PROJECT_TYPE=plugin + +if [[ ! -z "$CODESPACE_NAME" ]] +then + SITE_HOST="https://${CODESPACE_NAME}-8080.githubpreview.dev" +else + SITE_HOST="http://localhost:8080" +fi exec 3>&1 4>&2 trap 'exec 2>&4 1>&3' 0 1 2 3 exec 1>setup.log 2>&1 -SITE_HOST="https://${CODESPACE_NAME}-8080.githubpreview.dev" - # Prepare a nice name from project name for the site title. function getTitleFromSlug() { @@ -17,47 +23,29 @@ function getTitleFromSlug() echo "${___slug[@]^}" } -echo "Downloading WordPress" - -cd /var/www/html +# Install WP CLI +curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar +chmod +x wp-cli.phar +mv wp-cli.phar /usr/local/bin/wp -rm -f wp-config.php +# Install node +curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash +export NVM_DIR="$HOME/.nvm" +[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm +[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion +nvm install 10 -wp core download --force - -wp config create --dbhost="db" --dbname="$MYSQL_DATABASE" --dbuser="$MYSQL_USER" --dbpass="$MYSQL_PASSWORD" --skip-check - -echo "Install project dependencies" - -# Install required node version -if [[ ! -z "$NODE_VERSION" ]] && [[ "$NODE_VERSION" != "latest" ]] -then - source ~/.nvm/nvm.sh - nvm install $NODE_VERSION - nvm use $NODE_VERSION - nvm alias default $NODE_VERSION -fi - -cd /var/www/html/wp-content/${PROJECT_TYPE}s/$SLUG - -echo "Changed directory to $(pwd)" - -if [[ "$USE_NODE" == "true" ]] -then - npm install -fi - -if [[ "$USE_COMPOSER" == "true" ]] -then - composer install -fi +# Install Composer +curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer echo "Setting up WordPress at $SITE_HOST" -wp db check -wp db reset --yes -wp core install --url="$SITE_HOST" --title="$(getTitleFromSlug) Development" --admin_user="$ADMIN_USER" --admin_email="$ADMIN_EMAIL" --admin_password="$ADMIN_PASS" --skip-email +wp --allow-root db reset --yes +wp --allow-root core install --url="$SITE_HOST" --title="$(getTitleFromSlug) Development" --admin_user="admin" --admin_email="admin@example.com" --admin_password="password" --skip-email + +cd /var/www/html/wp-content/${PROJECT_TYPE}s/${SLUG}/ -echo "Activating theme/plugin" +npm i && npm run build +composer i -wp $PROJECT_TYPE activate $SLUG +wp --allow-root $PROJECT_TYPE activate $SLUG From 08589e84a73b96eefdff324a5eb32e5fbafe8aa3 Mon Sep 17 00:00:00 2001 From: Tung Du Date: Sat, 11 Sep 2021 14:59:29 +0700 Subject: [PATCH 22/26] fix: debug installing wordpress --- .devcontainer/setup.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.devcontainer/setup.sh b/.devcontainer/setup.sh index d9601a33..bb1492cf 100755 --- a/.devcontainer/setup.sh +++ b/.devcontainer/setup.sh @@ -38,14 +38,15 @@ nvm install 10 # Install Composer curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer -echo "Setting up WordPress at $SITE_HOST" - -wp --allow-root db reset --yes -wp --allow-root core install --url="$SITE_HOST" --title="$(getTitleFromSlug) Development" --admin_user="admin" --admin_email="admin@example.com" --admin_password="password" --skip-email - cd /var/www/html/wp-content/${PROJECT_TYPE}s/${SLUG}/ npm i && npm run build composer i wp --allow-root $PROJECT_TYPE activate $SLUG + +cd /var/www/html/ +echo "Setting up WordPress at $SITE_HOST" +ls +wp --allow-root db reset --yes +wp --allow-root core install --url="$SITE_HOST" --title="$(getTitleFromSlug) Development" --admin_user="admin" --admin_email="admin@example.com" --admin_password="password" --skip-email \ No newline at end of file From 11f5113a3e4daffce52e45136f33bb009d5bbcab Mon Sep 17 00:00:00 2001 From: Tung Du Date: Sat, 11 Sep 2021 15:01:58 +0700 Subject: [PATCH 23/26] fix: install git --- .devcontainer/setup.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.devcontainer/setup.sh b/.devcontainer/setup.sh index bb1492cf..67533195 100755 --- a/.devcontainer/setup.sh +++ b/.devcontainer/setup.sh @@ -23,6 +23,9 @@ function getTitleFromSlug() echo "${___slug[@]^}" } +# Install git +apt install git -y + # Install WP CLI curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar chmod +x wp-cli.phar @@ -49,4 +52,4 @@ cd /var/www/html/ echo "Setting up WordPress at $SITE_HOST" ls wp --allow-root db reset --yes -wp --allow-root core install --url="$SITE_HOST" --title="$(getTitleFromSlug) Development" --admin_user="admin" --admin_email="admin@example.com" --admin_password="password" --skip-email \ No newline at end of file +wp --allow-root core install --url="$SITE_HOST" --title="$(getTitleFromSlug) Development" --admin_user="admin" --admin_email="admin@example.com" --admin_password="password" --skip-email From 885dca05c93d0a29ed991fc0f68bf9f182532fa1 Mon Sep 17 00:00:00 2001 From: Tung Du Date: Sat, 11 Sep 2021 15:10:48 +0700 Subject: [PATCH 24/26] fix: commands order --- .devcontainer/setup.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.devcontainer/setup.sh b/.devcontainer/setup.sh index 67533195..229a130a 100755 --- a/.devcontainer/setup.sh +++ b/.devcontainer/setup.sh @@ -23,8 +23,11 @@ function getTitleFromSlug() echo "${___slug[@]^}" } -# Install git -apt install git -y +# Install basic dev tools +apt update +apt upgrade -y +apt install -y git +apt install -y zip # Install WP CLI curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar @@ -41,15 +44,15 @@ nvm install 10 # Install Composer curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer +# Install dependencies cd /var/www/html/wp-content/${PROJECT_TYPE}s/${SLUG}/ - npm i && npm run build composer i -wp --allow-root $PROJECT_TYPE activate $SLUG - +# Install WordPress and activate the plugin/theme. cd /var/www/html/ echo "Setting up WordPress at $SITE_HOST" ls wp --allow-root db reset --yes wp --allow-root core install --url="$SITE_HOST" --title="$(getTitleFromSlug) Development" --admin_user="admin" --admin_email="admin@example.com" --admin_password="password" --skip-email +wp --allow-root $PROJECT_TYPE activate $SLUG From 3805da8eedceecd6ebee9acc3bc3e1ba05851f32 Mon Sep 17 00:00:00 2001 From: Tung Du Date: Thu, 7 Oct 2021 16:36:59 +0700 Subject: [PATCH 25/26] build image when starting the devcontainer --- .devcontainer/Dockerfile | 36 ++++++++++++++++++++++++++++++++ .devcontainer/devcontainer.json | 7 ++----- .devcontainer/docker-compose.yml | 2 +- .devcontainer/setup.sh | 32 +++++++--------------------- 4 files changed, 46 insertions(+), 31 deletions(-) create mode 100644 .devcontainer/Dockerfile diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 00000000..e2f065ef --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,36 @@ +FROM wordpress + +# Allow devcontainer/Codespace use www-data as the remote user instead of root. +RUN usermod --shell /bin/bash www-data +RUN touch /var/www/.bashrc +RUN chown -R www-data: /var/www/ + +# Install git & zip +RUN apt-get update && \ + apt-get upgrade -y && \ + apt-get install -y git && \ + apt-get install -y sudo && \ + apt-get install -y zip + +# Install Xdebug +RUN pecl install "xdebug" || true \ + && docker-php-ext-enable xdebug +RUN echo "xdebug.mode=debug" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini +RUN echo "xdebug.start_with_request=yes" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini +RUN apachectl restart + +# Install Composer +RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer + +# Install WP CLI +RUN curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar && \ + chmod +x wp-cli.phar && \ + mv wp-cli.phar /usr/local/bin/wp + +# Install nvm and node +RUN su www-data -c 'curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash' +RUN su www-data -c 'export NVM_DIR="$HOME/.nvm" && [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" && nvm install --lts' + +# Allow www-data user to use sudo without password +RUN adduser www-data sudo +RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 4515684a..8e285245 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -5,12 +5,9 @@ "forwardPorts": [ 8080 ], - // Set *default* container specific settings.json values on container create. - "settings": { - "php.suggest.basic": false - }, // Add the IDs of extensions you want installed when the container is created. - "extensions": [], + "extensions": [ "felixfbecker.php-debug" ], "workspaceFolder": "/var/www/html/", "postCreateCommand": "/var/www/html/wp-content/plugins/${localWorkspaceFolderBasename}/.devcontainer/setup.sh", + "remoteUser": "www-data" } diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml index 0ed90513..63961e72 100644 --- a/.devcontainer/docker-compose.yml +++ b/.devcontainer/docker-compose.yml @@ -3,7 +3,7 @@ version: '3.1' services: wordpress: - image: wordpress + build: . restart: always ports: - 8080:80 diff --git a/.devcontainer/setup.sh b/.devcontainer/setup.sh index 229a130a..39e31ada 100755 --- a/.devcontainer/setup.sh +++ b/.devcontainer/setup.sh @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/bash SLUG=simple-podcasting PROJECT_TYPE=plugin @@ -23,26 +23,7 @@ function getTitleFromSlug() echo "${___slug[@]^}" } -# Install basic dev tools -apt update -apt upgrade -y -apt install -y git -apt install -y zip - -# Install WP CLI -curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar -chmod +x wp-cli.phar -mv wp-cli.phar /usr/local/bin/wp - -# Install node -curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash -export NVM_DIR="$HOME/.nvm" -[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm -[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion -nvm install 10 - -# Install Composer -curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer +source ~/.bashrc # Install dependencies cd /var/www/html/wp-content/${PROJECT_TYPE}s/${SLUG}/ @@ -52,7 +33,8 @@ composer i # Install WordPress and activate the plugin/theme. cd /var/www/html/ echo "Setting up WordPress at $SITE_HOST" -ls -wp --allow-root db reset --yes -wp --allow-root core install --url="$SITE_HOST" --title="$(getTitleFromSlug) Development" --admin_user="admin" --admin_email="admin@example.com" --admin_password="password" --skip-email -wp --allow-root $PROJECT_TYPE activate $SLUG +wp db reset --yes +wp core install --url="$SITE_HOST" --title="$(getTitleFromSlug) Development" --admin_user="admin" --admin_email="admin@example.com" --admin_password="password" --skip-email + +echo "Activate $SLUG" +wp $PROJECT_TYPE activate $SLUG From fdc1aaa892565f5b14ce63d2a341b7927ab07ad3 Mon Sep 17 00:00:00 2001 From: Tung Du Date: Wed, 6 Jul 2022 16:11:40 +0700 Subject: [PATCH 26/26] update setup script and debug extension --- .devcontainer/devcontainer.json | 8 +++----- .devcontainer/setup.sh | 10 ++++++++-- composer.json | 5 +++++ 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 8e285245..52620f4c 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -2,12 +2,10 @@ "name": "${localWorkspaceFolderBasename}", "dockerComposeFile": "docker-compose.yml", "service": "wordpress", - "forwardPorts": [ - 8080 - ], + "forwardPorts": [ 8080 ], // Add the IDs of extensions you want installed when the container is created. - "extensions": [ "felixfbecker.php-debug" ], + "extensions": [ "xdebug.php-debug" ], "workspaceFolder": "/var/www/html/", "postCreateCommand": "/var/www/html/wp-content/plugins/${localWorkspaceFolderBasename}/.devcontainer/setup.sh", - "remoteUser": "www-data" + "remoteUser": "www-data" } diff --git a/.devcontainer/setup.sh b/.devcontainer/setup.sh index 39e31ada..fac8dbe6 100755 --- a/.devcontainer/setup.sh +++ b/.devcontainer/setup.sh @@ -1,7 +1,11 @@ #! /bin/bash - -SLUG=simple-podcasting +CURRENT_WORKING_DIR="$(pwd)" +PROJECT_DIR="$(dirname "$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" )" +SLUG="$(basename "$PROJECT_DIR")" PROJECT_TYPE=plugin +if [ -f "$PROJECT_DIR/style.css" ]; then + PROJECT_TYPE=theme +fi if [[ ! -z "$CODESPACE_NAME" ]] then @@ -38,3 +42,5 @@ wp core install --url="$SITE_HOST" --title="$(getTitleFromSlug) Development" --a echo "Activate $SLUG" wp $PROJECT_TYPE activate $SLUG + +exit 0 diff --git a/composer.json b/composer.json index 54e18827..404152b9 100755 --- a/composer.json +++ b/composer.json @@ -21,5 +21,10 @@ "10up/wp_mock": "^0.4.2", "phpunit/phpunit": "^9.5", "phpcompatibility/phpcompatibility-wp": "*" + }, + "config": { + "allow-plugins": { + "dealerdirect/phpcodesniffer-composer-installer": true + } } }