Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
timnolte committed Sep 27, 2023
1 parent 9355f1f commit f7c07ae
Show file tree
Hide file tree
Showing 10 changed files with 82 additions and 391 deletions.
7 changes: 5 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@
"ghcr.io/devcontainers/features/node:1": {
"version": "14"
},
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
"ghcr.io/devcontainers/features/git:1": {}
"ghcr.io/devcontainers/features/docker-in-docker:2": {
"dockerDashComposeVersion": "v2"
},
"ghcr.io/devcontainers/features/git:1": {},
"ghcr.io/devcontainers/features/github-cli:1": {}
},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
Expand Down
11 changes: 11 additions & 0 deletions .devcontainer/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env sh

set -eux

echo "Installing wp-cli..."
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
sudo chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp

# Copy the welcome message
sudo cp .devcontainer/welcome-message.txt /usr/local/etc/vscode-dev-containers/first-run-notice.txt
24 changes: 24 additions & 0 deletions .devcontainer/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env sh

set -eux

if [ -z ${CODESPACE_NAME+x} ]; then
SITE_HOST="http://localhost:8080"
else
SITE_HOST="https://${CODESPACE_NAME}-8080.${GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN}"
fi

PLUGIN_DIR=/workspaces/openid-connect-generic

# Install Composer dependencies.
cd "${PLUGIN_DIR}"
composer install

# Install Composer dependencies.
cd "${PLUGIN_DIR}"
npm ci

# Setup the WordPress environment.
cd /var/www/html
echo "Setting up WordPress at $SITE_HOST"
wp core install --url="$SITE_HOST" --title="WordPress Trunk" --admin_user="admin" --admin_email="[email protected]" --admin_password="password" --skip-email
6 changes: 6 additions & 0 deletions .devcontainer/welcome-message.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
👋 Welcome to "OpenID Connect for WP Development" in Codespaces!

🛠️ Your environment is fully setup with all the required software.

🚀 To get started, wait for the "postCreateCommand" to finish setting things up, then open the portforwarded URL and append '/wp-admin'.

32 changes: 32 additions & 0 deletions dev-cli
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env sh
## Description: Run local development commands.
## Usage: ./dev-cli [flags] [command]
## Example: "./dev-cli phpcs"

WORKSPACE_DIR=./

# Check for the devcontainer CLI.
# TODO: Add a devcontainer CLI check and provide a docker compose fallback.

case $1 in
build)
devcontainer --workspace-folder ${WORKSPACE_DIR} build "${@:2}"
;;
start)
devcontainer --workspace-folder ${WORKSPACE_DIR} up "${@:2}"
;;
composer)
devcontainer exec --workspace-folder ${WORKSPACE_DIR} composer "${@:2}"
;;
npm)
devcontainer exec --workspace-folder ${WORKSPACE_DIR} npm "${@:2}"
;;
phpcs|phpcbf|phpstan|phpunit)
devcontainer exec --workspace-folder ${WORKSPACE_DIR} composer "$@"
;;
"")
echo "Usage: ./dev-cli [flags] [command]"
;;
*)
;;
esac
13 changes: 4 additions & 9 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ services:
app:
image: wordpressdevelop/php:8.0-fpm
restart: always
working_dir: /var/www/html
working_dir: /app
depends_on:
- db
environment:
Expand All @@ -16,10 +16,7 @@ services:
WORDPRESS_DB_USER: wordpress_test
WORDPRESS_DB_PASSWORD: wordpress_test
volumes:
- ./wordpress:/var/www/html/wp:cached
- .:/var/www/html/wp-content/plugins/daggerhart-openid-connect-generic:cached
- ./tools/local-env/mu-plugins:/var/www/html/wp-content/mu-plugins:cached
- ./tools/local-env/wp-config.dev.php:/var/www/html/wp-config.php:cached
- ../..:/workspaces:cached
- ~/.composer:/root/.composer:cached
networks:
- oidcwp-net
Expand All @@ -38,10 +35,8 @@ services:
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
volumes:
- ./wordpress:/var/www/html/wp:cached
- .:/var/www/html/wp-content/plugins/daggerhart-openid-connect-generic:cached
- ./tools/local-env/mu-plugins:/var/www/html/wp-content/mu-plugins:cached
- ./tools/local-env/wp-config.dev.php:/var/www/html/wp-config.php:cached
- ./tools/local-env:/var/www/html:cached
- .:/var/www/html/wp-content/plugins/daggerhart-openid-connect-generic:cached,ro
networks:
- oidcwp-net

Expand Down
133 changes: 0 additions & 133 deletions tools/local-env/phpunit-wp-config.php

This file was deleted.

File renamed without changes.
Loading

0 comments on commit f7c07ae

Please sign in to comment.