memos/Dockerfile

51 lines
1.1 KiB
Docker

# MemOS Production Dockerfile
# Multi-stage build with optimizations
# Stage 1: Install dependencies
FROM python:3.11-slim AS builder
RUN apt-get update && apt-get install -y \
gcc \
g++ \
build-essential \
libffi-dev \
python3-dev \
curl \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /build
COPY docker/requirements.txt .
RUN pip install --upgrade pip && \
pip install --prefix=/install --no-cache-dir -r requirements.txt
# Stage 2: Runtime image
FROM python:3.11-slim
RUN apt-get update && apt-get install -y \
curl \
&& rm -rf /var/lib/apt/lists/* \
&& useradd -m -u 1000 memos
WORKDIR /app
ENV HF_ENDPOINT=https://hf-mirror.com
ENV PYTHONPATH=/app/src
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
COPY --from=builder /install /usr/local
COPY src/ ./src
COPY docker/ ./docker
RUN chown -R memos:memos /app
USER memos
EXPOSE 8000
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://localhost:8000/health || exit 1
CMD ["uvicorn", "memos.api.server_api:app", "--host", "0.0.0.0", "--port", "8000"]