From a7f349cc8db38ec7646fc22b0c543a2557d73045 Mon Sep 17 00:00:00 2001 From: CI-DEV <154627941+IlumCI@users.noreply.github.com> Date: Fri, 1 Aug 2025 12:24:25 +0300 Subject: [PATCH] Update Dockerfile --- Dockerfile | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index aa312517..44392b09 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,25 +1,37 @@ -# Use a lightweight Python image +# Multi-stage build for optimized Docker image +FROM python:3.11-slim-bullseye as builder + +# Install system dependencies for building +RUN apt-get update && apt-get install -y --no-install-recommends \ + build-essential gcc curl \ + && rm -rf /var/lib/apt/lists/* + +# Install UV for faster package management +RUN curl -LsSf https://astral.sh/uv/install.sh | sh +ENV PATH="/root/.cargo/bin:${PATH}" + +# Create a virtual environment and install dependencies +RUN uv venv /opt/venv +ENV PATH="/opt/venv/bin:$PATH" + +# Install the swarms package using UV +RUN uv pip install --system -U swarms + +# Final stage FROM python:3.11-slim-bullseye # Environment config for speed and safety ENV PYTHONDONTWRITEBYTECODE=1 \ PYTHONUNBUFFERED=1 \ - PIP_NO_CACHE_DIR=1 \ - PIP_DISABLE_PIP_VERSION_CHECK=1 \ - PATH="/app:${PATH}" \ + PATH="/opt/venv/bin:${PATH}" \ PYTHONPATH="/app:${PYTHONPATH}" \ USER=swarms # Set working directory WORKDIR /app -# System dependencies (minimal) -RUN apt-get update && apt-get install -y --no-install-recommends \ - build-essential gcc \ - && rm -rf /var/lib/apt/lists/* - -# Install the swarms package -RUN pip install --upgrade pip && pip install -U swarms +# Copy virtual environment from builder stage +COPY --from=builder /opt/venv /opt/venv # Add non-root user RUN useradd -m -s /bin/bash -U $USER && \