feat: add Nextcloud Docker deployment with user provisioning (#146)#150
Open
t0kubetsu wants to merge 3 commits into
Open
feat: add Nextcloud Docker deployment with user provisioning (#146)#150t0kubetsu wants to merge 3 commits into
t0kubetsu wants to merge 3 commits into
Conversation
Two-stage Dockerfile (php:8.3-apache-bookworm builder → nextcloud:latest runtime) with a provisioner sidecar that bootstraps users and app passwords on first run. - Dockerfile: two-stage build; builder installs yq+jq static binaries, runtime inherits nextcloud - compose.yml: db (postgres:16-alpine) + redis (redis:7-alpine) + nextcloud + provisioner with health-chain - provisioning/users.yml: declarative admin/user manifest with display names - provisioning/init.sh: idempotent bootstrap via OCS API (users, admin group, app passwords) - .env.example: all tunable vars documented with safe defaults - Makefile: up/down/build/rebuild/reprovision/tokens/term targets - README.md: quick-start, user declaration, app password retrieval, WebDAV/API usage, env vars, troubleshooting - .dockerignore: prevents .env and key files leaking into build context Security: jq used for JSON construction to prevent injection via crafted display names; wait loop has 180 s timeout; plaintext passwords marked CHANGE BEFORE DEPLOY. App passwords written to /tokens/tokens.txt on nextcloud-tokens volume.
- Fix OCS API: use --data-urlencode form encoding (OCS rejects JSON for user creation) - Fix OCS status: check statuscode in response, fail on unexpected codes - Fix jq source: use jqlang/jq 1.7.1 (stedolan/jq is archived), pin yq to v4.44.1 - Add sleep before app password generation to avoid user-not-ready race - Fix make clean: scope to project only - Add start_period to nextcloud healthcheck
Author
|
All critical and high findings from the PR review have been addressed in commit Fix 1 & 2 — OCS user-create: form-encoded + status code check (CRITICAL)
Fix 1b —
Fix 3 — jq source and version pinning (HIGH)
Fix 4 — Sleep before app password generation (MEDIUM)
Fix 5 —
Fix 7 —
Fix 6 —
|
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.
Summary
Closes #146
php:8.3-apache-bookwormbuilder →nextcloud:latestruntime) with a provisioner sidecar that bootstraps additional users and app passwords on first run via the Nextcloud OCS API.nextcloud-tokens) and retrievable viamake tokens.Changes
yqandjqas static Debian binaries from GitHub releases; runtime stage copies tooling and provisioning scripts intonextcloud:latest.db,redis,nextcloud,provisioner) with health-chain dependencies and commented debug anchor.admins[]/users[]manifest (username, email, password, display_name)./status.phphealth, creates users via OCS v1 API, promotes admins to theadmingroup, generates app passwords via OCS v2 API, writes to/tokens/tokens.txt, stamps/tokens/.provisioned.up / down / build / rebuild / reprovision / logs-provisioner / tokens / termtargets matching the gitea reference pattern..envand key files from leaking into the build context.Design Notes
php:8.3-apache-bookworm(builder) matches the official Nextcloud Dockerfile lineage;nextcloud:latest(runtime) is the official PHP/Apache/Debian image — no Ubuntu.NEXTCLOUD_ADMIN_USER/NEXTCLOUD_ADMIN_PASSWORDenv vars trigger Nextcloud's built-in auto-setup; no CLI bootstrap needed for the first admin.POST /ocs/v1.php/cloud/users; app passwords viaPOST /ocs/v2.php/core/apppasswordauthenticated as each provisioned user./tokens/.provisioned— safe to restart;make reprovisionremoves the volume to force re-run.Testing
make build— provisioner image builds without errorsmake build-up— full stack starts, Nextcloud health check passesmake logs-provisioner— all users created, app passwords generatedmake tokens— tokens.txt readable, no ERROR entriesmake reprovision— removes volume, re-runs provisioner idempotentlyRelated Issues