All user-level agent state lives under ~/.vibe-trading in the container (persistent memory, sessions.db search index, user-created skills, shadow accounts, hypothesis registry, broker connector config), but docker-compose only mounted volumes for web sessions and backtest runs. Every `docker compose up --build` therefore recreated the container and silently wiped the user's memory store (#197). Swarm run history and uploads were lost the same way. - Mount vibe-home -> /home/vibe/.vibe-trading, plus vibe-swarm-runs and vibe-uploads. - Pre-create /home/vibe/.vibe-trading owned by the service user in the Dockerfile so the named volume inherits writable permissions (a named volume mounted onto a missing path is created root-owned and the non-root user cannot write). - README: document what persists across updates. Verified end-to-end: memory written via PersistentMemory in one container is intact in a fresh container on the same volume; the counterfactual run without the volume reproduces the wipe. Fixes #197.
60 lines
2.1 KiB
Docker
60 lines
2.1 KiB
Docker
# ============================================================================
|
|
# Stage 1: Build frontend
|
|
# ============================================================================
|
|
FROM node:20-slim AS frontend-build
|
|
|
|
WORKDIR /app/frontend
|
|
COPY frontend/package.json frontend/package-lock.json ./
|
|
RUN npm ci --ignore-scripts
|
|
COPY frontend/ ./
|
|
RUN npm run build
|
|
|
|
# ============================================================================
|
|
# Stage 2: Python runtime
|
|
# ============================================================================
|
|
FROM python:3.11-slim AS runtime
|
|
|
|
LABEL org.opencontainers.image.title="Vibe-Trading" \
|
|
org.opencontainers.image.description="Natural-language finance research AI agent with backtesting" \
|
|
org.opencontainers.image.version="0.1.7" \
|
|
org.opencontainers.image.source="https://github.com/HKUDS/Vibe-Trading" \
|
|
org.opencontainers.image.licenses="MIT"
|
|
|
|
WORKDIR /app
|
|
|
|
# System deps
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
build-essential \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Python deps (install before copying code for layer caching)
|
|
COPY agent/requirements.txt agent/requirements.txt
|
|
RUN pip install --no-cache-dir -r agent/requirements.txt
|
|
|
|
# Copy project
|
|
COPY pyproject.toml LICENSE README.md ./
|
|
COPY agent/ agent/
|
|
|
|
# Copy built frontend
|
|
COPY --from=frontend-build /app/frontend/dist frontend/dist
|
|
|
|
# Install CLI entrypoint
|
|
RUN pip install --no-cache-dir -e .
|
|
|
|
# Runtime should not run as root. Keep writable app data directories owned by
|
|
# the service user so named Docker volumes inherit usable permissions.
|
|
RUN useradd --create-home --shell /usr/sbin/nologin vibe \
|
|
&& mkdir -p agent/runs agent/sessions agent/uploads agent/.swarm/runs /home/vibe/.vibe-trading \
|
|
&& chown -R vibe:vibe /app /home/vibe/.vibe-trading
|
|
USER vibe
|
|
|
|
# Default port
|
|
EXPOSE 8899
|
|
|
|
# Health check
|
|
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
|
|
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8899/health')" || exit 1
|
|
|
|
# Run API server (serves frontend/dist as static files)
|
|
CMD ["vibe-trading", "serve", "--host", "0.0.0.0", "--port", "8899"]
|