Files
lollms_hub/Dockerfile
Saifeddine ALOUI 65a530f1e7 refactor(docker): optimize multi-stage build for production
- Split into dedicated builder and runtime stages
- Move gunicorn install to runtime stage
- Add python3-dev and libcairo2 to their respective stages
- Use COPY --from=builder for dependencies instead of venv
- Simplify permission setup with recursive chown
- Remove redundant comments and streamline layer ordering
2026-04-14 23:33:13 +02:00

46 lines
1010 B
Docker

# --- Builder Stage ---
FROM python:3.13-slim AS builder
WORKDIR /app
RUN apt-get update && apt-get install -y \
build-essential \
pkg-config \
libcairo2-dev \
python3-dev \
&& rm -rf /var/lib/apt/lists/*
RUN pip install --no-cache-dir poetry
COPY pyproject.toml ./
RUN poetry config virtualenvs.create false && \
poetry install --without dev --no-root --no-interaction --no-ansi
# --- Runtime Stage ---
FROM python:3.13-slim
WORKDIR /home/app
RUN apt-get update && apt-get install -y \
libcairo2 \
&& rm -rf /var/lib/apt/lists/*
RUN pip install --no-cache-dir gunicorn
RUN addgroup --system app && adduser --system --group app
COPY --from=builder /usr/local/lib/python3.13 /usr/local/lib/python3.13
COPY --from=builder /usr/local/bin /usr/local/bin
COPY ./app ./app
COPY gunicorn_conf.py .
RUN mkdir -p ./app/static/uploads ./.ssl ./benchmarks && \
chown -R app:app /home/app
USER app
EXPOSE 8080
CMD ["gunicorn", "-c", "./gunicorn_conf.py", "app.main:app"]