memory/docker/api/Dockerfile
mruwnik f0195464c8 Complete bug investigation and fix unused appuser in Dockerfile
Investigation complete - verified 35+ bugs as fixed or non-issues:

Medium severity verified:
- BUG-018: N/A - intentional TODO comments for future features
- BUG-022: Low priority - sync_book properly chunks, only extract_ebook affected
- BUG-025: Acceptable - 4 chars/token is common approximation
- BUG-029: N/A - intentional score thresholds documented
- BUG-036: Acceptable - IntegrityError handling correct
- BUG-038: N/A - standard single beat process practice

Low severity fixed:
- BUG-056: Removed unused appuser from Dockerfile

Remaining valid issues documented for future work:
- BUG-002: Collection mismatch (needs data verification)
- BUG-026: BM25 scores discarded
- BUG-030: Rate limiting
- BUG-032: CSRF protection

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-19 20:53:53 +00:00

62 lines
1.4 KiB
Docker

# Backend base stage
FROM python:3.12-slim AS backend-base
WORKDIR /app
# Install build dependencies
RUN apt-get update && apt-get install -y \
gcc \
g++ \
python3-dev \
curl \
&& rm -rf /var/lib/apt/lists/*
# Copy and install Python requirements
COPY requirements ./requirements/
RUN mkdir src
COPY setup.py ./
# Do an initial install to get the dependencies cached
RUN pip install -e ".[api]"
# Frontend build stage
FROM node:18-alpine AS frontend-builder
WORKDIR /frontend
COPY frontend/package*.json ./
RUN npm install
COPY frontend/ ./
# Set Vite environment variables for build from build args
ARG SERVER_URL
ARG SESSION_COOKIE_NAME
ENV VITE_SERVER_URL=${SERVER_URL}
ENV VITE_SESSION_COOKIE_NAME=${SESSION_COOKIE_NAME}
RUN npm run build
# Final stage
FROM backend-base
# Install the package with Python source code
COPY src/ ./src/
RUN pip install -e ".[api]"
# Copy frontend build output from frontend stage
COPY --from=frontend-builder /frontend/dist ./static/
# Create directories for app
RUN mkdir -p /app/memory_files
ENV PYTHONPATH="/app"
# Create user and set permissions
RUN useradd -m kb
RUN mkdir -p /var/cache/fontconfig /home/kb/.cache/fontconfig && \
chown -R kb:kb /var/cache/fontconfig /home/kb/.cache/fontconfig /app
USER kb
# Set environment variables
ENV PORT=8000
EXPOSE 8000
CMD ["uvicorn", "memory.api.app:app", "--host", "0.0.0.0", "--port", "8000", "--proxy-headers", "--forwarded-allow-ips", "*"]