-
Notifications
You must be signed in to change notification settings - Fork 46
feat(deploy): T399695 - Initial Deploy config/setup wizard (Web and CLI) #879
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
lorenjohnson
wants to merge
68
commits into
main
Choose a base branch
from
deploy-setup-script
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
68 commits
Select commit
Hold shift + click to select a range
759297c
chore: fix linting issues and update config
lorenjohnson abc0dfd
feat(deploy): T399695 - Deploy Web-based initial setup
lorenjohnson fda3fda
fix(deploy): Proper setup cloud-init flag
lorenjohnson c2fb04f
chore(deploy): Better dev mode for setup script
lorenjohnson 430017d
chore(deploy): Better organize setup scripts
lorenjohnson 7181e5c
feat(deploy): Add basic CLI setup option which is now default. Better…
lorenjohnson 7ec942e
feat(deploy): Make setup script work with interactive CLI option
lorenjohnson e219942
fix
lorenjohnson 7eac8ea
update
lorenjohnson 233bc9f
enable launch in cli mode
lorenjohnson a6a46d2
update
lorenjohnson f567753
fix
lorenjohnson ac6fa3a
fix
lorenjohnson 4c5c964
fix
lorenjohnson 6c8b5ce
better cli entry/defaults
lorenjohnson bf3781c
test
lorenjohnson 7115d6f
switch back to bash
lorenjohnson 6c3543f
wrap v0.1 CLI setup
lorenjohnson 452cada
updates
lorenjohnson 0b1bb98
update host name validators
lorenjohnson 5b81a53
update log display
lorenjohnson 0df495e
allow localhost hostname
lorenjohnson 2610fdd
lint
lorenjohnson 3f43b78
update formatting
lorenjohnson fda8767
formatting
lorenjohnson 95ebb82
linting
lorenjohnson ee73e38
Merge branch 'main' into deploy-setup-script
lorenjohnson 016c8f4
Merge branch 'main' into deploy-setup-script
lorenjohnson 2b0a8e1
Merge branch 'main' into deploy-setup-script
lorenjohnson 3f907c1
chore(deploy/setup): Improved Web UI field validation (no includes ho…
lorenjohnson 861b6e2
linting
lorenjohnson 14b9cc3
fix readme
lorenjohnson ac53300
update readme
lorenjohnson 44689d2
udpate readme
lorenjohnson bc768ef
fix for subdomain SETUP_SUBDOMAIN generation that doesn't cause pipefail
lorenjohnson f4500a1
Refinements in prep for next code review
lorenjohnson 2d58f6b
Fixes the git and docker install across all supported distros, improv…
lorenjohnson 3fd8651
Update text
lorenjohnson 26192de
Brings back minimal LOCALHOST support, adds dev notes, recognizes if …
lorenjohnson cc46565
Move current DEV status back into PR
lorenjohnson 4e3aeb4
Fix setup script local run condition
lorenjohnson 159b882
Improved cert warning feedback and support
lorenjohnson 628c5d2
Fix pipe vs normal run detection issue for setup script
lorenjohnson 5b0a938
Updates backend SSE story using better-sse library, cleans-up front e…
lorenjohnson a477766
fixes logging quotes, handles run logging better, fixes default WDQS_…
lorenjohnson bf3ccd3
fix initial log load
lorenjohnson 02c6567
fixes
lorenjohnson 68f2d7a
fix certbot image version
lorenjohnson 075a660
certbot fallback fix
lorenjohnson cdfc0bb
fixes
lorenjohnson 4a04c3a
fix bug
lorenjohnson 5ab2b11
fix download config bug
lorenjohnson 5de4ae2
fix log formatting in web
lorenjohnson ba65f6e
Updates from review
lorenjohnson 79be817
change from review
lorenjohnson e4d7e86
remove sudo from script as per pr review
lorenjohnson 3e86f00
adds getConfig abstraction to web server, clears-up --dev cli option …
lorenjohnson 0b36707
Re-organization of file structure
lorenjohnson 5e04feb
fix
lorenjohnson b58cfdc
fixes web form init/final state updating from server, removes any exi…
lorenjohnson 83905d6
feat(deploy): Ignores docker-compose.local.env for use in localhost/d…
lorenjohnson c13c4e5
cleans-up and normalizes webserver helpers, makes wikibase.test and q…
lorenjohnson 0d73c49
adds --reset option with cli prompts, cleans-up and normalizes env va…
lorenjohnson ff1ede0
better RESET status
lorenjohnson f050f39
--dev is equal to --local --skip-deps
lorenjohnson dfc1895
moves web into its own directory, elaborates logstream, fixes some ui…
lorenjohnson de1a857
moves reset functionality out of start.sh into setup.sh, renames lauc…
lorenjohnson f01e4c5
Merge branch 'main' into deploy-setup-script
lorenjohnson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| docker-compose.local.yml |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| # Wikibase Suite Deploy – Setup Script | ||
|
|
||
| This script bootstraps a Wikibase Suite Deploy installation handling or guiding you through all of the following steps: | ||
|
|
||
| 1. **Check for Git** – Installs Git if it is not already available on the system. | ||
| 2. **Clone the repository** – Downloads the Wikibase Suite Deploy code from the official repository. | ||
| 3. **Check for Docker** – Installs Docker if it is not already available on the system. | ||
| 4. **Prompt for configuration** – Collects all required setup values interactively through a web interface. | ||
| 5. **Launch deployment** – Starts the deployment process once configuration is complete and notifies you once your new Suite instance is available. | ||
|
|
||
| ## Installation | ||
|
|
||
| 1. Setup on a new VPS instance that meets the following criteria: | ||
|
|
||
| - Meets minimum hardware requirements (see https://github.com/wmde/wikibase-release-pipeline/tree/main/deploy#requirements) | ||
| - Is running one of these officially supported Linux distributions: Ubuntu (22, 24), Debian (11, 12), Fedora, and CentOS | ||
| - You have root level SSH access to the instance | ||
|
|
||
| 2. SSH as root into your new VPS instance and enter the following, following instructions from there: | ||
|
|
||
| ```bash | ||
| curl -fsSL https://raw.githubusercontent.com/wmde/wikibase-release-pipeline/refs/heads/deploy-setup-script/deploy/setup/start.sh | bash | ||
| ``` | ||
|
|
||
| Alternatively, if you already have cloned the repository you can run do start setup running the following commands: | ||
|
|
||
| ```bash | ||
| cd deploy/setup | ||
| ./start.sh --skip-clone | ||
| ``` | ||
|
|
||
| ## CLI Options | ||
|
|
||
| `start.sh` also has some CLI options available for special cases, debugging, and development: | ||
|
|
||
| | Option | Description | | ||
| |------------------|-------------| | ||
| | `--debug` | Enable verbose/debug logging for troubleshooting. | | ||
| | `--skip-clone` | Skip cloning the repository (use an existing checkout). | | ||
| | `--skip-deps` | Skip dependency installation (assumes Git & Docker are already installed). | | ||
| | `--skip-launch` | Do not launch services after configuration completes. | | ||
|
|
||
| ### Dev-only | ||
|
|
||
| | Option | Description | | ||
| |------------------|-------------| | ||
| | `--dev` | Development mode: skips clone, dependency installs, and launch; uses a relative repo path for local development. | | ||
| | `--local` | Mark this run as local which launches setup on localhost:8888 and runs the interactive instead of as a background process. Useful only for dev/testing at this stage.| | ||
|
|
||
| These options can be applied using the following command formats: | ||
|
|
||
| ```bash | ||
| curl -fsSL https://raw.githubusercontent.com/wmde/wikibase-release-pipeline/refs/heads/deploy-setup-script/deploy/setup/start.sh | bash -s -- [OPTIONS] | ||
| ``` | ||
|
|
||
| Or, from within the deploy/setup directory of an already cloned repository: | ||
|
|
||
| ```bash | ||
| ./setup [OPTIONS] | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| #!/usr/bin/env bash | ||
| # ----------------------------------------------------------------------------- | ||
| # Clean stdout, structured log: | ||
| # - stdout: no timestamps / no [LEVEL] | ||
| # - log : ISO8601 timestamp + [LEVEL] | ||
| # ----------------------------------------------------------------------------- | ||
|
|
||
| export LOG_PATH=${LOG_PATH:=/tmp/wbs-deploy-setup.log} | ||
|
|
||
| DEBUG=${DEBUG:=false} | ||
|
|
||
| # Are we attached to a terminal? | ||
| INTERACTIVE=false | ||
| [ -t 1 ] && INTERACTIVE=true | ||
|
|
||
| _timestamp() { date -u +"%FT%TZ"; } | ||
|
|
||
| # --- one-shot init that rotates the previous file and starts clean ----------- | ||
| log_init() { | ||
| if [ "${WBS_LOG_INITIALIZED:-}" = "1" ]; then | ||
| return | ||
| fi | ||
| export WBS_LOG_INITIALIZED=1 | ||
|
|
||
| mkdir -p "$(dirname "$LOG_PATH")" 2>/dev/null || true | ||
|
|
||
| if [ -f "$LOG_PATH" ] && [ -s "$LOG_PATH" ]; then | ||
| ts=$(date -u +"%Y%m%d-%H%M%S") | ||
| backup="${LOG_PATH}.${ts}" | ||
| # Prefer mv; fall back to cp if moving across devices fails | ||
| mv -- "$LOG_PATH" "$backup" 2>/dev/null || { | ||
| cp --preserve=mode,timestamps -- "$LOG_PATH" "$backup" 2>/dev/null || true | ||
| touch "$LOG_PATH" | ||
| } | ||
| fi | ||
| touch "$LOG_PATH" | ||
| } | ||
|
|
||
| # run init immediately | ||
| log_init | ||
|
|
||
| # status "Message..." | ||
| # - stdout: "Message..." | ||
| # - log : "2025-08-12T10:00:00Z [status] Message..." | ||
| status() { | ||
| printf '%s [status] %s\n' "$(_timestamp)" "$*" >> "$LOG_PATH" | ||
| if $INTERACTIVE; then | ||
| printf '%s\n' "$*" | ||
| fi | ||
| } | ||
|
|
||
| # debug "Message..." | ||
| # - stdout: shown only if DEBUG=true (clean) | ||
| # - log : "2025-08-12T10:00:00Z [debug] Message..." | ||
| debug() { | ||
| printf '%s [debug] %s\n' "$(_timestamp)" "$*" >> "$LOG_PATH" | ||
| if [ "$DEBUG" = true ]; then | ||
| printf '%s\n' "$*" | ||
| fi | ||
| } | ||
|
|
||
| # run "command string" | ||
| # Always logs. Mirrors to stdout only if INTERACTIVE && DEBUG. | ||
| # Log format: | ||
| # 2025-... [debug] $ command string | ||
| # <raw command output...> | ||
| run() { | ||
| local cmd="$*" | ||
| printf '%s [debug] $ %s\n' "$(_timestamp)" "BEGIN RUN: $cmd" >> "$LOG_PATH" | ||
|
|
||
| if $INTERACTIVE && [ "$DEBUG" = true ]; then | ||
| # output to screen and log | ||
| bash -c "$cmd" 2>&1 | tee -a "$LOG_PATH" | ||
| else | ||
| # log only | ||
| bash -c "$cmd" >>"$LOG_PATH" 2>&1 | ||
| fi | ||
| printf '%s [debug] $ %s\n' "$(_timestamp)" "END RUN" >> "$LOG_PATH" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| # --- Expected Variables --- | ||
|
|
||
| export SCRIPTS_DIR | ||
|
|
||
| # --- Bootstrap Logging --- | ||
|
|
||
| # shellcheck disable=SC1091 | ||
| source "$SCRIPTS_DIR/_logging.sh" | ||
|
|
||
| # --- Main Script --- | ||
|
|
||
| debug "Checking for Docker..." | ||
|
|
||
| if command -v docker >/dev/null 2>&1; then | ||
| exit 0 | ||
| fi | ||
|
|
||
| debug "Installing Docker..." | ||
|
|
||
| if command -v apt-get >/dev/null 2>&1; then | ||
| # Debian/Ubuntu: install Docker from official Docker APT repo for consistent versioning | ||
|
|
||
| # Detect OS and codename | ||
| OS_ID="$(. /etc/os-release 2>/dev/null; echo "${ID:-debian}")" | ||
| CODENAME="$(. /etc/os-release 2>/dev/null; echo "${VERSION_CODENAME:-}")" | ||
| if [ -z "$CODENAME" ] && command -v lsb_release >/dev/null 2>&1; then | ||
| CODENAME="$(lsb_release -cs 2>/dev/null || true)" | ||
| fi | ||
| if [ -z "$CODENAME" ]; then | ||
| echo "❌ Could not determine distro codename" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| run "echo 'Using Docker APT repo for $OS_ID ($CODENAME)'" | ||
| run "apt-get update -y" | ||
| run "apt-get install -y --no-install-recommends ca-certificates curl gnupg" | ||
| run "install -m 0755 -d /etc/apt/keyrings" | ||
| run "curl -fsSL https://download.docker.com/linux/$OS_ID/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg" | ||
| run "apt-get remove -y docker.io docker-compose docker-compose-v2 2>/dev/null || true" | ||
| run "echo \"deb [arch=\$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/$OS_ID $CODENAME stable\" | tee /etc/apt/sources.list.d/docker.list >/dev/null" | ||
| run "apt-get update -y" | ||
| run "apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin" | ||
| elif command -v dnf >/dev/null 2>&1; then | ||
| # Distinguish Fedora vs RHEL-family (CentOS Stream, RHEL, Rocky, Alma) | ||
| OS_ID="$(. /etc/os-release 2>/dev/null; echo "${ID:-}")" | ||
|
|
||
| if [ "$OS_ID" = "fedora" ]; then | ||
| # Fedora: use Fedora-maintained Moby packages | ||
| run "dnf -y install moby-engine moby-cli docker-compose-plugin docker-buildx-plugin" | ||
| else | ||
| # RHEL-family (CentOS Stream / RHEL / Rocky / Alma): use Docker's official repo | ||
| run "dnf -y install dnf-plugins-core" | ||
| run "dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo" | ||
| run "dnf -y install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin || \ | ||
| (echo '❌ Docker CE packages not available for this release yet.' >&2; exit 1)" | ||
| fi | ||
| else | ||
| status "⚠️ Unsupported package manager. Please install Docker manually." | ||
| exit 1 | ||
| fi | ||
|
|
||
| debug "Enabling and starting Docker..." | ||
| run "systemctl enable --now docker" | ||
| status "Docker installation complete." | ||
| run "docker --version" || true | ||
| run "docker compose version" || true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| # --- Expected Variables --- | ||
|
|
||
| export DEBUG | ||
| export LOCALHOST | ||
| export LOG_PATH | ||
| export DEPLOY_DIR | ||
| export ENV_FILE_PATH | ||
| export SCRIPTS_DIR | ||
| export SETUP_DIR | ||
| export RESET | ||
|
|
||
| # --- Bootstrap Logging --- | ||
|
|
||
| # shellcheck disable=SC1091 | ||
| source "$SCRIPTS_DIR/_logging.sh" | ||
|
|
||
| # --- Functions --- | ||
|
|
||
| wait_for_env_file() { | ||
| until [ -s "$ENV_FILE_PATH" ]; do sleep 2; done | ||
| debug "Configuration saved." | ||
| } | ||
|
|
||
| launch_deploy() { | ||
| pushd "$DEPLOY_DIR" >/dev/null || return 1 | ||
|
|
||
| local compose_opts=() | ||
| local compose_up_opts=(-d) | ||
|
|
||
| if [ -f "docker-compose.local.yml" ]; then | ||
| compose_opts+=(-f docker-compose.yml -f docker-compose.local.yml) | ||
| fi | ||
|
|
||
| if ! $DEBUG ; then | ||
| compose_up_opts+=(--quiet-pull); | ||
| fi | ||
|
|
||
| if $RESET; then | ||
| status "Removing config/LocalSettings.php (RESET=true)" | ||
| run "rm -f config/LocalSettings.php" | ||
|
|
||
| status "Taking down any existing wbs-deploy services and data (RESET=true)" | ||
| run "docker compose ${compose_opts[*]} down --volumes" | ||
| fi | ||
|
|
||
| status "Waiting for services to start. Generally takes 2–6 minutes..." | ||
|
|
||
| run "docker compose ${compose_opts[*]} up ${compose_up_opts[*]}" | ||
|
|
||
| popd >/dev/null || return 1 | ||
| } | ||
|
|
||
| # NOTE: final_message intentionally uses echo+tee for a clean human banner on stdout. | ||
| # The block is also appended to the log via tee, but WITHOUT timestamps/levels. | ||
| final_message() { | ||
| { | ||
| echo | ||
| echo "✅ Setup is Complete!" | ||
| echo | ||
| if [[ -f "$ENV_FILE_PATH" ]]; then | ||
| # shellcheck disable=SC1090 | ||
| source "$ENV_FILE_PATH" | ||
|
lorenjohnson marked this conversation as resolved.
|
||
|
|
||
| if [[ -n "${WIKIBASE_PUBLIC_HOST:-}" ]]; then | ||
| echo "Your Wikibase Suite services can be found at:" | ||
| echo | ||
| echo "MediaWiki/Wikibase:" | ||
| echo "https://$WIKIBASE_PUBLIC_HOST" | ||
| echo | ||
| echo "Query Service:" | ||
| echo "https://${WDQS_PUBLIC_HOST:-query.$WIKIBASE_PUBLIC_HOST}" | ||
| echo | ||
| echo "QuickStatements:" | ||
| echo "https://$WIKIBASE_PUBLIC_HOST/tools/quickstatements" | ||
| echo | ||
| else | ||
| echo "⚠️ Could not determine WIKIBASE_PUBLIC_HOST from .env" | ||
| fi | ||
|
|
||
| echo | ||
| echo "The following configuration was saved during setup." | ||
| echo "Please save these credentials and settings securely:" | ||
| echo | ||
| sed 's/^/ /' "$ENV_FILE_PATH" | ||
| echo | ||
| else | ||
| echo "⚠️ .env file not found at $ENV_FILE_PATH" | ||
| echo | ||
| fi | ||
| } | tee -a "$LOG_PATH" | ||
| } | ||
|
|
||
| # --- Execution --- | ||
|
|
||
| wait_for_env_file | ||
| launch_deploy | ||
| final_message | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can move the software requirements section in here, because it is automatic for those using the web based setup
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well currently the setup scripts (web or cli) attempt to install dependencies but don't do any real pre-checking on the machine specs or dist+version to confirm compatibility. In my mind the Requirements section here is all about the user provisioning the correct VPS instance which is decidedly a step not in scope or otherwise handled by the Deploy Setup product. All to say, I like Requirements where it is, but we maybe could/should enrich it at some point to include notes or links about selecting a VPS provider and provisioning one for Deploy use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was just doing the process now several times today following the documentation and I found it confusing that the requirements section is talking about software requirements (such as docker) which are installed afterwards automatically. I found this was just noise if I was to use the web installer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I appreciate the antidotal report. Even if we're not perfectly representative of our users, conversations based on our own experience I think are easier to navigate than principles sometimes. So I gotcha. Would it be less confusing if the requirements section simply marked the items which were handled by the optional install script?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I personally really prefer the reordering as initially suggested.