Skip to content
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

build(bin/stack) make WP container dynamic #670

Merged
merged 3 commits into from
Nov 10, 2023
Merged
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
1 change: 1 addition & 0 deletions .github/workflows/static-analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
- "src/**"
- "tests/**"
- "composer.json"
- ".github/workflows/static-analysis.yaml"
jobs:
lint-on-56:
name: PHP 5.6 lint
Expand Down
21 changes: 14 additions & 7 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
- "src/**"
- "tests/**"
- "composer.json"
- ".github/workflows/test.yaml"
jobs:
test_codeception_4_php_56:
name: PHP 5.6, Codeception 4
Expand All @@ -26,6 +27,9 @@ jobs:
build-args: |
PHP_VERSION=5.6
WP_IMAGE_VERSION=5
WP_IMAGE_NAME=php-5.6apache
WP_PHP_VERSION=5.6
WP_DOCKERFILE=Dockerfile-PHP-5.6
TARGET=wordpress
USER_UID=33
USER_GID=33
Expand Down Expand Up @@ -72,15 +76,18 @@ jobs:
uses: docker/build-push-action@v4
with:
context: containers/php
file: containers/php/Dockerfile-PHP-5.6
file: containers/php/Dockerfile
push: false
tags: lucatume/wp-browser-v3-wordpress:php5.6-apache
cache-from: type=gha,scope=5.6
cache-to: type=gha,mode=max,scope=5.6
tags: lucatume/wp-browser-v3-wordpress:php-apache
cache-from: type=gha,scope=${{ matrix.php_version }}
cache-to: type=gha,mode=max,scope=${{ matrix.php_version }}
load: true
build-args: |
PHP_VERSION=5.6
WP_IMAGE_VERSION=5
PHP_VERSION=${{ matrix.php_version }}
WP_IMAGE_VERSION=6
WP_IMAGE_NAME=php-apache
WP_PHP_VERSION=${{ matrix.php_version }}
WP_DOCKERFILE=Dockerfile
TARGET=wordpress
USER_UID=33
USER_GID=33
Expand All @@ -103,7 +110,7 @@ jobs:
USER_GID=33
USER_NAME=www-data
- name: Build
run: bin/stack -p5.6 build
run: bin/stack -p${{ matrix.php_version }} build
- name: Cache Composer dependencies
uses: actions/cache@v3
with:
Expand Down
20 changes: 17 additions & 3 deletions bin/stack
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,20 @@ fi
TEST_DATABASES=(wordpress test_subdir test_subdomain test_empty)

export PHP_VERSION=${PHP_VERSION:-8.0}

# If the PHP_VERSION is 5.6 export WP_IMAGE_NAME=php5.6-apache, else export WP_IMAGE_NAME=php-apache.
if [ "${PHP_VERSION}" = "5.6" ]; then
export WP_IMAGE_NAME="php5.6-apache"
export WP_IMAGE_VERSION="5"
export WP_PHP_VERSION="5.6"
export WP_DOCKERFILE="Dockerfile-PHP-5.6"
else
export WP_IMAGE_NAME="php-apache"
export WP_IMAGE_VERSION="6"
export WP_PHP_VERSION="8.0"
export WP_DOCKERFILE="Dockerfile"
fi

export USER_UID=$(id -u)
export USER_GID=$(id -g)
export USER_NAME=$(id -un)
Expand Down Expand Up @@ -116,7 +130,7 @@ function ensure_twentytwentyone_theme() {
fi

# Download and install the twentytwentyone theme.
curl -sSL https://downloads.wordpress.org/theme/twentytwentyone.2.1.zip -o "${PWD}/var/wordpress/wp-content/themes/twentytwentyone.zip" || exit 1
curl -sSL https://downloads.wordpress.org/theme/twentytwentyone.2.0.zip -o "${PWD}/var/wordpress/wp-content/themes/twentytwentyone.zip" || exit 1
unzip -q "${PWD}/var/wordpress/wp-content/themes/twentytwentyone.zip" -d "${PWD}/var/wordpress/wp-content/themes/" || exit 1
}

Expand Down Expand Up @@ -163,7 +177,7 @@ function run_wp_cli_command() {
--network "wpbrowser_v3" \
-w /var/www/html \
-u "${USER_UID}:${USER_GID}" \
"lucatume/wp-browser-v3-wordpress:php5.6-apache" \
"lucatume/wp-browser-v3-wordpress:${WP_IMAGE_NAME}" \
wp --allow-root --url=http://wordpress.test --path=/var/www/html "$@"
}

Expand All @@ -184,7 +198,7 @@ function ensure_wordpress_configured() {
--network "wpbrowser_v3" \
-w /var/www/html \
-u "${USER_UID}:${USER_GID}" \
"lucatume/wp-browser-v3-wordpress:php5.6-apache" \
"lucatume/wp-browser-v3-wordpress:${WP_IMAGE_NAME}" \
bash -c "wp --allow-root core config --dbname=wordpress --dbuser=root --dbpass=password --dbhost=database --dbprefix=wp_ --extra-php <<PHP
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
Expand Down
8 changes: 4 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ services:
user: "${USER_UID}:${USER_GID}"
sysctls:
- net.ipv4.ip_unprivileged_port_start=0
image: lucatume/wp-browser-v3-wordpress:php5.6-apache
image: lucatume/wp-browser-v3-wordpress:${WP_IMAGE_NAME:-php-apache}
build:
context: ./containers/php
dockerfile: "Dockerfile-PHP-5.6"
dockerfile: "${WP_DOCKERFILE:-Dockerfile}"
args:
PHP_VERSION: "5.6"
WP_IMAGE_VERSION: "5"
PHP_VERSION: "${WP_PHP_VERSION:-7.4}"
WP_IMAGE_VERSION: "${WP_IMAGE_VERSION:-6}"
USER_UID: "${USER_UID:-33}"
USER_GID: "${USER_GID:-33}"
USER_NAME: "${USER_NAME:-www-data}"
Expand Down
Loading