fix(docker): create the first admin declaratively on compose deploys#175
Open
shani-singh1 wants to merge 1 commit into
Open
fix(docker): create the first admin declaratively on compose deploys#175shani-singh1 wants to merge 1 commit into
shani-singh1 wants to merge 1 commit into
Conversation
A fresh `docker compose up` had no supported way to create the first administrator through the web flow: public sign-up is disabled, and the loopback bootstrap shortcut never fires because the request reaches the API from a Docker-bridge IP rather than 127.0.0.1 (issue oblien#138). Add an optional one-shot `init-admin` service that calls the existing internal-token-gated `POST /api/system/bootstrap-admin` endpoint — the same path the CLI wizard uses — with credentials the operator declares in `.env` (`OPENSHIP_ADMIN_NAME` / `_EMAIL` / `_PASSWORD`). - No-op unless the admin vars are set, so nothing changes for operators who create the admin another way. - Does not enable public sign-up; reuses the invite-only bootstrap path. - Idempotent: bootstrap-admin returns 409 once an admin exists, which the script treats as success, so re-running compose never mutates an admin. Closes oblien#138.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
On a fresh Docker Compose deployment there's no supported way to create the first admin through the web flow. Public sign-up is disabled on self-hosted instances, and the loopback bootstrap shortcut in the sign-up guard never fires because the request reaches the API from a Docker-bridge IP (e.g.
172.18.x.x) rather than127.0.0.1, so it always returnsSIGNUP_DISABLED.openship up's interactive wizard has no Compose equivalent.Fixes #138.
Approach
This follows the direction discussed in #138 (declarative credentials at start, endorsed by @Hydralerne) and reuses the exact mechanism the CLI already relies on — the internal-token-gated, one-shot
POST /api/system/bootstrap-adminendpoint. Public sign-up is not touched.An optional one-shot
init-adminCompose service runs once the API is healthy and creates the first admin from credentials the operator declares in.env:Properties:
0, so nothing changes for operators who create the admin another way.depends_onis one-directional; no other service waits on it.INTERNAL_TOKEN. It does not enable public registration.bootstrap-adminreturns409once an admin exists, which the script treats as success, so re-runningdocker compose upnever mutates an existing admin.Changes
scripts/docker-init-admin.sh— the bootstrap script (POSIXsh; JSON body is escaped for embedded quotes/backslashes).docker-compose.yml— theinit-adminservice (pinnedcurlimages/curl, mounts the script read-only, waits forapihealth, then exits)..env.example— documents the optionalOPENSHIP_ADMIN_*vars.docs/installation.md— a "Create the first admin" note in the Docker section.Testing
docker compose configrenders cleanly;init-adminreceivesINTERNAL_TOKENandOPENSHIP_API_URL.sh -n/bash -nsyntax-check pass.bootstrap-admincontract covering every branch: vars-unset skip, successful create (incl. a password with embedded"and\to confirm JSON escaping), idempotent409re-run,401wrong-token, missing-INTERNAL_TOKENabort, and unreachable-API. Success/skip paths exit0; error paths exit non-zero without blocking the rest of the stack.Notes for reviewers
restart: "no", nothing depends on it), so an error state surfaces as anExited (1)container without affecting the API/dashboard.