diff --git a/.gitignore b/.gitignore index 6d57748..374a098 100644 --- a/.gitignore +++ b/.gitignore @@ -1,28 +1,26 @@ # Application -/bedrock/web/app/plugins/* -/bedrock/!web/app/plugins/.gitkeep -/bedrock/web/app/mu-plugins/*/ -/bedrock/web/app/upgrade -/bedrock/web/app/uploads/* -/bedrock/!web/app/uploads/.gitkeep +/src/web/app/plugins/* +/src/!web/app/plugins/.gitkeep +/src/web/app/mu-plugins/* +/src/web/app/upgrade +/src/web/app/uploads/* +/src/!web/app/uploads/.gitkeep # WordPress -/bedrock/web/wp -/bedrock/web/.htaccess +/src/web/wp +/src/web/.htaccess # Logs -*.log +/src/*.log # Dotenv -.env -.env.* -!.env.example -/bedrock/.env -/bedrock/.env.* -/bedrock/!.env.example +/src/.env +/src/.env.* +/src/!.env.example +/src/!.env.sample # Composer -/bedrock/vendor +/src/vendor # WP-CLI -wp-cli.local.yml +/src/wp-cli.local.yml diff --git a/Dockerfile b/Dockerfile index 35b4c3a..085879d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,13 @@ -FROM php:8.1-apache +FROM wordpress:5.8.2-php8.0-fpm +# TODO: use renovate-bot to send pull requests on upstream image updates -COPY entrypoint-wordpress.sh /usr/local/bin/ +COPY --from=composer:2.1 /usr/bin/composer /usr/bin/composer +# TODO: use renovate-bot to send pull requests on upstream image updates -COPY apache-docker.conf /etc/apache2/sites-enabled/ +RUN apt-get update && apt-get install -y \ + git \ + unzip && \ + rm -rf /var/lib/apt/lists/* -ENTRYPOINT /usr/local/bin/entrypoint-wordpress.sh +# Upstream Wordpress entrypoint, adapted for Composer use +COPY docker-entrypoint.sh /usr/local/bin/ diff --git a/README.md b/README.md new file mode 100644 index 0000000..63d3c97 --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +1. Clone this repository +2. Copy `src/.env.example` to `src/.env` +3. Run `cd src && composer install` +4. Run `docker-compose up` diff --git a/apache-docker.conf b/apache-docker.conf deleted file mode 100644 index bbbb5c8..0000000 --- a/apache-docker.conf +++ /dev/null @@ -1,17 +0,0 @@ - - -ServerName localhost - -ServerAdmin webmaster@localhost -DocumentRoot /var/www/html/web - -ErrorLog /var/log/apache2/error.log -CustomLog /var/log/apache2/access.log combined - - -Options Indexes FollowSymLinks -AllowOverride All -Require all granted - - - diff --git a/bedrock/.env.example b/bedrock/.env.example deleted file mode 100644 index 7de18aa..0000000 --- a/bedrock/.env.example +++ /dev/null @@ -1,28 +0,0 @@ -DB_NAME='database_name' -DB_USER='database_user' -DB_PASSWORD='database_password' - -# Optionally, you can use a data source name (DSN) -# When using a DSN, you can remove the DB_NAME, DB_USER, DB_PASSWORD, and DB_HOST variables -# DATABASE_URL='mysql://database_user:database_password@database_host:database_port/database_name' - -# Optional database variables -# DB_HOST='localhost' -# DB_PREFIX='wp_' - -WP_ENV='development' -WP_HOME='http://example.com' -WP_SITEURL="${WP_HOME}/wp" - -# Specify optional debug.log path -# WP_DEBUG_LOG='/path/to/debug.log' - -# Generate your keys here: https://roots.io/salts.html -AUTH_KEY='generateme' -SECURE_AUTH_KEY='generateme' -LOGGED_IN_KEY='generateme' -NONCE_KEY='generateme' -AUTH_SALT='generateme' -SECURE_AUTH_SALT='generateme' -LOGGED_IN_SALT='generateme' -NONCE_SALT='generateme' diff --git a/bedrock/web/app/mu-plugins/bedrock-autoloader.php b/bedrock/web/app/mu-plugins/bedrock-autoloader.php deleted file mode 100644 index 646f4a8..0000000 --- a/bedrock/web/app/mu-plugins/bedrock-autoloader.php +++ /dev/null @@ -1,16 +0,0 @@ -&2 "WordPress not found in $PWD - copying now..." + # if [ -n "$(find -mindepth 1 -maxdepth 1 -not -name wp-content)" ]; then + # echo >&2 "WARNING: $PWD is not empty! (copying anyhow)" + # fi + # sourceTarArgs=( + # --create + # --file - + # --directory /usr/src/wordpress + # --owner "$user" --group "$group" + # ) + # targetTarArgs=( + # --extract + # --file - + # ) + # if [ "$uid" != '0' ]; then + # # avoid "tar: .: Cannot utime: Operation not permitted" and "tar: .: Cannot change mode to rwxr-xr-x: Operation not permitted" + # targetTarArgs+=( --no-overwrite-dir ) + # fi + # # loop over "pluggable" content in the source, and if it already exists in the destination, skip it + # # https://github.com/docker-library/wordpress/issues/506 ("wp-content" persisted, "akismet" updated, WordPress container restarted/recreated, "akismet" downgraded) + # for contentPath in \ + # /usr/src/wordpress/.htaccess \ + # /usr/src/wordpress/wp-content/*/*/ \ + # ; do + # contentPath="${contentPath%/}" + # [ -e "$contentPath" ] || continue + # contentPath="${contentPath#/usr/src/wordpress/}" # "wp-content/plugins/akismet", etc. + # if [ -e "$PWD/$contentPath" ]; then + # echo >&2 "WARNING: '$PWD/$contentPath' exists! (not copying the WordPress version)" + # sourceTarArgs+=( --exclude "./$contentPath" ) + # fi + # done + # tar "${sourceTarArgs[@]}" . | tar "${targetTarArgs[@]}" + # echo >&2 "Complete! WordPress has been successfully copied to $PWD" + # fi + # + # wpEnvs=( "${!WORDPRESS_@}" ) + # if [ ! -s wp-config.php ] && [ "${#wpEnvs[@]}" -gt 0 ]; then + # for wpConfigDocker in \ + # wp-config-docker.php \ + # /usr/src/wordpress/wp-config-docker.php \ + # ; do + # if [ -s "$wpConfigDocker" ]; then + # echo >&2 "No 'wp-config.php' found in $PWD, but 'WORDPRESS_...' variables supplied; copying '$wpConfigDocker' (${wpEnvs[*]})" + # # using "awk" to replace all instances of "put your unique phrase here" with a properly unique string (for AUTH_KEY and friends to have safe defaults if they aren't specified with environment variables) + # awk ' + # /put your unique phrase here/ { + # cmd = "head -c1m /dev/urandom | sha1sum | cut -d\\ -f1" + # cmd | getline str + # close(cmd) + # gsub("put your unique phrase here", str) + # } + # { print } + # ' "$wpConfigDocker" > wp-config.php + # if [ "$uid" = '0' ]; then + # # attempt to ensure that wp-config.php is owned by the run user + # # could be on a filesystem that doesn't allow chown (like some NFS setups) + # chown "$user:$group" wp-config.php || true + # fi + # break + # fi + # done + # fi +fi + +exec "$@" diff --git a/entrypoint-wordpress.sh b/entrypoint-wordpress.sh deleted file mode 100755 index c2548cd..0000000 --- a/entrypoint-wordpress.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -if [ -n "$PHP_EXTENSIONS" ]; then - docker-php-ext-install "$PHP_EXTENSIONS" -fi - -chown -R www-data:www-data /var/www/html - -if [ -n "$*" ]; then - "$@" -fi - -# Upstream ENTRYPOINT -# https://github.com/docker-library/wordpress/blob/master/php7.4/apache/Dockerfile#L120 -apache2-foreground diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..40442dd --- /dev/null +++ b/nginx.conf @@ -0,0 +1,48 @@ +server { + listen 80 default_server; + listen [::]:80 default_server; + + server_name _; + + client_max_body_size 128M; + + gzip on; + gzip_proxied any; + gzip_types text/plain text/xml text/css application/x-javascript; + gzip_vary on; + gzip_disable "MSIE [1-6]\.(?!.*SV1)"; + + sendfile on; + sendfile_max_chunk 512k; + + root /app/web; + + access_log off; + + location / { + include /etc/nginx/mime.types; + + root /app/web; + index index.html index.htm index.php; + + try_files $uri $uri/ /index.php?q=$uri&$args; + } + + location ~ .php$ { + include fastcgi.conf; + + fastcgi_read_timeout 300; + fastcgi_pass php:9000; + + fastcgi_index index.php; + fastcgi_param SCRIPT_FILENAME /app/web/$fastcgi_script_name; + fastcgi_param PATH_INFO $fastcgi_script_name; + + fastcgi_param PHP_VALUE "error_log=/var/log/nginx/application_php_errors.log"; + fastcgi_buffers 16 16k; + fastcgi_buffer_size 32k; + + include fastcgi_params; + } +} + diff --git a/bedrock/CHANGELOG.md b/src/CHANGELOG.md similarity index 100% rename from bedrock/CHANGELOG.md rename to src/CHANGELOG.md diff --git a/bedrock/LICENSE.md b/src/LICENSE.md similarity index 100% rename from bedrock/LICENSE.md rename to src/LICENSE.md diff --git a/bedrock/README.md b/src/README.md similarity index 100% rename from bedrock/README.md rename to src/README.md diff --git a/bedrock/composer.json b/src/composer.json similarity index 100% rename from bedrock/composer.json rename to src/composer.json diff --git a/bedrock/composer.lock b/src/composer.lock similarity index 100% rename from bedrock/composer.lock rename to src/composer.lock diff --git a/bedrock/config/application.php b/src/config/application.php similarity index 100% rename from bedrock/config/application.php rename to src/config/application.php diff --git a/bedrock/config/environments/development.php b/src/config/environments/development.php similarity index 100% rename from bedrock/config/environments/development.php rename to src/config/environments/development.php diff --git a/bedrock/config/environments/staging.php b/src/config/environments/staging.php similarity index 100% rename from bedrock/config/environments/staging.php rename to src/config/environments/staging.php diff --git a/bedrock/phpcs.xml b/src/phpcs.xml similarity index 100% rename from bedrock/phpcs.xml rename to src/phpcs.xml diff --git a/bedrock/web/app/themes/.gitkeep b/src/web/app/themes/.gitkeep similarity index 100% rename from bedrock/web/app/themes/.gitkeep rename to src/web/app/themes/.gitkeep diff --git a/bedrock/web/index.php b/src/web/index.php similarity index 100% rename from bedrock/web/index.php rename to src/web/index.php diff --git a/bedrock/web/wp-config.php b/src/web/wp-config.php similarity index 100% rename from bedrock/web/wp-config.php rename to src/web/wp-config.php diff --git a/bedrock/wp-cli.yml b/src/wp-cli.yml similarity index 100% rename from bedrock/wp-cli.yml rename to src/wp-cli.yml