6.7 KiB
6.7 KiB
TASK METADATA
- Target Files:
spire/Dockerfile.serverspire/Dockerfile.agentspire/entrypoint.server.shspire/entrypoint.agent.shspire/templates/server.confspire/templates/agent.confinfra/compose.spire.ymlinfra/setup.tsinfra/.env
- Core Objective: Package standalone, generic Smart SPIRE Server and Agent container images with self-seeding configuration entrypoints, and simplify the stack to a 1-host-volume persistent layout with a dedicated named socket volume for cross-stack zero-trust IPC.
- Dependencies:
- Upstream SPIRE binaries (
ghcr.io/spiffe/spire-server:1.9.3andghcr.io/spiffe/spire-agent:1.9.3) - Minimal Alpine base image (
${REG}/library/alpine:3.20)
- Upstream SPIRE binaries (
- Additional Important Notes:
- SPIRE must remain 100% decoupled and generic (named
spire-serverandspire-agent, not prefixed withauth-yes). - No inline shell scripts, heredocs, or temporary
inithelper containers incompose.spire.yml. - Storing configuration files on the persistent host volume ensures full user editability while preventing upgrades from overwriting user customizations.
- SPIRE must remain 100% decoupled and generic (named
Architectural Considerations & Risks
Risks
- Root CA Private Key Exposure: If client workloads (e.g.
auth-api) mount the entire host SPIRE storage volume to reachagent.sock, they could potentially readkeys.json(server CA private keys) or SQLite databases.- Mitigation: The Workload API UNIX domain socket is written to and shared
via a dedicated named volume (
spire-socket), which only exposesagent.sockto client containers.
- Mitigation: The Workload API UNIX domain socket is written to and shared
via a dedicated named volume (
- Stale UNIX Socket on Unclean Shutdown: An abrupt host crash or power loss
may leave a dead
agent.sockfile on disk.- Mitigation:
entrypoint.agent.shunconditionally runsrm -f /var/run/spire/agent.sockbefore launchingspire-agent.
- Mitigation:
- Database File Locking over Network Mounts: SQLite datastores can suffer
locking issues over NFS/CIFS.
- Mitigation:
SPIRE_DATA_PATHdefaults to local filesystem/volume1/docker/spire(ext4/Btrfs).
- Mitigation:
Alternatives Considered
- Inline Compose Scripting (
spire-inithelper container): Rejected. Putting multi-line heredocs and shell scripts insidecompose.spire.ymlis fragile across orchestrators (Portainer, Podman), pollutes compose files, and degrades developer experience. - Separate Conf/Data Volumes (4+ volume mounts): Rejected. Mounting
individual subfolders (
server/conf,server/data,agent/conf,agent/data) introduces unnecessary configuration complexity. A single host root volume (/volume1/docker/spire) containingserver.conf,agent.conf, anddata/subdirectories provides the cleanest DX.
Proposed Implementation
Phase 1: Create Generic SPIRE Smart Container Module (spire/)
Create the decoupled spire/ directory with self-bootstrapping Dockerfiles,
entrypoints, and master configuration templates:
spire/
├── Dockerfile.server # Generic SPIRE Server Image
├── Dockerfile.agent # Generic SPIRE Agent Image
├── entrypoint.server.sh # Self-seeding bootstrap entrypoint
├── entrypoint.agent.sh # Self-seeding bootstrap entrypoint & stale socket cleanup
└── templates/
├── server.conf # Master commented configuration template
└── agent.conf # Master commented configuration template
1. spire/Dockerfile.server
- Multi-stage build extracting
spire-serverbinary fromghcr.io/spiffe/spire-server:1.9.3intoalpine:3.20. - Bakes master template into
/etc/spire/templates/server.conf. - Sets
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]andCMD ["run", "-config", "/opt/spire/server.conf"].
2. spire/entrypoint.server.sh
- Checks if
/opt/spire/server.confexists on the mounted volume. - If missing, copies
/etc/spire/templates/server.confto/opt/spire/server.confwithchmod 644. - Creates
/opt/spire/data/serverdatastore directory. exec /usr/local/bin/spire-server "$@".
3. spire/Dockerfile.agent
- Multi-stage build extracting
spire-agentbinary fromghcr.io/spiffe/spire-agent:1.9.3intoalpine:3.20. - Bakes master template into
/etc/spire/templates/agent.conf. - Sets
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]andCMD ["run", "-config", "/opt/spire/agent.conf"].
4. spire/entrypoint.agent.sh
- Removes any stale
/var/run/spire/agent.sockfile. - Checks if
/opt/spire/agent.confexists on the mounted volume. - If missing, copies
/etc/spire/templates/agent.confto/opt/spire/agent.confwithchmod 644. - Creates
/opt/spire/data/agentcache directory and/var/run/spire. exec /usr/local/bin/spire-agent "$@".
5. spire/templates/server.conf & spire/templates/agent.conf
- Heavily commented HCL templates configuring trust domain (
system.local), SQLite datastore (/opt/spire/data/server/datastore.sqlite3), key storage, and Docker workload attestor.
Phase 2: Ultra-Clean Compose Configuration (infra/compose.spire.yml)
Update
infra/compose.spire.yml
to use the 1-volume host layout and named socket volume:
version: "3.8"
services:
spire-server:
image: ${REG}/library/spire-server:latest
container_name: spire-server
hostname: spire-server
networks:
- auth-internal-net
volumes:
- spire-data:/opt/spire
spire-agent:
image: ${REG}/library/spire-agent:latest
container_name: spire-agent
hostname: spire-agent
pid: host
depends_on:
- spire-server
networks:
- auth-internal-net
volumes:
- spire-data:/opt/spire
- spire-socket:/var/run/spire
- /var/run/docker.sock:/var/run/docker.sock:ro
volumes:
spire-data:
driver: local
driver_opts:
type: none
device: ${SPIRE_DATA_PATH}
o: bind
spire-socket:
name: spire-socket
networks:
auth-internal-net:
external: true
Phase 3: Setup CLI & Build Pipeline Integration (infra/setup.ts)
Update generateBuildCommands in
infra/setup.ts to build
all stack images:
auth-yes-api:latest(Dockerfile)spire-server:latest(spire/Dockerfile.server)spire-agent:latest(spire/Dockerfile.agent)
Update DEFAULT_AUTH_CONFIG:
dbDataPath: "/volume1/docker/auth-yes/data"spireDataPath: "/volume1/docker/spire"
Phase 4: Quality Gates & Verification
- Run
deno fmtanddeno task lint. - Run
deno task checkacross all modules. - Run
deno test -Ato verify unit and integration tests. - Verify image build commands via
podman buildtest.