Skip to content

Commit c574142

Browse files
committed
initial commit
1 parent b027336 commit c574142

File tree

7 files changed

+261
-0
lines changed

7 files changed

+261
-0
lines changed

.ddev/config.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# @Todo: update project's name
2+
name: project_name
3+
type: drupal9
4+
docroot: web
5+
php_version: "7.4"
6+
webserver_type: nginx-fpm
7+
router_http_port: "8080"
8+
router_https_port: "8443"
9+
xdebug_enabled: false
10+
additional_hostnames: []
11+
additional_fqdns: []
12+
database:
13+
type: mariadb
14+
version: "10.3"
15+
nfs_mount_enabled: false
16+
mutagen_enabled: false
17+
use_dns_when_possible: true
18+
composer_version: "2"
19+
web_environment: []
20+
provider: pantheon

.ddev/providers/pantheon.yaml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
#ddev-generated
2+
# Example Pantheon.io provider configuration.
3+
# This example is Drupal/drush oriented,
4+
# but can be adapted for other CMSs supported by Pantheon
5+
6+
# To use this configuration:
7+
#
8+
# 1. Get your Pantheon.io machine token:
9+
# a. Login to your Pantheon Dashboard, and [Generate a Machine Token](https://pantheon.io/docs/machine-tokens/) for ddev to use.
10+
# b. Add the API token to the `web_environment` section in your global ddev configuration at ~/.ddev/global_config.yaml
11+
#
12+
# ```
13+
# web_environment:
14+
# - PROJECT_TERMINUS_TOKEN=abcdeyourtoken
15+
# ```
16+
#
17+
# 2. Choose a Pantheon site and environment you want to use with ddev. You can usually use the site name, but in some environments you may need the site uuid, which is the long 3rd component of your site dashboard URL. So if the site dashboard is at <https://dashboard.pantheon.io/sites/009a2cda-2c22-4eee-8f9d-96f017321555#dev/>, the site ID is 009a2cda-2c22-4eee-8f9d-96f017321555.
18+
#
19+
# 3. On the pantheon dashboard, make sure that at least one backup has been created. (When you need to refresh what you pull, do a new backup.)
20+
#
21+
# 4. Make sure your public ssh key is configured in Pantheon (Account->SSH Keys)
22+
#
23+
# 5. Check out project codebase from Pantheon. Enable the "Git Connection Mode" and use `git clone` to check out the code locally.
24+
#
25+
# 6. Verify that drush is installed in your project, `ddev composer require drush/drush`
26+
#
27+
# 7. Configure the local checkout for ddev using `ddev config`
28+
#
29+
# 8. In your project's .ddev/providers directory, copy pantheon.yaml.example to pantheon.yaml and edit the "project" under `environment_variables` (change it from `yourproject.dev`). If you want to use a different environment than "dev", change `dev` to the name of the environment.
30+
#
31+
# 9. `ddev restart`
32+
#
33+
# 10. Run `ddev pull pantheon`. The ddev environment download the Pantheon database and files, and import the database and files into the ddev environment. You should now be able to access the project locally.
34+
#
35+
# 11. Optionally use `ddev push pantheon` to push local files and database to Pantheon. Note that `ddev push` is a command that can potentially damage your production site, so this is not recommended.
36+
#
37+
38+
# Debugging: Use `ddev exec terminus auth:whoami` to see what terminus knows about
39+
# `ddev exec terminus site:list` will show available sites
40+
41+
# @Todo: update the project name and pantheon environment name (dev/test/live/etc.)
42+
environment_variables:
43+
project: project_name.pantheon_environment_name
44+
45+
auth_command:
46+
command: |
47+
set -eu -o pipefail
48+
ssh-add -l >/dev/null || ( echo "Please 'ddev auth ssh' before running this command." && exit 1 )
49+
if ! command -v drush >/dev/null ; then echo "Please make sure your project contains drush, ddev composer require drush/drush" && exit 1; fi
50+
if [ -z "${PROJECT_TERMINUS_TOKEN:-}" ]; then echo "Please make sure you have set PROJECT_TERMINUS_TOKEN in ~/.ddev/global_config.yaml" && exit 1; fi
51+
terminus auth:login --machine-token="${PROJECT_TERMINUS_TOKEN}" || ( echo "terminus auth login failed, check your PROJECT_TERMINUS_TOKEN" && exit 1 )
52+
terminus aliases 2>/dev/null
53+
54+
db_pull_command:
55+
command: |
56+
set -x # You can enable bash debugging output by uncommenting
57+
set -eu -o pipefail
58+
ls /var/www/html/.ddev >/dev/null # This just refreshes stale NFS if possible
59+
pushd /var/www/html/.ddev/.downloads >/dev/null
60+
terminus backup:get ${project} --element=db --to=db.sql.gz
61+
62+
files_pull_command:
63+
command: |
64+
set -x # You can enable bash debugging output by uncommenting
65+
set -eu -o pipefail
66+
ls /var/www/html/.ddev >/dev/null # This just refreshes stale NFS if possible
67+
pushd /var/www/html/.ddev/.downloads >/dev/null;
68+
terminus backup:get ${project} --element=files --to=files.tgz
69+
mkdir -p files && tar --strip-components=1 -C files -zxf files.tgz
70+
71+
# push is a dangerous command. If not absolutely needed it's better to delete these lines.
72+
db_push_command:
73+
command: |
74+
set -x # You can enable bash debugging output by uncommenting
75+
set -eu -o pipefail
76+
ls /var/www/html/.ddev >/dev/null # This just refreshes stale NFS if possible
77+
pushd /var/www/html/.ddev/.downloads >/dev/null;
78+
terminus remote:drush ${project} -- sql-drop -y
79+
gzip -dc db.sql.gz | terminus remote:drush ${project} -- sql-cli
80+
81+
# push is a dangerous command. If not absolutely needed it's better to delete these lines.
82+
files_push_command:
83+
command: |
84+
set -x # You can enable bash debugging output by uncommenting
85+
set -eu -o pipefail
86+
ls ${DDEV_FILES_DIR} >/dev/null # This just refreshes stale NFS if possible
87+
drush rsync -y @self:%files @${project}:%files

