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

🔧 Add dev container #748

Merged
merged 4 commits into from
Dec 14, 2024
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
19 changes: 19 additions & 0 deletions .devcontainer/.env.example
Original file line number Diff line number Diff line change
@@ -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'
2 changes: 2 additions & 0 deletions .devcontainer/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
docker-compose.override.yml
.env
19 changes: 19 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
15 changes: 15 additions & 0 deletions .devcontainer/config/nginx.conf
Original file line number Diff line number Diff line change
@@ -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;
}
}
7 changes: 7 additions & 0 deletions .devcontainer/config/php.ini
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -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"
}
38 changes: 38 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/.circleci export-ignore
/.editorconfig export-ignore
/.devcontainer export-ignore
/.gitattributes export-ignore
/.github export-ignore
39 changes: 21 additions & 18 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,26 @@ 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 "<title>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/[email protected]
with:
configFile: .devcontainer/devcontainer.json
runCmd: |
composer install
while ! mysqladmin ping -h"database" --silent; do
sleep 1
done
wp core install --url=http://localhost:8080 --title=Bedrock --admin_user=admin --admin_password=admin [email protected] --skip-email --allow-root

- name: Verify installation
run: |
curl -s http://localhost:8080 | grep "<title>Bedrock"
Loading