diff --git a/Dockerfile b/Dockerfile index 4e4628db5..d03af8146 100644 --- a/Dockerfile +++ b/Dockerfile @@ -75,6 +75,7 @@ RUN --mount=type=cache,target=/usr/local/cargo/registry \ FROM python:${PYTHON_VERSION}-slim AS runtime-slim-base ARG RUNTIME_USER=nonroot +ARG RUNTIME_HOME=/home/nonroot ARG PYTHON_SITE_PACKAGES RUN apt-get update && \ @@ -97,12 +98,19 @@ RUN mkdir -p /home/nonroot /data && \ fi USER ${RUNTIME_USER} -WORKDIR /home/nonroot +WORKDIR ${RUNTIME_HOME} ENV HEADROOM_HOST=0.0.0.0 \ PYTHONUNBUFFERED=1 \ PYTHONDONTWRITEBYTECODE=1 +# Declare ~/.headroom as a volume so Docker (and ACA) can attach persistent +# storage here. Bare `docker run` gets an anonymous volume as a fallback so +# state is never silently written to the ephemeral container layer. +# RUNTIME_HOME defaults to /home/nonroot (the published image default); pass +# --build-arg RUNTIME_HOME=/root when building with RUNTIME_USER=root. +VOLUME ${RUNTIME_HOME}/.headroom + EXPOSE 8787 HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 \ @@ -137,4 +145,4 @@ ENTRYPOINT ["python3", "-m", "headroom.cli", "proxy"] CMD ["--host", "0.0.0.0", "--port", "8787"] # Default published image remains python-slim runtime -FROM runtime-slim-base AS runtime +FROM runtime-slim-base AS runtime \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index a3a30316e..dbb8b0f9e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,6 +9,8 @@ services: # - OPENAI_TARGET_API_URL=https://api.x.ai ports: - "8787:8787" + volumes: + - headroom_workspace:/home/nonroot/.headroom healthcheck: test: ["CMD", "curl", "--fail", "--silent", "http://127.0.0.1:8787/readyz"] interval: 30s @@ -46,5 +48,6 @@ services: - NEO4J_apoc_import_file_use__neo4j__config=true volumes: + headroom_workspace: # persists proxy_savings, memory.db, session_stats, toin across image updates qdrant_data: - neo4j_data: + neo4j_data: \ No newline at end of file