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
29 changes: 29 additions & 0 deletions .devcontainer/WELCOME.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

██████╗ ██████╗ ██╗ ██╗██╗ ██╗████████╗ ██╗███████╗
██╔══██╗██╔══██╗██║ ██║╚██╗██╔╝╚══██╔══╝ ██║██╔════╝
██║ ██║██████╔╝██║ ██║ ╚███╔╝ ██║ ██║███████╗
██║ ██║██╔══██╗██║ ██║ ██╔██╗ ██║ ██ ██║╚════██║
██████╔╝██║ ██║╚██████╔╝██╔╝ ██╗ ██║██╗╚█████╔╝███████║
╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚════╝ ╚══════╝

Welcome to the Druxt serverless starterkit.

Dependencies are installed, and the Drupal backend is provisioned and
running on port 8888. This site builds to full static output, so Drupal
only matters at build time - nothing needs to be running once it ships.

Pick a task:

npm run dev Nuxt dev server (port 3000)
npm run generate Build the full static site into nuxt/dist
npm run info What is running, and where

npm run start Restart the backend (npm run stop halts it)
npm run login Print a one-time Drupal login link
npm run reset Wipe the database (npm run setup provisions it again)

npm run drush -- <cmd> Run Drush, e.g. npm run drush -- core:status

Both ports above are forwarded automatically.

Happy building.
6 changes: 6 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@
}
},
"customizations": {
// Codespaces opens the welcome guide on first attach; other clients get it
// from the shell rc hook post-create.sh installs.
"codespaces": {
"openFiles": [".devcontainer/WELCOME.txt"]
},
"vscode": {
"settings": {
// Absolute path to where the mise feature installs the binary
Expand Down Expand Up @@ -79,5 +84,6 @@
}
},
"postCreateCommand": "bash .devcontainer/post-create.sh",
"postStartCommand": "bash .devcontainer/post-start.sh",
"remoteUser": "vscode"
}
22 changes: 22 additions & 0 deletions .devcontainer/post-create.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,25 @@ echo 'extension=gd' | sudo tee "$CONF_DIR/gd.ini" > /dev/null
php -r "exit(extension_loaded('gd') ? 0 : 1);" || { echo "gd extension failed to load" >&2; exit 1; }


echo "==> Greeting new terminals with the welcome guide"
# postAttachCommand output goes to whatever launched the container - DevPod
# prints it to its own CLI log, outside the container - so someone opening a
# terminal never sees it. The shell's own rc file is the only place that
# reliably reaches them.
#
# Both rc files, because the base image ships bash and zsh and which one a
# terminal opens depends on the client. Every interactive shell, not once: a
# one-shot marker gets spent by whichever shell the editor opens first, which
# is rarely the one the user is looking at.
for rc in "$HOME/.bashrc" "$HOME/.zshrc"; do
cat >> "$rc" <<SH

case \$- in
*i*) cat "$(pwd)/.devcontainer/WELCOME.txt" ;;
esac
SH
done

echo "==> Trusting this repo's mise.toml"
mise trust

Expand All @@ -66,3 +85,6 @@ echo "==> Running npm install (triggers the full setup pipeline)"
# app's pinned Node 16 works fine but emits a wall of EBADENGINE
# warnings that drowns the real setup output on first run.
npm install --loglevel=error

echo "==> Ready"
cat .devcontainer/WELCOME.txt
17 changes: 17 additions & 0 deletions .devcontainer/post-start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash
#
# Start the Drupal backend on every container start. Without this, stopping and
# resuming a container leaves the frontend pointing at a backend that is no
# longer listening, which looks like a broken install rather than a stopped
# process.
#
# Skipped, with a pointer, when the site was never provisioned (a post-create
# that failed part way), so one broken create does not also fail every start.
set -euo pipefail

cd drupal
if [ ! -f web/sites/default/settings.local.php ]; then
echo "The Drupal backend is not provisioned. Run: npm run setup" >&2
exit 0
fi
.devtools/start
Loading