Skip to content

Version 5.0.0 #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
FROM php:8.4-apache

RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini"
# set php memory limit to -1
RUN sed -i 's/memory_limit = .*/memory_limit = -1/' $PHP_INI_DIR/php.ini
# Enable .htaccess files & mod_rewrite
RUN sed -i '/<Directory \/var\/www\/>/,/<\/Directory>/ s/AllowOverride None/AllowOverride all/' /etc/apache2/apache2.conf
RUN a2enmod rewrite

#Most of this comes directly from the WordPress docker image
#We don't inherit from it becase it has a VOLUME that causes issues
RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends ghostscript git less ssh-client mariadb-client; \
rm -rf /var/lib/apt/lists/*

# install the PHP extensions, including XDebug
RUN set -ex; \
apt-get update; \
apt-get install -y --no-install-recommends \
libfreetype6-dev \
libjpeg-dev \
libmagickwand-dev \
libpng-dev \
libzip-dev \
; \
docker-php-ext-configure gd --with-freetype --with-jpeg; \
docker-php-ext-install -j "$(nproc)" \
bcmath \
exif \
gd \
mysqli \
opcache \
zip \
; \
pecl install imagick-3.8.0; \
pecl install xdebug-3.4.3; \
pear install PHP_CodeSniffer; \
docker-php-ext-enable imagick xdebug;\
rm -rf /var/lib/apt/lists/*

#XDebug settings
RUN echo "[XDebug]\nxdebug.mode = debug\nxdebug.start_with_request = 1" > $PHP_INI_DIR/conf.d/xdebug.ini

#WP recommended PHP settings
RUN { \
echo 'opcache.memory_consumption=128'; \
echo 'opcache.interned_strings_buffer=8'; \
echo 'opcache.max_accelerated_files=4000'; \
echo 'opcache.revalidate_freq=2'; \
echo 'opcache.fast_shutdown=1'; \
} > /usr/local/etc/php/conf.d/opcache-recommended.ini

#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 Composer
WORKDIR /tmp
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \
&& php composer-setup.php --quiet --install-dir=/usr/local/bin --filename=composer

#add vscode user
RUN useradd -ms /bin/bash vscode \
&& usermod -aG www-data vscode

WORKDIR /var/www/html
USER www-data

#Download WP
RUN wp core download

#add dirs for plugin and theme dev
RUN mkdir -p /var/www/html/wp-content/plugins/imagekit

USER root
RUN chown -R www-data:www-data /var/www/html/
RUN chmod g+w -R /var/www/html/
RUN find /var/www/html/ -type d -exec chmod g+s {} \;
Empty file.
17 changes: 17 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "WordPress",
"dockerComposeFile": "docker-compose.yml",
"service": "wordpress",
"workspaceFolder": "/var/www/html/wp-content/plugins/imagekit",
"customizations": {
"vscode": {
"extensions": ["felixfbecker.php-pack", "wordpresstoolbox.wordpress-toolbox", "johnbillion.vscode-wordpress-hooks"],
"settings": {
"terminal.integrated.shell.linux": "/bin/bash",
"php.suggest.basic": false
}
}
},
"postCreateCommand": ".devcontainer/wp-setup.sh",
"remoteUser": "vscode"
}
38 changes: 38 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
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/imagekit
- ./.idea:/var/www/html/wp-content/plugins/imagekit/.idea
#- ../:/var/www/html/wp-content/themes/theme-dev

db:
image: mariadb:11.4
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:
45 changes: 45 additions & 0 deletions .devcontainer/wp-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#! /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=""

#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

#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