Files
pruefwerk/docker/agent-entrypoint.sh
T
sharang 0444f18a8e
CI / Check (push) Skipped
CI / Detect Changes (push) Successful in 3s
CI / Deploy Docs (push) Successful in 1m12s
CI / Deploy MCP (push) Successful in 4m0s
CI / Deploy Dashboard (push) Successful in 6m25s
CI / Deploy Agent (push) Successful in 9m12s
feat(platform): harden the container images (#261) (#307)
2026-09-21 17:28:23 +00:00

31 lines
1.3 KiB
Bash

#!/usr/bin/env bash
# Check the agent can write where it keeps data, seed the OSCAL snapshot, then
# run the agent.
set -euo pipefail
# The agent runs as an unprivileged user. A volume mounted over a data
# directory keeps the ownership it was created with, so a volume made by an
# older image that ran as root is not writable. Say how to fix it instead of
# failing on the first upload.
for dir in "${ARTIFACT_STORE_BASE_PATH:?}" "${BREAKPILOT_SNAPSHOT_DIR:?}"; do
if ! mkdir -p "$dir" 2>/dev/null || [ ! -w "$dir" ]; then
echo "agent-entrypoint: $dir is not writable by uid $(id -u)." >&2
echo "agent-entrypoint: fix the volume once with: chown -R $(id -u):$(id -g) <volume>" >&2
exit 1
fi
done
# Seed the OSCAL control-catalog snapshot. The image ships a catalog snapshot so
# control mapping works without the breakpilot-compliance backend
# (BREAKPILOT_BASE_URL unset). Copy-if-absent, so a snapshot refreshed from a
# live backend (or a mounted volume) always wins.
for f in /opt/breakpilot/oscal-snapshot/*.json; do
[ -e "$f" ] || continue
if [ ! -e "$BREAKPILOT_SNAPSHOT_DIR/$(basename "$f")" ]; then
cp "$f" "$BREAKPILOT_SNAPSHOT_DIR/" \
&& echo "agent-entrypoint: seeded $(basename "$f") into $BREAKPILOT_SNAPSHOT_DIR"
fi
done
exec compliance-agent "$@"