Skip to content

Commit

Permalink
Improve gitpod setup (#124)
Browse files Browse the repository at this point in the history
  • Loading branch information
pookmish authored Mar 19, 2024
1 parent 02f2066 commit b0a7c1f
Show file tree
Hide file tree
Showing 5 changed files with 173 additions and 91 deletions.
12 changes: 6 additions & 6 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ NEXT_PUBLIC_DRUPAL_BASE_URL=https://library-dev.sites-pro.stanford.edu
NEXT_PUBLIC_SITE_NAME=Local Environment

# Grab these from the Vercel Environment Variables.
#DRUPAL_DRAFT_CLIENT=CLIENT
#DRUPAL_DRAFT_SECRET=SECRET
#DRUPAL_PREVIEW_SECRET=SECRET
#DRUPAL_REVALIDATE_SECRET=SECRET
#DRUPAL_DRAFT_CLIENT=DRUPAL_DRAFT_CLIENT
#DRUPAL_DRAFT_SECRET=DRUPAL_DRAFT_SECRET
#DRUPAL_PREVIEW_SECRET=DRUPAL_PREVIEW_SECRET
#DRUPAL_REVALIDATE_SECRET=DRUPAL_REVALIDATE_SECRET

# LibApps credentials.
#LIBGUIDE_CLIENT_ID=ID
#LIBGUIDE_CLIENT_SECRET=SECRET
#LIBGUIDE_CLIENT_ID=LIBGUIDE_CLIENT_ID
#LIBGUIDE_CLIENT_SECRET=LIBGUIDE_CLIENT_SECRET

# To build every page when running `yarn build`, change this to 'true' (prod environment).
BUILD_COMPLETE=false
101 changes: 91 additions & 10 deletions .gitpod.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,91 @@
mainConfiguration: https://github.com/SU-SWS/ace-sulgryphon
github:
prebuilds:
master: true
branches: false
pullRequests: true
pullRequestsFromForks: false
addCheck: false
addComment: false
addBadge: true

additionalRepositories:
- url: https://github.com/SU-SWS/ace-stanfordlagunita/
checkoutLocation: back
checkoutLocation: front
ports:
- name: database
description: Mysql database
port: 3306
onOpen: ignore
visibility: private
- port: 33060
onOpen: ignore
visibility: private
- name: drupal
description: Drupal backend
port: 8001
onOpen: ignore
visibility: public
- name: frontend
description: NextJS frontend
port: 3000
onOpen: ignore
visibility: public
- port: 8002-9999
onOpen: ignore
image: pookmish/drupal8ci:gitpod
tasks:
- name: Drupal Prep
init: >
eval $(gp env -e APACHE_DOCROOT_IN_REPO=../back/docroot) &&
cd /workspace/back &&
rm -rf config/default &&
mkdir -p config/default &&
touch config/default/core.extension.yml &&
composer install --no-interaction &&
mkdir -p blt &&
cp .gitpod/blt.yml blt/local.blt.yml &&
find docroot/sites/ -name 'local*' | xargs rm -rf &&
export NEXT_PUBLIC_DRUPAL_BASE_URL=`gp url 8001` &&
export PREVIEW_URL=${NEXT_PUBLIC_DRUPAL_BASE_URL#"https://"} &&
blt blt:telemetry:disable --no-interaction &&
blt settings &&
blt drupal:install --site=library -n &&
drush @library.local cset system.theme default claro -y &&
cd /workspace/front &&
cp .env.example .env.local &&
sed -i 's/#DRUPAL_REVALIDATE_SECRET/DRUPAL_REVALIDATE_SECRET/' .env.local &&
sed -i 's/#DRUPAL_PREVIEW_SECRET/DRUPAL_PREVIEW_SECRET/' .env.local &&
yarn install
command: |
cd /workspace/back &&
echo 'Restarting Apache' &&
eval $(gp env -e APACHE_DOCROOT_IN_REPO=../back/docroot) &&
apache2ctl restart &&
gp ports await 8001 &&
find docroot -name 'local.drush.yml' | xargs rm &&
export NEXT_PUBLIC_DRUPAL_BASE_URL=`gp url 8001` &&
export PREVIEW_URL=${NEXT_PUBLIC_DRUPAL_BASE_URL#"https://"} &&
echo "<?php \$sites['$PREVIEW_URL'] = 'library';" > docroot/sites/local.sites.php &&
blt blt:telemetry:disable --no-interaction &&
echo 'Establishing Settings' &&
blt settings &&
echo 'Logging Into Drupal' &&
drush @library.local uli --uri=$NEXT_PUBLIC_DRUPAL_BASE_URL &&
drush @library.local uli --uri=$NEXT_PUBLIC_DRUPAL_BASE_URL | xargs gp preview --external &&
git config core.fileMode false &&
echo 'Connecting Drupal to Frontend' &&
drush @library.local su-next-connect "$(gp url 3000)" --preview-secret=DRUPAL_PREVIEW_SECRET --revalidation-secret=DRUPAL_REVALIDATION_SECRET &&
cd /workspace/front &&
yarn install &&
sed -i -r "s|NEXT_PUBLIC_DRUPAL_BASE_URL.*|NEXT_PUBLIC_DRUPAL_BASE_URL=$NEXT_PUBLIC_DRUPAL_BASE_URL|g" .env.local &&
yarn dev &
gp ports await 3000 &&
gp url 3000 | xargs gp preview --external
- name: SSH Keys
before: |
mkdir -p ~/.ssh
if [[ ! -z $SSH_PUBLIC_KEY ]]; then
echo $SSH_PUBLIC_KEY | base64 -d > ~/.ssh/id_rsa.pub && chmod 644 ~/.ssh/id_rsa.pub
fi
if [[ ! -z $SSH_PRIVATE_KEY ]]; then
echo $SSH_PRIVATE_KEY | base64 -d > ~/.ssh/id_rsa && chmod 600 ~/.ssh/id_rsa
fi
if [[ ! -z $GITCONFIG ]]; then
echo $GITCONFIG | base64 -d > ~/.gitconfig && chmod 644 ~/.gitconfig
fi
vscode:
extensions:
- bradlc.vscode-tailwindcss
3 changes: 3 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ module.exports = {
protocol: drupalUrl.protocol.replace(':', ''),
hostname: drupalUrl.hostname,
},
{
hostname: '**.gitpod.io'
}
],
},
eslint: {
Expand Down
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
"dependencies": {
"@formkit/auto-animate": "^0.8.1",
"@heroicons/react": "^2.1.1",
"@mui/base": "^5.0.0-beta.38",
"@mui/base": "^5.0.0-beta.39",
"@next/third-parties": "^14.1.3",
"@tailwindcss/container-queries": "^0.1.1",
"@tailwindcss/typography": "^0.5.10",
"@tanstack/react-query": "^5.25.0",
"@types/node": "^20.11.25",
"@types/react": "^18.2.64",
"@tanstack/react-query": "^5.28.4",
"@types/node": "^20.11.29",
"@types/react": "^18.2.67",
"autoprefixer": "^10.4.18",
"axios": "^1.6.7",
"axios": "^1.6.8",
"critters": "^0.0.22",
"decanter": "^7.2.0",
"graphql": "^16.8.1",
Expand All @@ -32,7 +32,7 @@
"jsona": "^1.12.1",
"next": "^14.1.3",
"next-drupal": "^1.6.0",
"postcss": "^8.4.35",
"postcss": "^8.4.36",
"react": "^18.2.0",
"react-aria": "^3.32.1",
"react-dom": "^18.2.0",
Expand All @@ -43,7 +43,7 @@
"react-stately": "^3.30.1",
"react-tiny-oembed": "^1.1.0",
"sharp": "^0.33.2",
"tailwind-merge": "^2.2.1",
"tailwind-merge": "^2.2.2",
"tailwindcss": "^3.4.1",
"typescript": "^5.4.2",
"usehooks-ts": "^3.0.1"
Expand All @@ -53,7 +53,7 @@
"@graphql-codegen/import-types-preset": "^3.0.0",
"@graphql-codegen/typescript-graphql-request": "^6.2.0",
"@graphql-codegen/typescript-operations": "4.2.0",
"@types/qs": "^6.9.12",
"@types/qs": "^6.9.13",
"eslint": "^8.57.0",
"eslint-config-next": "^14.1.3",
"eslint-plugin-deprecation": "^2.0.0",
Expand Down
Loading

0 comments on commit b0a7c1f

Please sign in to comment.