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
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"
}
22 changes: 22 additions & 0 deletions .devcontainer/setup_project.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/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 $GITHUB_TOKEN

cp .env.example .env
sed -i "s/WP_HOME=.*/WP_HOME='https:\/\/$CODESPACE_NAME-8080.$GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN'/" .env

mkdir -p ~/.ssh
chmod 700 ~/.ssh
25 changes: 23 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 git@github.com:generoi/bedrock.git gdsbedrock
cd gdsbedrock
Expand Down Expand Up @@ -82,6 +80,29 @@ 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

# Option 1: Retrieve database by SSH into codespace with your keys
# ----------------------------------------------------------------
gh codespace ssh -- -o ForwardAgent=yes

# Option 2: Retrieve database through a personal codespace secret
# ---------------------------------------------------------------
echo -e "$PERSONAL_KINSTA_DEPLOY_KEY" >| ~/.ssh/private-key
chmod 600 ~/.ssh/private-key
eval `ssh-agent`
ssh-add

# 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