Skip to content

Commit

Permalink
Add devcontainer
Browse files Browse the repository at this point in the history
  • Loading branch information
oxyc committed May 21, 2023
1 parent 21cb97d commit f504d18
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 2 deletions.
32 changes: 32 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"image": "mcr.microsoft.com/devcontainers/universal:2",
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:1": {},
"ghcr.io/ddev/ddev/install-ddev:latest": {}
},
"portsAttributes": {
"3306": {
"label": "database"
},
"8027": {
"label": "mailhog"
},
"8036": {
"label": "phpmyadmin"
},
"8080": {
"label": "web http"
},
"8443": {
"label": "web https"
}
},
"extensions": [
"EditorConfig.EditorConfig",
"xdebug.php-debug",
"bmewburn.vscode-intelephense-client",
"cjhowe7.laravel-blade",
"github.vscode-github-actions"
],
"postCreateCommand": "bash .devcontainer/setup_project.sh"
}
19 changes: 19 additions & 0 deletions .devcontainer/setup_project.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

set -eu -o pipefail
set -x

export DDEV_NONINTERACTIVE=true

ddev config global --omit-containers=ddev-router
ddev debug download-images

ddev stop -a
ddev start -y

npm config set "//npm.fontawesome.com/:_authToken" $NPM_FONTAWESOME_AUTH_TOKEN
composer config --global http-basic.satispress.generodigital.com $SATISPRESS_API_KEY $SATISPRESS_PASSWORD
composer config --global github-oauth.github.com $PACKAGIST_GITHUB_TOKEN

cp .env.example .env
sed -i "s/WP_HOME=.*/WP_HOME='https:\/\/$CODESPACE_NAME-8080.$GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN'/" .env
17 changes: 15 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ You will need an authentication token, we have a shared one added to LastPass/1P

_If you are on Windows you should read the latest DDEV documentation and recommendations for getting things running. You'll need to run all composer, npm, robo and dep commands from within the DDEV container. Remember to send your SSH keys to container using `ddev auth ssh`_

### Setup and run project

# Clone the repository and install the development dependencies.
git clone --recursive [email protected]:generoi/bedrock.git gdsbedrock
cd gdsbedrock
Expand Down Expand Up @@ -82,6 +80,21 @@ Additional useful tasks
./vendor/bin/dep
./vendor/bin/wp

## Remote project development with GitHub codespaces

# Create a codespace and install development tools when the setup tasks are done
composer install:development
cd web/app/themes/gds && npm run build

# SSH into codespace forwarding your keys so that you can pull the database from production.
gh codespace ssh -- -o ForwardAgent=yes

# Pull the database
./vendor/bin/robo db:pull @production
./vendor/bin/robo db:search-replace @ddev 'gdsbedrock.ddev.site' "$CODESPACE_NAME-8080.$GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN"

## Deploy

### Deploying with GitHub actions

Go to [GitHub Actions deploy_production.yml](https://github.com/generoi/gdsbedrock/actions/workflows/deploy_production.yml) workflow and trigger a deploy.
Expand Down
7 changes: 7 additions & 0 deletions config/application.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,13 @@
$_SERVER['HTTPS'] = 'on';
}

/**
* Support reverse proxy on codespaces/ddev
*/
if (env('IS_DDEV_PROJECT') && isset($_SERVER['HTTP_X_FORWARDED_HOST'])) {
$_SERVER['HTTP_HOST'] = $_SERVER['HTTP_X_FORWARDED_HOST'];
}

$env_config = __DIR__ . '/environments/' . WP_ENV . '.php';

if (file_exists($env_config)) {
Expand Down

0 comments on commit f504d18

Please sign in to comment.