Skip to content
Open
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
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
PHP_VERSION=8.1

# WordPress Configuration
WORDPRESS_VERSION=6.4
WORDPRESS_VERSION=6
WORDPRESS_DEBUG=1
WORDPRESS_DEBUG_LOG=1
WORDPRESS_DEBUG_DISPLAY=0
Expand Down
99 changes: 46 additions & 53 deletions .github/workflows/docker-build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Docker Build & Test

on:
push:
branches: [ main ]
branches: [ main, multi-instance-support ]
pull_request:
branches: [ main ]
branches: [ main, multi-instance-support ]
schedule:
# Run weekly on Monday at 00:00 UTC to catch dependency issues
- cron: '0 0 * * 1'
Expand All @@ -26,34 +26,27 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Create .env file
run: |
cp .env.example .env
sed -i "s/PHP_VERSION=8.1/PHP_VERSION=${{ matrix.php-version }}/" .env
- name: Make woocker script executable
run: chmod +x woocker

# For PHP 7.4, use wordpress:php7.4-apache (no version pinning)
if [ "${{ matrix.php-version }}" = "7.4" ]; then
echo "WORDPRESS_IMAGE_TAG=wordpress:php7.4-apache" >> .env
fi
- name: Create Test Instance
run: ./woocker create ci-test --php ${{ matrix.php-version }}

cat .env
- name: Start Instance
run: ./woocker start ci-test

- name: Generate SSL certificates
- name: Export Env Vars for CI
# We need to export variables so subsequent docker compose commands work
run: |
mkdir -p ssl
openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
-keyout ssl/key.pem \
-out ssl/cert.pem \
-subj "/C=US/ST=State/L=City/O=Development/CN=localhost" \
-addext "subjectAltName=DNS:localhost,IP:127.0.0.1"

- name: Build Docker images
run: docker compose build
timeout-minutes: 10

- name: Start containers
run: docker compose up -d
timeout-minutes: 5
echo "INSTANCE_PATH=$(pwd)/instances/ci-test" >> $GITHUB_ENV
echo "PLUGINS_PATH=$(pwd)/plugins" >> $GITHUB_ENV
echo "COMPOSE_PROJECT_NAME=woocker_ci-test" >> $GITHUB_ENV
# Source the .env to get ports
set -a
source instances/ci-test/.env
set +a
echo "WORDPRESS_PORT=$WORDPRESS_PORT" >> $GITHUB_ENV
echo "PMA_PORT=$PMA_PORT" >> $GITHUB_ENV

- name: Wait for services to be ready
run: |
Expand All @@ -63,7 +56,7 @@ jobs:

echo "Waiting for WordPress..."
sleep 10
timeout 60 bash -c 'until curl -f http://localhost:8000 > /dev/null 2>&1; do sleep 2; done'
timeout 60 bash -c "until curl -f http://localhost:$WORDPRESS_PORT > /dev/null 2>&1; do sleep 2; done"
echo "WordPress is ready!"

- name: Check container status
Expand All @@ -72,7 +65,7 @@ jobs:
- name: Verify WordPress installation
run: |
# Check if WordPress responds
response=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8000)
response=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:$WORDPRESS_PORT)
if [ "$response" -ne "200" ] && [ "$response" -ne "301" ] && [ "$response" -ne "302" ]; then
echo "WordPress is not responding correctly (HTTP $response)"
exit 1
Expand Down Expand Up @@ -114,7 +107,7 @@ jobs:

- name: Check PHPMyAdmin
run: |
response=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8080)
response=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:$PMA_PORT)
if [ "$response" -ne "200" ]; then
echo "PHPMyAdmin is not responding correctly (HTTP $response)"
exit 1
Expand All @@ -131,30 +124,40 @@ jobs:

- name: Stop containers
if: always()
run: docker compose down -v
run: ./woocker remove ci-test --force

test-setup-script:
name: Test Setup Script
test-init-command:
name: Test Init Command
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Make setup script executable
run: chmod +x setup.sh
- name: Make woocker script executable
run: chmod +x woocker

- name: Create and Start Instance
run: |
./woocker create ci-init
./woocker start ci-init

