Skip to content

Commit

Permalink
docker fix
Browse files Browse the repository at this point in the history
  • Loading branch information
kyegomez committed Feb 4, 2025
1 parent ceffa6f commit 2e6b2df
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 34 deletions.
51 changes: 18 additions & 33 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,57 +1,42 @@
# 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 \
g++ \
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
CMD python -c "import swarms; print('Health check passed')" || exit 1
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>"]
Expand Down Expand Up @@ -76,6 +76,8 @@ aiofiles = "*"
clusterops = "*"
# chromadb = "*"
rich = "*"
numpy = "*"
litellm = "*"
# sentence-transformers = "*"


Expand Down

0 comments on commit 2e6b2df

Please sign in to comment.