fix(agent): run container as non-root #40
No files matched your search
@@ -13,11 +13,11 @@ RUN dotnet publish src/Heimdall.Agent/Heimdall.Agent.csproj -c Release --no-rest
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:10.0-noble@sha256:d5633778c754e89a386882eddf8dbee6942447a8a4b8267c19cf1e1158d0b0ac
|
||||
WORKDIR /app
|
||||
RUN apt-get update -qq && apt-get install -y --no-install-recommends ffmpeg wget libgomp1 tzdata && rm -rf /var/lib/apt/lists/*
|
||||
# The agent only needs these diagnostic endpoints for its local healthcheck.
|
||||
# Keep them off the host/container network interfaces by default.
|
||||
RUN install -d -m 0700 -o 1654 -g 1654 /var/lib/heimdall
|
||||
ENV ASPNETCORE_URLS=http://127.0.0.1:8080
|
||||
COPY --from=build /out/ ./
|
||||
COPY models/yolov8n.onnx ./models/yolov8n.onnx
|
||||
EXPOSE 8080
|
||||
HEALTHCHECK --interval=30s --timeout=5s --start-period=30s CMD wget -q --spider http://127.0.0.1:8080/healthz || exit 1
|
||||
USER 1654:1654
|
||||
ENTRYPOINT ["dotnet", "Heimdall.Agent.dll"]
|
||||
@@ -14,3 +14,6 @@ services:
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: docker/Dockerfile.agent
|
||||
|
||||
agent-state-init:
|
||||
image: heimdall-agent:local
|
||||
@@ -187,12 +187,25 @@ services:
|
||||
start_period: 15s
|
||||
volumes:
|
||||
- agent_state:/var/lib/heimdall
|
||||
user: "1654:1654"
|
||||
depends_on:
|
||||
- heimdall
|
||||
heimdall:
|
||||
condition: service_started
|
||||
agent-state-init:
|
||||
condition: service_completed_successfully
|
||||
restart: unless-stopped
|
||||
logging: *default-logging
|
||||
# no networks: host networking
|
||||
|
||||
# Migrate existing root-owned state before starting the non-root agent.
|
||||
agent-state-init:
|
||||
image: eltruncho/heimdall-agent:${AGENT_IMAGE_TAG:-latest}
|
||||
user: "0:0"
|
||||
entrypoint: ["chown", "-R", "1654:1654", "/state"]
|
||||
volumes:
|
||||
- agent_state:/state
|
||||
restart: "no"
|
||||
|
||||
# ── Backup service (opt-in via --profile backup) ───────────────
|
||||
|
||||
backup:
|
||||
|
||||
@@ -114,6 +114,7 @@ services:
|
||||
- heimdall-net
|
||||
|
||||
heimdall-agent:
|
||||
image: heimdall-agent:latest
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: docker/Dockerfile.agent
|
||||
@@ -141,6 +142,7 @@ services:
|
||||
ORT_CUDA_DEVICE_ID: ${AGENT_CUDA_DEVICE_ID:-0}
|
||||
volumes:
|
||||
- agent_state:/var/lib/heimdall
|
||||
user: "1654:1654"
|
||||
# GPU device exposure (NVIDIA CUDA, AMD ROCm, Intel VAAPI/iGPU)
|
||||
# Override in docker-compose.local.yml for specific GPU hardware:
|
||||
# deploy:
|
||||
@@ -171,11 +173,23 @@ services:
|
||||
retries: 3
|
||||
start_period: 15s
|
||||
depends_on:
|
||||
- heimdall
|
||||
heimdall:
|
||||
condition: service_started
|
||||
agent-state-init:
|
||||
condition: service_completed_successfully
|
||||
restart: unless-stopped
|
||||
logging: *default-logging
|
||||
# no networks: host networking
|
||||
|
||||
# Migrate existing root-owned state before starting the non-root agent.
|
||||
agent-state-init:
|
||||
image: heimdall-agent:latest
|
||||
user: "0:0"
|
||||
entrypoint: ["chown", "-R", "1654:1654", "/state"]
|
||||
volumes:
|
||||
- agent_state:/state
|
||||
restart: "no"
|
||||
|
||||
# ── Optional services (dev) ────────────────────────────────────
|
||||
|
||||
coturn:
|
||||
|
||||
@@ -62,6 +62,7 @@
|
||||
image: eltruncho/heimdall-agent:latest
|
||||
container_name: heimdall-agent-{{safeName}}
|
||||
restart: unless-stopped
|
||||
user: "1654:1654"
|
||||
environment:
|
||||
Agent__CentralUrl: {{CentralUrl}}
|
||||
Agent__SiteToken: {{SiteToken}}
|
||||
@@ -70,6 +71,9 @@
|
||||
Agent__StateDirectory: /var/lib/heimdall
|
||||
volumes:
|
||||
- agent_state:/var/lib/heimdall
|
||||
depends_on:
|
||||
agent-state-init:
|
||||
condition: service_completed_successfully
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:8080/healthz"]
|
||||
interval: 30s
|
||||
@@ -77,6 +81,14 @@
|
||||
retries: 3
|
||||
start_period: 15s
|
||||
|
||||
agent-state-init:
|
||||
image: eltruncho/heimdall-agent:latest
|
||||
user: "0:0"
|
||||
entrypoint: ["chown", "-R", "1654:1654", "/state"]
|
||||
volumes:
|
||||
- agent_state:/state
|
||||
restart: "no"
|
||||
|
||||
volumes:
|
||||
agent_state:
|
||||
""";
|
||||
|
||||
Reference in new issue
Block a user