- name: Export Env Vars for CI
run: |
echo "INSTANCE_PATH=$(pwd)/instances/ci-init" >> $GITHUB_ENV
echo "PLUGINS_PATH=$(pwd)/plugins" >> $GITHUB_ENV
echo "COMPOSE_PROJECT_NAME=woocker_ci-init" >> $GITHUB_ENV
set -a
source instances/ci-init/.env
set +a
echo "WORDPRESS_PORT=$WORDPRESS_PORT" >> $GITHUB_ENV

- name: Run setup script
run: ./setup.sh
- name: Run Init Command
run: ./woocker init ci-init
timeout-minutes: 15
env:
CI: true

- name: Verify WordPress is installed
run: |
# Wait a bit for WordPress to fully initialize
sleep 5

# Check if WordPress core is installed
if docker compose exec -T wordpress wp core is-installed --allow-root; then
echo "✓ WordPress is installed"
Expand Down Expand Up @@ -207,18 +210,9 @@ jobs:
exit 1
fi

- name: Verify VS Code config exists
run: |
if [ -f ".vscode/launch.json" ]; then
echo "✓ VS Code launch.json created"
else
echo "✗ VS Code launch.json not found"
exit 1
fi

- name: Test WordPress site accessibility
run: |
response=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8000)
response=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:$WORDPRESS_PORT)
if [ "$response" -eq "200" ] || [ "$response" -eq "301" ] || [ "$response" -eq "302" ]; then
echo "✓ WordPress site is accessible (HTTP $response)"
else
Expand All @@ -229,12 +223,11 @@ jobs:
- name: View logs on failure
if: failure()
run: |
echo "=== Setup Script Output ==="
echo "=== WordPress Logs ==="
docker compose logs wordpress
echo "=== Database Logs ==="
docker compose logs db

- name: Cleanup
if: always()
run: docker compose down -v
run: ./woocker remove ci-init --force
17 changes: 12 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,19 @@ tests-output/
phpunit.xml.dist

# WordPress - ignore everything except custom plugins
# Old structure (deprecated but kept for history if needed)
wordpress/
!wordpress/wp-content/
!wordpress/wp-content/plugins/
wordpress/wp-content/plugins/*
!wordpress/wp-content/plugins/.gitkeep
# Add your custom plugins here with !wordpress/wp-content/plugins/your-plugin-name/

# New Multi-Instance Structure
instances/
!instances/.gitkeep

# Shared Plugins - Track these!
plugins/
!plugins/.gitkeep
# Ignore everything inside plugins except specific ones if needed,
# but usually we want to track shared plugins.
# If you want to ignore specific plugins, add them here.

# Logs
*.log
Expand Down
13 changes: 6 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
ARG WORDPRESS_VERSION=6.4
ARG PHP_VERSION=8.1
# For PHP 7.4, use wordpress:php7.4-apache (no version pinning)
# For PHP 8.0+, use wordpress:6.4-php8.x-apache (version pinned)
ARG WORDPRESS_IMAGE_TAG
FROM ${WORDPRESS_IMAGE_TAG:-wordpress:${WORDPRESS_VERSION}-php${PHP_VERSION}-apache}
ARG WORDPRESS_IMAGE=wordpress:${WORDPRESS_VERSION}-php${PHP_VERSION}-apache

FROM ${WORDPRESS_IMAGE}

# Install system dependencies
RUN apt-get update && apt-get install -y \
Expand Down Expand Up @@ -35,11 +34,11 @@ RUN a2ensite default-ssl
# PHP 8.3+: Xdebug 3.3.x
RUN PHP_VERSION=$(php -r "echo PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;") && \
if [ "$PHP_VERSION" = "7.4" ]; then \
pecl install xdebug-3.1.6; \
pecl install xdebug-3.1.6; \
elif [ "$PHP_VERSION" = "8.3" ]; then \
pecl install xdebug-3.3.2; \
pecl install xdebug-3.3.2; \
else \
pecl install xdebug-3.2.2; \
pecl install xdebug-3.2.2; \
fi && \
docker-php-ext-enable xdebug

Expand Down
Loading