Update Dockerfile

pull/1002/head
CI-DEV 1 month ago committed by GitHub
parent 5f6f8c00e6
commit a7f349cc8d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -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 && \

Loading…
Cancel
Save