From 2e6b2df013ff112647f6e94bd27ccaa82121bff4 Mon Sep 17 00:00:00 2001 From: Kye Gomez Date: Tue, 4 Feb 2025 16:33:58 -0500 Subject: [PATCH] docker fix --- Dockerfile | 51 ++++++++--------------- deepseek_r1.py => examples/deepseek_r1.py | 0 o3_mini.py => examples/fast_r1_groq.py | 0 simple_example.py => examples/o3_mini.py | 0 pyproject.toml | 4 +- 5 files changed, 21 insertions(+), 34 deletions(-) rename deepseek_r1.py => examples/deepseek_r1.py (100%) rename o3_mini.py => examples/fast_r1_groq.py (100%) rename simple_example.py => examples/o3_mini.py (100%) diff --git a/Dockerfile b/Dockerfile index d9ec88b3..0810481f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,20 @@ -# Use Python 3.11 slim-bullseye for smaller base image -FROM python:3.11-slim-bullseye AS builder +# Use Python 3.11 slim-bullseye for a smaller base image +FROM python:3.11-slim-bullseye -# Set environment variables +# Set environment variables for Python and pip ENV PYTHONDONTWRITEBYTECODE=1 \ PYTHONUNBUFFERED=1 \ PIP_NO_CACHE_DIR=1 \ - PIP_DISABLE_PIP_VERSION_CHECK=1 + PIP_DISABLE_PIP_VERSION_CHECK=1 \ + WORKSPACE_DIR="agent_workspace" \ + PATH="/app:${PATH}" \ + PYTHONPATH="/app:${PYTHONPATH}" \ + USER=swarms # Set the working directory -WORKDIR /build +WORKDIR /app -# Install only essential build dependencies +# Install essential build dependencies RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential \ gcc \ @@ -18,40 +22,21 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ gfortran \ && rm -rf /var/lib/apt/lists/* -# Install swarms packages -RUN pip install --no-cache-dir swarm-models swarms -RUN pip install transformers torch litellm tiktoken openai pandas numpy pypdf - +# Install required Python packages +RUN pip install --no-cache-dir swarm-models swarms && \ + pip install --no-cache-dir transformers torch litellm tiktoken openai pandas numpy pypdf -# Production stage -FROM python:3.11-slim-bullseye - -# Set secure environment variables -ENV PYTHONDONTWRITEBYTECODE=1 \ - PYTHONUNBUFFERED=1 \ - WORKSPACE_DIR="agent_workspace" \ - PATH="/app:${PATH}" \ - PYTHONPATH="/app:${PYTHONPATH}" \ - USER=swarms - -# Create non-root user +# Create a non-root user and set correct permissions for the application directory RUN useradd -m -s /bin/bash -U $USER && \ mkdir -p /app && \ chown -R $USER:$USER /app -# Set working directory -WORKDIR /app - -# Copy only necessary files from builder -COPY --from=builder /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages -COPY --from=builder /usr/local/bin /usr/local/bin - -# Copy application with correct permissions +# Copy application files into the image with proper ownership COPY --chown=$USER:$USER . . -# Switch to non-root user +# Switch to the non-root user USER $USER -# Health check +# Health check to ensure the container is running properly HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \ - CMD python -c "import swarms; print('Health check passed')" || exit 1 \ No newline at end of file + CMD python -c "import swarms; print('Health check passed')" || exit 1 diff --git a/deepseek_r1.py b/examples/deepseek_r1.py similarity index 100% rename from deepseek_r1.py rename to examples/deepseek_r1.py diff --git a/o3_mini.py b/examples/fast_r1_groq.py similarity index 100% rename from o3_mini.py rename to examples/fast_r1_groq.py diff --git a/simple_example.py b/examples/o3_mini.py similarity index 100% rename from simple_example.py rename to examples/o3_mini.py diff --git a/pyproject.toml b/pyproject.toml index 4510a6a1..1c6c6926 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ build-backend = "poetry.core.masonry.api" [tool.poetry] name = "swarms" -version = "7.0.9" +version = "7.1.1" description = "Swarms - TGSC" license = "MIT" authors = ["Kye Gomez "] @@ -76,6 +76,8 @@ aiofiles = "*" clusterops = "*" # chromadb = "*" rich = "*" +numpy = "*" +litellm = "*" # sentence-transformers = "*"