feat(docker): implement site container creation #655
No reviewers
Labels
No labels
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
thwap/thwap-pagesd!655
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/docker-container-create"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Implement site container creation for standalone mode (Phase 2, first task). Adds the container-creation primitive to
internal/dockerand the static-server image config.standalone.static_imageconfig (defaultnginx:alpine); wired together withstandalone.base_dirintoStandaloneDeployer./usr/share/nginx/html(per the standalone deployment model's storage resolution; host directories, no named volumes).tpagectl-{site-name}-{version}for production,tpagectl-{site-name}-preview-{branch}for previews, with documented sanitization (invalid chars →-, collapse/strip/truncate).tpagectl.site,tpagectl.version(previewfor previews),tpagectl.preview_branch(previews only),tpagectl.deployed_at(RFC3339).unless-stoppedfor production,on-failurefor previews.StandaloneDeployer.PublishSiteremains not-implemented; the primitive is consumed by Phase 4 deployment wiring (#393), since theDeployerinterface does not yet carry a version.Why
Phase 2 begins container lifecycle management. This task delivers the container-creation capability (image/mount/name/labels/restart policy) that Phase 2 removal (#353), inspection (#357), and Phase 4 deployment build on.
Testing
internal/docker— fake unix-socket daemon answeringPOST /containers/createand/containers/{id}/startcontainerName/sanitizeNametable tests (invalid chars, collapse, strip, truncate, missing fields)internal/config—static_imagedefault + YAML/TOML/env fixturesgo vet ./...clean;go test -race -count=1 ./...full suite, no failuresBreaking Changes
None. New config key; constructor signature of
docker.NewStandaloneDeployerextended internally.Notes
ContainerCreateis invoked with a nil platform argument (host default). Bind mounts follow the design doc's host-directory storage resolution; Docker named volumes are not used in standalone mode.Closes #344
Closes #345
Closes #346
Closes #347
Closes #348
Closes #349
Add the container-creation primitive for standalone mode, creating and starting a static-server container per deployment. - config: add standalone.static_image (default nginx:alpine); wire it and base_dir into the standalone deployer - docker: StandaloneDeployer.CreateSiteContainer builds the container config (image, tracking labels, read-only bind mount of the site directory at /usr/share/nginx/html) and start policy (unless-stopped production, on-failure previews); containerName follows the tpagectl-{site}-{version} / tpagectl-{site}-preview-{branch} convention with documented sanitization - tests: fake unix-socket daemon answers container create/start; asserts image, name, labels, bind mount, restart policy, and error propagation - DOCKER-ROADMAP.md: mark #349 and subtasks complete Closes #344 Closes #345 Closes #346 Closes #347 Closes #348 Closes #349Solid Phase 2 primitive. The create call is correct against the SDK (
ContainerCreatewith nil platform, fixed name), bind mount is read-only at/usr/share/nginx/html, restart policies and tracking labels match the approved deployment model, and sanitization is consistent with site-name validation (lowercase DNS labels enforced at registration, so no lowercase gap). The fake-daemon tests are valid — version negotiation goes through/_ping, so the versioned create/start paths match — and cover the payload, labels, mount, restart policy, error propagation, and naming. Referenced issues #344–#349 are all closed and the roadmap checkboxes match.Suggestions
internal/docker/container_test.go—truncateName(255-char limit) is never exercised;TestContainerName/TestSanitizeNamestop short of the truncation path. Add a long-name boundary test. Filed as #656.internal/docker/container.go—SiteDir(s, version)has no preview counterpart ({baseDir}/sites/{site}/preview-{branch}); Phase 4 preview wiring will need it. Consider aPreviewDir(s, branch)helper. Filed as #657.Questions
network.NetworkingConfig{}, so they join the default bridge rather thantpagectl-net(the model doc's Create step says attached totpagectl-net). Consistent with roadmap sequencing — attach lands with #378 in Phase 3 — but containers created before then will need recreation to join the shared network.No blocking issues. Approving.
Add StandaloneDeployer.PreviewDir so preview asset paths ({baseDir}/sites/{site}/preview-{branch}) stay next to the production SiteDir form, ready for Phase 4 preview wiring. Closes #657New commits pushed, approval review dismissed automatically according to repository settings
Review feedback addressed:
TestTruncateName(short pass-through + long truncation to the 255-char limit) andTestContainerNameTruncatesLongName(end-to-end name exceeding the limit viacontainerName). Commit5c7bb8e.StandaloneDeployer.PreviewDir(s, branch)returning{baseDir}/sites/{site}/preview-{branch}, mirroringSiteDir. Commitefd9fcf.On the two questions:
tpagectl-net: containers intentionally start on the default bridge. Shared-network attachment is Phase 3 (#374/#375/#378); containers created before then would need recreation to jointpagectl-net. Noted in the deployment model doc; deferred by design.Re-review of commit
5c7bb8e. Both suggestions are addressed:TestTruncateName(short pass-through, long name cut to exactly 255) andTestContainerNameTruncatesLongName(end-to-end throughcontainerName, prefix preserved, length == 255) cover the truncation path. Closed.StandaloneDeployer.PreviewDir(s, branch)returns{baseDir}/sites/{site}/preview-{branch}, mirroringSiteDir, verified byTestStandaloneDeployerDirs. Closed.Both questions were answered with documented roadmap-sequenced deferrals (shared-network attach → Phase 3 #374/#375/#378; re-create handling → Phase 4 #350/#395), which is consistent with the deployment model.
No blocking issues and no new findings. Approving.