.gitpod.yml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
image: drupalpod/drupalpod-gitpod-base:latest
2+
3+
# ddev and composer are running as part of the prebuild
4+
# when starting a workspace all docker images are ready
5+
tasks:
6+
- name: terminal
7+
before: |
8+
.gitpod/env-setup.sh
9+
.gitpod/ddev-in-gitpod-setup.sh
10+
init: |
11+
ddev debug download-images
12+
.gitpod/project-setup.sh
13+
command: |
14+
echo y | ddev start
15+
gp preview $(gp url 8080)
16+
17+
# VScode xdebug extension
18+
vscode:
19+
extensions:
20+
# PHP extensions.
21+
- felixfbecker.php-debug
22+
- wongjn.php-sniffer
23+
- neilbrayfield.php-docblocker
24+
- bmewburn.vscode-intelephense-client
25+
26+
# Twig extensions.
27+
- mblode.twig-language-2
28+
29+
# Bash extensions.
30+
- timonwong.shellcheck
31+
- rogalmic.bash-debug
32+
33+
# Set the following ports public
34+
ports:
35+
# Used by ddev - local db clients
36+
- port: 3306
37+
onOpen: ignore
38+
# Used by MailHog
39+
- port: 5000
40+
onOpen: open-preview
41+
- port: 6006
42+
onOpen: open-preview
43+
- port: 6942
44+
onOpen: ignore
45+
- port: 8027
46+
onOpen: ignore
47+
# Used by phpMyAdmin
48+
- port: 8036
49+
onOpen: ignore
50+
# Direct-connect ddev-webserver port that is the main port
51+
- port: 8080
52+
onOpen: ignore
53+
# Ignore host https port
54+
- port: 8443
55+
onOpen: ignore
56+
# xdebug port
57+
- port: 9003
58+
onOpen: ignore
59+
60+
github:
61+
prebuilds:
62+
# enable for the master/default branch (defaults to true)
63+
master: true
64+
# enable for all branches in this repo (defaults to false)
65+
branches: true
66+
# enable for pull requests coming from this repo (defaults to true)
67+
pullRequests: true
68+
# enable for pull requests coming from forks (defaults to false)
69+
pullRequestsFromForks: true
70+
# add a check to pull requests (defaults to true)
71+
addCheck: true
72+
# add a "Review in Gitpod" button as a comment to pull requests (defaults to false)
73+
addComment: true
74+
# add a "Review in Gitpod" button to the pull request's description (defaults to false)
75+
addBadge: true
76+
# add a label once the prebuild is ready to pull requests (defaults to false)
77+
addLabel: true

