Skip to content

Commit

Permalink
Merge branch 'main' of github.com:blonestar/wp-theme-vite-tailwind
Browse files Browse the repository at this point in the history
  • Loading branch information
blonestar committed Dec 14, 2022
2 parents 609ac89 + e5a9483 commit 7e39bda
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 0 deletions.
28 changes: 28 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "WordPress",

"dockerComposeFile": "docker-compose.yml",
"service": "wordpress",

// Uncomment the appropriate line depending on plugin vs theme development.
// This should match the active volume mount in docker-compose.yml
//"workspaceFolder": "/var/www/html/wp-content/plugins/plugin-dev",
"workspaceFolder": "/var/www/html/wp-content/themes/vite-tailwind-theme",

// Set *default* container specific settings.json values on container create.
"settings": {
"terminal.integrated.shell.linux": "/bin/bash",
"php.suggest.basic": false // avoids duplicate autocomplete
},

// Add the IDs of any extensions you want installed.
"extensions": [
"felixfbecker.php-pack",
"wordpresstoolbox.wordpress-toolbox",
"johnbillion.vscode-wordpress-hooks"
],

// Sets up WordPress on container start.
"postCreateCommand": ".devcontainer/wp-setup.sh",
"remoteUser": "vscode"
}
37 changes: 37 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
version: '3'
services:
wordpress:
build: ./
ports:
- 8080:80
depends_on:
- db
environment:
WORDPRESS_DB_HOST: db
WORDPRESS_DB_USER: wp_user
WORDPRESS_DB_PASSWORD: wp_pass
WORDPRESS_DB_NAME: wordpress
WORDPRESS_DEBUG: 1
links:
- db
volumes:
#Swap the folder path for plugin vs theme development
- wordpress:/var/www/html
#- ../:/var/www/html/wp-content/plugins/plugin-dev
- ../:/var/www/html/wp-content/themes/vite-tailwind-theme

db:
image: mariadb:10
environment:
MYSQL_DATABASE: wordpress
MYSQL_USER: wp_user
MYSQL_PASSWORD: wp_pass
MYSQL_RANDOM_ROOT_PASSWORD: '1'
ports:
- 3306:3306
volumes:
- data:/var/lib/mysql

volumes:
wordpress:
data:
47 changes: 47 additions & 0 deletions .devcontainer/wp-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#! /bin/bash

#Site configuration options
SITE_TITLE="Dev Site"
ADMIN_USER=admin
ADMIN_PASS=password
ADMIN_EMAIL="[email protected]"
#Space-separated list of plugin ID's to install and activate
PLUGINS="advanced-custom-fields"

#Set to true to wipe out and reset your wordpress install (on next container rebuild)
WP_RESET=true


echo "Setting up WordPress"
DEVDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
cd /var/www/html;
if $WP_RESET ; then
echo "Resetting WP"
wp plugin delete $PLUGINS
wp db reset --yes
rm wp-config.php;
fi

if [ ! -f wp-config.php ]; then
echo "Configuring";
wp config create --dbhost="db" --dbname="wordpress" --dbuser="wp_user" --dbpass="wp_pass" --skip-check;
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 install $PLUGINS --activate
#TODO: Only activate plugin if it contains files - i.e. might be developing a theme instead
#wp plugin activate plugin-dev
wp theme activate vite-tailwind-theme

#Data import
cd $DEVDIR/data/
for f in *.sql; do
wp db import $f
done

cp -r plugins/* /var/www/html/wp-content/plugins
for p in plugins/*; do
wp plugin activate $(basename $p)
done

else
echo "Already configured"
fi

0 comments on commit 7e39bda

Please sign in to comment.