diff --git a/.devcontainer/.env.example b/.devcontainer/.env.example new file mode 100644 index 000000000..99135d845 --- /dev/null +++ b/.devcontainer/.env.example @@ -0,0 +1,19 @@ +DB_NAME=wordpress +DB_USER=wordpress +DB_PASSWORD=password +DB_HOST=database +DB_PREFIX=wp_ + +WP_ENV=development +WP_HOME=http://localhost:8080 +WP_SITEURL=${WP_HOME}/wp + +# 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/.devcontainer/.gitignore b/.devcontainer/.gitignore new file mode 100644 index 000000000..215d7c87c --- /dev/null +++ b/.devcontainer/.gitignore @@ -0,0 +1,2 @@ +docker-compose.override.yml +.env diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 000000000..f5f354f69 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,19 @@ +FROM php:8.1-fpm + +RUN apt-get update && apt-get install -y \ + mariadb-client \ + zip \ + unzip \ + && docker-php-ext-install -j$(nproc) \ + mysqli \ + pdo_mysql \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer + +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 + +WORKDIR /roots/app diff --git a/.devcontainer/config/nginx.conf b/.devcontainer/config/nginx.conf new file mode 100644 index 000000000..59deb3912 --- /dev/null +++ b/.devcontainer/config/nginx.conf @@ -0,0 +1,15 @@ +server { + listen 80; + root /roots/app/web; + index index.php; + + location / { + try_files $uri $uri/ /index.php$is_args$args; + } + + location ~ \.php$ { + fastcgi_pass app:9000; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + include fastcgi_params; + } +} diff --git a/.devcontainer/config/php.ini b/.devcontainer/config/php.ini new file mode 100644 index 000000000..0bdfa9d13 --- /dev/null +++ b/.devcontainer/config/php.ini @@ -0,0 +1,7 @@ +memory_limit = 256M +max_execution_time = 120 +upload_max_filesize = 64M +post_max_size = 64M +error_reporting = E_ALL +display_errors = Off +log_errors = On diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 000000000..c1d59fbb2 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,11 @@ +{ + "name": "Bedrock Development", + "dockerComposeFile": ["docker-compose.yml"], + "service": "app", + "workspaceFolder": "/roots/app", + "forwardPorts": [8080], + "remoteEnv": { + "WP_ENV": "development" + }, + "postCreateCommand": "cp -n /roots/app/.devcontainer/.env.example /roots/app/.env" +} diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml new file mode 100644 index 000000000..c23834a0e --- /dev/null +++ b/.devcontainer/docker-compose.yml @@ -0,0 +1,38 @@ +services: + app: + build: + context: . + dockerfile: Dockerfile + volumes: + - ..:/roots/app + - ./config/php.ini:/usr/local/etc/php/conf.d/bedrock.ini + networks: + - bedrock + depends_on: + - database + + web: + image: nginx:alpine + ports: + - '8080:80' + volumes: + - ..:/roots/app:ro + - ./config/nginx.conf:/etc/nginx/conf.d/default.conf:ro + depends_on: + - app + networks: + - bedrock + + database: + image: mariadb:10 + environment: + MYSQL_DATABASE: wordpress + MYSQL_USER: wordpress + MYSQL_PASSWORD: password + MYSQL_ROOT_PASSWORD: password + networks: + - bedrock + +networks: + bedrock: + driver: bridge diff --git a/.gitattributes b/.gitattributes index db8a36b25..0c36f6475 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,4 +1,4 @@ -/.circleci export-ignore /.editorconfig export-ignore +/.devcontainer export-ignore /.gitattributes export-ignore /.github export-ignore diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index d226e2e98..a67f42787 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -3,23 +3,24 @@ name: Integration on: [push, pull_request, workflow_dispatch] jobs: - build: + test: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - with: - repository: roots/bedrock-docker - ref: main - path: bedrock-docker - - uses: actions/checkout@v4 - with: - path: bedrock-docker/bedrock - - name: Build and run - run: docker compose up --build -d - working-directory: bedrock-docker - - name: Wait for install - run: sleep 30 - working-directory: bedrock-docker - - name: Verify install - run: curl -s http://127.0.0.1 | grep "bedrock" - working-directory: bedrock-docker + - uses: actions/checkout@v4 + + - name: Copy .env file + working-directory: .devcontainer + run: cp .env.example ../.env + + - name: Start dev container and test + uses: devcontainers/ci@v0.3 + with: + configFile: .devcontainer/devcontainer.json + runCmd: | + composer install + wp core install --url=http://localhost:8080 --title=Bedrock --admin_user=admin --admin_password=admin --admin_email=admin@example.com --skip-email + + - name: Verify installation + run: | + sleep 30 # Give web server a moment to start + curl -s http://localhost:8080 | grep "<title>Bedrock"