.gitpod/ddev-in-gitpod.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
if [ -n "$DEBUG_SCRIPTS" ] || [ -n "$GITPOD_HEADLESS" ]; then
3+
set -x
4+
fi
5+
6+
# Misc housekeeping before start
7+
ddev config global --instrumentation-opt-in=true --web-environment="PROJECT_TERMINUS_TOKEN=$PROJECT_TERMINUS_TOKEN"

.gitpod/env-setup.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env bash
2+
if [ -n "$DEBUG_SCRIPTS" ]; then
3+
set -x
4+
fi
5+
6+
if [ -n "$GITPOD_HEADLESS" ]; then
7+
# Fetch PANTHEON_SSH_KEY value during `init`
8+
eval "$(gp env -e)" > /dev/null
9+
fi
10+
11+
# Setting SSH key from environment variable
12+
mkdir -p ~/.ssh
13+
printenv PANTHEON_SSH_KEY > ~/.ssh/id_rsa
14+
chmod 600 ~/.ssh/id_rsa

.gitpod/project-setup.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env bash
2+
if [ -n "$DEBUG_SCRIPTS" ] || [ -n "$GITPOD_HEADLESS" ]; then
3+
set -x
4+
fi
5+
6+
cd "$GITPOD_REPO_ROOT" && ddev composer install
7+
cd "$GITPOD_REPO_ROOT" && ddev auth ssh
8+
cd "$GITPOD_REPO_ROOT" && ddev pull pantheon -y
9+
cd "$GITPOD_REPO_ROOT" && ddev drush updb -y
10+
cd "$GITPOD_REPO_ROOT" && ddev drush cim -y
11+
cd "$GITPOD_REPO_ROOT" && ddev drush cr

README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# DrupalPod with Pantheon
2+
3+
## Setup
4+
5+
1. Add all the files in this repo to your existing project (make sure all the script files in `./gitpod/` directory are executable)
6+
```
7+
chmod +x .gitpod/*
8+
```
9+
10+
1. Generate ssh-key in Gitpod
11+
```
12+
ssh-keygen -b 4096
13+
```
14+
15+
1. In Gitpod terminal, run `gp env PANTHEON_SSH_KEY=$(cat ~/.ssh/id_rsa)`
16+
<br>
17+
This will add environment variable scoped to this project.
18+
19+
1. _Optional_ - use the same `PANTHEON_SSH_KEY` in all your projects:
20+
1. Edit `PANTHEON_SSH_KEY` in https://gitpod.io/variables
21+
1. Update the scope to `*/*`.
22+
23+
1. Add the content of `~/.ssh/id_rsa.pub` to Pantheon
24+
<br>
25+
https://pantheon.io/docs/ssh-keys#add-your-ssh-key-to-pantheon
26+
27+
28+
1. Generate Terminus Token
29+
<br>
30+
https://pantheon.io/docs/machine-tokens#create-a-machine-token
31+
32+
1. Add Terminus token you generated to Gitpod as a new environment variable `PROJECT_TERMINUS_TOKEN` (https://gitpod.io/variables)
33+
34+
1. Update `.ddev/config.yaml` to the correct project name
35+
```
36+
name: project_name
37+
```
38+
39+
1. Update line 43 in `.ddev/providers/pantheon.yaml`
40+
```
41+
project: project_name.pantheon_environment_name
42+
```
43+
44+
1. _**Recommended**_:
45+
<br>To speed up the process, enable Prebuilds by follow the instructions @ https://www.gitpod.io/docs/prebuilds#enable-prebuilt-workspaces

0 commit comments

Comments
 (0)