Skip to content

build(container): add production-ready wrapper image - #11

Merged
korayakpinar merged 11 commits into
feat/flexible-deployment-phase-2from
feat/flexible-deployment-phase-3
Aug 5, 2026
Merged

korayakpinar merged 11 commits into
feat/flexible-deployment-phase-2from
feat/flexible-deployment-phase-3

Conversation

@korayakpinar

@korayakpinar korayakpinar commented Aug 3, 2026 •

Copy link
Copy Markdown
Member

Summary

This PR turns the idempotent runtime introduced in #10 into a production-oriented container artifact.

It adds a native query-readiness healthcheck, deterministic build metadata, a pinned multi-stage non-root image, reproducibility checks, and container-level lifecycle and isolation tests.

This is the top PR in the flexible archive-wrapper deployment stack.

Native Healthcheck

The binary now provides:

archive-wrapper healthcheck [--config <path>] [--address <host:port>] [--timeout <duration>]

The healthcheck calls the standard gRPC health service for query.Query. Only SERVING exits with status 0; NOT_SERVING, UNKNOWN, connection failure, timeout, and invalid configuration exit non-zero.

Address resolution follows:

--address
ARCHIVE_WRAPPER_HEALTHCHECK_ADDRESS
ARCHIVE_WRAPPER_GRPC_LISTEN_ADDRESS
YAML grpc_listen_address

An explicit address does not require a config file. Wildcard bind addresses are converted to loopback dial targets inside the container:

0.0.0.0 -> 127.0.0.1
::      -> ::1

The default timeout is three seconds. Healthcheck and version commands are dispatched before runtime logger initialization, so short-lived probes do not create log files.

Build Metadata

The binary now exposes stable version information:

archive-wrapper version

Version, commit SHA, and build date are injected with linker flags. Runtime startup logs carry the same fields.

Build dates derive from the source commit timestamp rather than wall-clock time, supporting reproducible artifacts.

Container Image

The new root-level Dockerfile uses pinned builder and runtime images and supports:

linux/amd64
linux/arm64

The runtime image:

  • Uses a distroless base
  • Contains no shell or package manager
  • Runs as UID/GID 65532:65532
  • Uses a read-only root filesystem
  • Defaults to archive-wrapper run
  • Uses SIGTERM as the stop signal
  • Exposes the gRPC port without publishing it
  • Includes the native query healthcheck
  • Contains no config, genesis, PostgreSQL URI, .env, LevelDB state, or log file

The expected runtime mounts are:

Path Access Purpose
/etc/archive-wrapper/config.yaml Read-only Wrapper configuration
/var/lib/pulsar Read-only Pulsar home and genesis
/var/lib/archive-wrapper Read-write volume Persistent LevelDB state
/run/archive-wrapper Read-write tmpfs Control socket

The image pre-creates its data directory with non-root ownership so newly created named volumes work without an init container. Operators using bind mounts must provide matching host ownership.

Reproducible Builds

The build uses:

  • Pinned base image digests
  • CGO_ENABLED=0
  • The repository's purego build tag
  • -trimpath
  • -buildvcs=false
  • Source-derived timestamps
  • OCI timestamp rewriting
  • Disabled provenance attestations for byte-stable local exports

Make targets verify both binary and OCI image reproducibility.

Container Lifecycle Contract

The same image and run command are used for fresh boot and restart.

The image supports:

  • Fresh LevelDB initialization
  • Restart from persisted metadata and cursor
  • PostgreSQL-unavailable startup without process termination
  • Readiness withdrawal during PostgreSQL loss
  • Automatic recovery after PostgreSQL reconnect
  • Bounded graceful shutdown
  • LevelDB lock rejection for a second owner

PostgreSQL connectivity alone does not produce readiness. The query service becomes SERVING only after successful reconciliation has produced or recovered a usable cursor.

Container Test Harness

The deterministic Compose fixture verifies:

  • Fresh startup and initial catch-up
  • PostgreSQL loss and recovery
  • Restart persistence
  • SIGTERM shutdown behavior
  • Control socket cleanup
  • LevelDB lock enforcement
  • Non-root execution
  • Read-only root filesystem compatibility
  • Absence of default log files
  • Secret redaction
  • Image content and build metadata
  • Three concurrent gRPC clients using one wrapper
  • Three independent wrappers using isolated LevelDB volumes
  • Failure isolation and restart of one wrapper instance

Each test uses a unique Compose project and removes only its own containers and volumes.

CI

The new container workflow:

  • Runs Go unit, race, and vet checks
  • Builds native and multi-platform artifacts
  • Runs the container lifecycle and isolation suite
  • Verifies image metadata and reproducibility
  • Uploads diagnostic artifacts on failure
  • Does not authenticate to or push images into a registry

Documentation

docs/container.md documents the complete image contract, including mounts, ownership, startup, shutdown, health behavior, transport limitations, image pinning, and local validation commands.

Pulsar topology generation and full Pulsar-wrapper E2E orchestration are intentionally handled in the subsequent Pulsar integration phase rather than this wrapper artifact PR.

Validation

The current stack has been validated with:

GOCACHE=/tmp/go-build-cache go test -tags=purego ./... -count=1
GOCACHE=/tmp/go-build-cache go test -race -tags=purego ./... -count=1
GOCACHE=/tmp/go-build-cache go vet -tags=purego ./...
make lint
make docker-test
go mod tidy -diff
git diff --check

The container lifecycle, concurrent-client, and wrapper-isolation smoke tests pass.

Stack

@korayakpinar korayakpinar changed the title feat/flexible deployment phase 3 build(container): add production-ready wrapper image Aug 3, 2026
@korayakpinar
korayakpinar requested a review from yusufozmis August 3, 2026 14:48
@korayakpinar
korayakpinar force-pushed the feat/flexible-deployment-phase-3 branch from f8fcc1b to d722623 Compare August 5, 2026 16:05
@korayakpinar
korayakpinar force-pushed the feat/flexible-deployment-phase-3 branch from d722623 to 50f8c75 Compare August 5, 2026 16:42
@korayakpinar
korayakpinar merged commit 7674e76 into development Aug 5, 2026
2 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants