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 01/33] 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 && \ From 13e7d5b20b1fe6fdbb447ab5e44678fde7b18b7e Mon Sep 17 00:00:00 2001 From: CI-DEV <154627941+IlumCI@users.noreply.github.com> Date: Fri, 1 Aug 2025 12:26:55 +0300 Subject: [PATCH 02/33] Update docker-publish.yml --- .github/workflows/docker-publish.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 34372b3e..40fac9cb 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -58,6 +58,7 @@ jobs: type=semver,pattern={{major}}.{{minor}} type=semver,pattern={{major}} type=sha + type=raw,value=latest,enable={{is_default_branch}} # Build and push Docker image - name: Build and push Docker image @@ -71,3 +72,5 @@ jobs: platforms: linux/amd64,linux/arm64 cache-from: type=gha cache-to: type=gha,mode=max + build-args: | + BUILDKIT_INLINE_CACHE=1 From 6f5496a48db4e450c75fba6fc808fb595c3d27d2 Mon Sep 17 00:00:00 2001 From: CI-DEV <154627941+IlumCI@users.noreply.github.com> Date: Fri, 1 Aug 2025 12:30:26 +0300 Subject: [PATCH 03/33] Add files via upload --- docker-compose.yml | 71 ++++++++++++++++++++++++++++++++++++++++++++++ test_docker.py | 65 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 136 insertions(+) create mode 100644 docker-compose.yml create mode 100644 test_docker.py diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..8e4f2360 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,71 @@ +version: '3.8' + +services: + swarms: + build: + context: . + dockerfile: Dockerfile + image: swarms:latest + container_name: swarms-container + environment: + - PYTHONUNBUFFERED=1 + - PYTHONPATH=/app + # Add your API keys here or use .env file + # - OPENAI_API_KEY=${OPENAI_API_KEY} + # - ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY} + # - GOOGLE_API_KEY=${GOOGLE_API_KEY} + volumes: + - .:/app + - ./data:/app/data + - ./models:/app/models + working_dir: /app + command: python test_docker.py + restart: unless-stopped + healthcheck: + test: ["CMD", "python", "-c", "import swarms; print('Health check passed')"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s + + swarms-dev: + build: + context: . + dockerfile: Dockerfile + image: swarms:dev + container_name: swarms-dev-container + environment: + - PYTHONUNBUFFERED=1 + - PYTHONPATH=/app + volumes: + - .:/app + - ./data:/app/data + - ./models:/app/models + working_dir: /app + command: bash + stdin_open: true + tty: true + restart: unless-stopped + + swarms-api: + build: + context: . + dockerfile: Dockerfile + image: swarms:api + container_name: swarms-api-container + environment: + - PYTHONUNBUFFERED=1 + - PYTHONPATH=/app + volumes: + - .:/app + working_dir: /app + ports: + - "8000:8000" + command: python -m uvicorn main:app --host 0.0.0.0 --port 8000 --reload + restart: unless-stopped + depends_on: + - swarms + +networks: + default: + name: swarms-network \ No newline at end of file diff --git a/test_docker.py b/test_docker.py new file mode 100644 index 00000000..4733fc0d --- /dev/null +++ b/test_docker.py @@ -0,0 +1,65 @@ +#!/usr/bin/env python3 +""" +Test script to verify Swarms installation in Docker container. +""" + +import sys +from typing import Dict, Any + +def test_swarms_import() -> Dict[str, Any]: + """ + Test that swarms can be imported and basic functionality works. + + Returns: + Dict[str, Any]: Test results + """ + try: + import swarms + print(f"✅ Swarms imported successfully. Version: {swarms.__version__}") + + # Test basic functionality + from swarms import Agent + print("✅ Agent class imported successfully") + + return { + "status": "success", + "version": swarms.__version__, + "message": "Swarms package is working correctly" + } + + except ImportError as e: + print(f"❌ Failed to import swarms: {e}") + return { + "status": "error", + "error": str(e), + "message": "Swarms package import failed" + } + except Exception as e: + print(f"❌ Unexpected error: {e}") + return { + "status": "error", + "error": str(e), + "message": "Unexpected error occurred" + } + +def main() -> None: + """Main function to run tests.""" + print("🐝 Testing Swarms Docker Image...") + print("=" * 50) + + # Test Python version + print(f"Python version: {sys.version}") + + # Test swarms import + result = test_swarms_import() + + print("=" * 50) + if result["status"] == "success": + print("🎉 All tests passed! Docker image is working correctly.") + sys.exit(0) + else: + print("💥 Tests failed! Please check the Docker image.") + sys.exit(1) + +if __name__ == "__main__": + main() \ No newline at end of file From 0c410052b026a5d45802baf1db40f3312cdffe1f Mon Sep 17 00:00:00 2001 From: CI-DEV <154627941+IlumCI@users.noreply.github.com> Date: Fri, 1 Aug 2025 12:30:50 +0300 Subject: [PATCH 04/33] Add files via upload --- DOCKER.md | 225 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 225 insertions(+) create mode 100644 DOCKER.md diff --git a/DOCKER.md b/DOCKER.md new file mode 100644 index 00000000..0b2ec1fb --- /dev/null +++ b/DOCKER.md @@ -0,0 +1,225 @@ +# Swarms Docker Image + +This repository includes a Docker image for running Swarms, an AI agent framework. The image is automatically built and published to DockerHub on every push to the main branch and on version tags. + +## 🐳 Quick Start + +### Pull and Run + +```bash +# Pull the latest image +docker pull kyegomez/swarms:latest + +# Run a simple test +docker run --rm kyegomez/swarms:latest python test_docker.py + +# Run with interactive shell +docker run -it --rm kyegomez/swarms:latest bash +``` + +### Using Specific Versions + +```bash +# Pull a specific version +docker pull kyegomez/swarms:v8.0.4 + +# Run with specific version +docker run --rm kyegomez/swarms:v8.0.4 python -c "import swarms; print(swarms.__version__)" +``` + +## 🏗️ Building Locally + +### Prerequisites + +- Docker installed on your system +- Git to clone the repository + +### Build Steps + +```bash +# Clone the repository +git clone https://github.com/kyegomez/swarms.git +cd swarms + +# Build the image +docker build -t swarms:latest . + +# Test the image +docker run --rm swarms:latest python test_docker.py +``` + +## 🚀 Usage Examples + +### Basic Agent Example + +```bash +# Create a Python script (agent_example.py) +cat > agent_example.py << 'EOF' +from swarms import Agent + +# Create an agent +agent = Agent( + agent_name="test_agent", + system_prompt="You are a helpful AI assistant." +) + +# Run the agent +result = agent.run("Hello! How are you today?") +print(result) +EOF + +# Run in Docker +docker run --rm -v $(pwd):/app swarms:latest python /app/agent_example.py +``` + +### Interactive Development + +```bash +# Run with volume mount for development +docker run -it --rm \ + -v $(pwd):/app \ + -w /app \ + swarms:latest bash + +# Inside the container, you can now run Python scripts +python your_script.py +``` + +### Using Environment Variables + +```bash +# Run with environment variables +docker run --rm \ + -e OPENAI_API_KEY=your_api_key_here \ + -e ANTHROPIC_API_KEY=your_anthropic_key_here \ + swarms:latest python your_script.py +``` + +## 🔧 Configuration + +### Environment Variables + +The Docker image supports the following environment variables: + +- `OPENAI_API_KEY`: Your OpenAI API key +- `ANTHROPIC_API_KEY`: Your Anthropic API key +- `GOOGLE_API_KEY`: Your Google API key +- `PYTHONPATH`: Additional Python path entries +- `PYTHONUNBUFFERED`: Set to 1 for unbuffered output + +### Volume Mounts + +Common volume mount patterns: + +```bash +# Mount current directory for development +-v $(pwd):/app + +# Mount specific directories +-v $(pwd)/data:/app/data +-v $(pwd)/models:/app/models + +# Mount configuration files +-v $(pwd)/config:/app/config +``` + +## 🐛 Troubleshooting + +### Common Issues + +1. **Permission Denied** + ```bash + # Fix permission issues + docker run --rm -v $(pwd):/app:rw swarms:latest python your_script.py + ``` + +2. **Memory Issues** + ```bash + # Increase memory limit + docker run --rm --memory=4g swarms:latest python your_script.py + ``` + +3. **Network Issues** + ```bash + # Use host network + docker run --rm --network=host swarms:latest python your_script.py + ``` + +### Debug Mode + +```bash +# Run with debug output +docker run --rm -e PYTHONUNBUFFERED=1 swarms:latest python -u your_script.py + +# Run with interactive debugging +docker run -it --rm swarms:latest python -m pdb your_script.py +``` + +## 🔄 CI/CD Integration + +The Docker image is automatically built and published via GitHub Actions: + +- **Triggers**: Push to main branch, version tags (v*.*.*) +- **Platforms**: linux/amd64, linux/arm64 +- **Registry**: DockerHub (kyegomez/swarms) + +### GitHub Actions Secrets Required + +- `DOCKERHUB_USERNAME`: Your DockerHub username +- `DOCKERHUB_TOKEN`: Your DockerHub access token + +## 📊 Image Details + +### Base Image +- Python 3.11-slim-bullseye +- Multi-stage build for optimization +- UV package manager for faster installations + +### Image Size +- Optimized for minimal size +- Multi-stage build reduces final image size +- Only necessary dependencies included + +### Security +- Non-root user execution +- Minimal system dependencies +- Regular security updates + +## 🤝 Contributing + +To contribute to the Docker setup: + +1. Fork the repository +2. Make your changes to the Dockerfile +3. Test locally: `docker build -t swarms:test .` +4. Submit a pull request + +### Testing Changes + +```bash +# Build test image +docker build -t swarms:test . + +# Run tests +docker run --rm swarms:test python test_docker.py + +# Test with your code +docker run --rm -v $(pwd):/app swarms:test python your_test_script.py +``` + +## 📝 License + +This Docker setup is part of the Swarms project and follows the same MIT license. + +## 🆘 Support + +For issues with the Docker image: + +1. Check the troubleshooting section above +2. Review the GitHub Actions logs for build issues +3. Open an issue on GitHub with detailed error information +4. Include your Docker version and system information + +--- + +**Note**: This Docker image is automatically updated with each release. For production use, consider pinning to specific version tags for stability. \ No newline at end of file From f88c94ba469bfe2bd88ede0c19915d46f411d951 Mon Sep 17 00:00:00 2001 From: CI-DEV <154627941+IlumCI@users.noreply.github.com> Date: Fri, 1 Aug 2025 12:33:08 +0300 Subject: [PATCH 05/33] Add files via upload --- scripts/docker-utils.ps1 | 139 ++++++++++++++++++++++++ scripts/docker-utils.sh | 167 +++++++++++++++++++++++++++++ scripts/setup-dockerhub-secrets.md | 113 +++++++++++++++++++ 3 files changed, 419 insertions(+) create mode 100644 scripts/docker-utils.ps1 create mode 100644 scripts/docker-utils.sh create mode 100644 scripts/setup-dockerhub-secrets.md diff --git a/scripts/docker-utils.ps1 b/scripts/docker-utils.ps1 new file mode 100644 index 00000000..59c94636 --- /dev/null +++ b/scripts/docker-utils.ps1 @@ -0,0 +1,139 @@ +# Docker utilities for Swarms project (PowerShell version) +# Usage: .\scripts\docker-utils.ps1 [command] + +param( + [Parameter(Position=0)] + [string]$Command = "help" +) + +# Configuration +$ImageName = "swarms" +$Registry = "kyegomez" +$FullImageName = "$Registry/$ImageName" + +# Functions +function Write-Usage { + Write-Host "Docker Utilities for Swarms" -ForegroundColor Blue + Write-Host "" + Write-Host "Usage: .\scripts\docker-utils.ps1 [command]" + Write-Host "" + Write-Host "Commands:" + Write-Host " build Build the Docker image locally" + Write-Host " test Test the Docker image" + Write-Host " run Run the Docker image interactively" + Write-Host " push Push to DockerHub (requires login)" + Write-Host " clean Clean up Docker images and containers" + Write-Host " logs Show logs from running containers" + Write-Host " shell Open shell in running container" + Write-Host " compose-up Start services with docker-compose" + Write-Host " compose-down Stop services with docker-compose" + Write-Host " help Show this help message" + Write-Host "" +} + +function Build-Image { + Write-Host "Building Docker image..." -ForegroundColor Green + docker build -t "$ImageName`:latest" . + Write-Host "✅ Image built successfully!" -ForegroundColor Green +} + +function Test-Image { + Write-Host "Testing Docker image..." -ForegroundColor Green + docker run --rm "$ImageName`:latest" python test_docker.py + Write-Host "✅ Image test completed!" -ForegroundColor Green +} + +function Run-Interactive { + Write-Host "Running Docker image interactively..." -ForegroundColor Green + docker run -it --rm -v "${PWD}:/app" -w /app "$ImageName`:latest" bash +} + +function Push-ToDockerHub { + Write-Host "⚠️ Make sure you're logged into DockerHub first!" -ForegroundColor Yellow + Write-Host "Pushing to DockerHub..." -ForegroundColor Green + + # Tag the image + docker tag "$ImageName`:latest" "$FullImageName`:latest" + + # Push to DockerHub + docker push "$FullImageName`:latest" + + Write-Host "✅ Image pushed to DockerHub!" -ForegroundColor Green +} + +function Clean-Docker { + Write-Host "Cleaning up Docker resources..." -ForegroundColor Yellow + + # Stop and remove containers + docker ps -aq | ForEach-Object { docker rm -f $_ } + + # Remove images + docker images "$ImageName" -q | ForEach-Object { docker rmi -f $_ } + + # Remove dangling images + docker image prune -f + + Write-Host "✅ Docker cleanup completed!" -ForegroundColor Green +} + +function Show-Logs { + Write-Host "Showing logs from running containers..." -ForegroundColor Green + docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}" + Write-Host "" + + # Show logs for swarms containers + $containers = docker ps --filter "name=swarms" --format "{{.Names}}" + foreach ($container in $containers) { + Write-Host "Logs for $container:" -ForegroundColor Blue + docker logs $container --tail 20 + Write-Host "" + } +} + +function Open-Shell { + Write-Host "Opening shell in running container..." -ForegroundColor Green + + # Find running swarms container + $container = docker ps --filter "name=swarms" --format "{{.Names}}" | Select-Object -First 1 + + if (-not $container) { + Write-Host "❌ No running swarms container found!" -ForegroundColor Red + Write-Host "Start a container first with: .\scripts\docker-utils.ps1 run" + exit 1 + } + + Write-Host "Opening shell in $container..." -ForegroundColor Blue + docker exec -it $container bash +} + +function Compose-Up { + Write-Host "Starting services with docker-compose..." -ForegroundColor Green + docker-compose up -d + Write-Host "✅ Services started!" -ForegroundColor Green + Write-Host "Use 'docker-compose logs -f' to view logs" +} + +function Compose-Down { + Write-Host "Stopping services with docker-compose..." -ForegroundColor Yellow + docker-compose down + Write-Host "✅ Services stopped!" -ForegroundColor Green +} + +# Main script logic +switch ($Command.ToLower()) { + "build" { Build-Image } + "test" { Test-Image } + "run" { Run-Interactive } + "push" { Push-ToDockerHub } + "clean" { Clean-Docker } + "logs" { Show-Logs } + "shell" { Open-Shell } + "compose-up" { Compose-Up } + "compose-down" { Compose-Down } + "help" { Write-Usage } + default { + Write-Host "❌ Unknown command: $Command" -ForegroundColor Red + Write-Usage + exit 1 + } +} \ No newline at end of file diff --git a/scripts/docker-utils.sh b/scripts/docker-utils.sh new file mode 100644 index 00000000..5b86e7dd --- /dev/null +++ b/scripts/docker-utils.sh @@ -0,0 +1,167 @@ +#!/bin/bash + +# Docker utilities for Swarms project +# Usage: ./scripts/docker-utils.sh [command] + +set -e + +# Colors for output +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +NC='\033[0m' # No Color + +# Configuration +IMAGE_NAME="swarms" +REGISTRY="kyegomez" +FULL_IMAGE_NAME="${REGISTRY}/${IMAGE_NAME}" + +# Functions +print_usage() { + echo -e "${BLUE}Docker Utilities for Swarms${NC}" + echo "" + echo "Usage: $0 [command]" + echo "" + echo "Commands:" + echo " build Build the Docker image locally" + echo " test Test the Docker image" + echo " run Run the Docker image interactively" + echo " push Push to DockerHub (requires login)" + echo " clean Clean up Docker images and containers" + echo " logs Show logs from running containers" + echo " shell Open shell in running container" + echo " compose-up Start services with docker-compose" + echo " compose-down Stop services with docker-compose" + echo " help Show this help message" + echo "" +} + +build_image() { + echo -e "${GREEN}Building Docker image...${NC}" + docker build -t "${IMAGE_NAME}:latest" . + echo -e "${GREEN}✅ Image built successfully!${NC}" +} + +test_image() { + echo -e "${GREEN}Testing Docker image...${NC}" + docker run --rm "${IMAGE_NAME}:latest" python test_docker.py + echo -e "${GREEN}✅ Image test completed!${NC}" +} + +run_interactive() { + echo -e "${GREEN}Running Docker image interactively...${NC}" + docker run -it --rm \ + -v "$(pwd):/app" \ + -w /app \ + "${IMAGE_NAME}:latest" bash +} + +push_to_dockerhub() { + echo -e "${YELLOW}⚠️ Make sure you're logged into DockerHub first!${NC}" + echo -e "${GREEN}Pushing to DockerHub...${NC}" + + # Tag the image + docker tag "${IMAGE_NAME}:latest" "${FULL_IMAGE_NAME}:latest" + + # Push to DockerHub + docker push "${FULL_IMAGE_NAME}:latest" + + echo -e "${GREEN}✅ Image pushed to DockerHub!${NC}" +} + +clean_docker() { + echo -e "${YELLOW}Cleaning up Docker resources...${NC}" + + # Stop and remove containers + docker ps -aq | xargs -r docker rm -f + + # Remove images + docker images "${IMAGE_NAME}" -q | xargs -r docker rmi -f + + # Remove dangling images + docker image prune -f + + echo -e "${GREEN}✅ Docker cleanup completed!${NC}" +} + +show_logs() { + echo -e "${GREEN}Showing logs from running containers...${NC}" + docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}" + echo "" + + # Show logs for swarms containers + for container in $(docker ps --filter "name=swarms" --format "{{.Names}}"); do + echo -e "${BLUE}Logs for $container:${NC}" + docker logs "$container" --tail 20 + echo "" + done +} + +open_shell() { + echo -e "${GREEN}Opening shell in running container...${NC}" + + # Find running swarms container + container=$(docker ps --filter "name=swarms" --format "{{.Names}}" | head -1) + + if [ -z "$container" ]; then + echo -e "${RED}❌ No running swarms container found!${NC}" + echo "Start a container first with: $0 run" + exit 1 + fi + + echo -e "${BLUE}Opening shell in $container...${NC}" + docker exec -it "$container" bash +} + +compose_up() { + echo -e "${GREEN}Starting services with docker-compose...${NC}" + docker-compose up -d + echo -e "${GREEN}✅ Services started!${NC}" + echo "Use 'docker-compose logs -f' to view logs" +} + +compose_down() { + echo -e "${YELLOW}Stopping services with docker-compose...${NC}" + docker-compose down + echo -e "${GREEN}✅ Services stopped!${NC}" +} + +# Main script logic +case "${1:-help}" in + build) + build_image + ;; + test) + test_image + ;; + run) + run_interactive + ;; + push) + push_to_dockerhub + ;; + clean) + clean_docker + ;; + logs) + show_logs + ;; + shell) + open_shell + ;; + compose-up) + compose_up + ;; + compose-down) + compose_down + ;; + help|--help|-h) + print_usage + ;; + *) + echo -e "${RED}❌ Unknown command: $1${NC}" + print_usage + exit 1 + ;; +esac \ No newline at end of file diff --git a/scripts/setup-dockerhub-secrets.md b/scripts/setup-dockerhub-secrets.md new file mode 100644 index 00000000..ac4dd691 --- /dev/null +++ b/scripts/setup-dockerhub-secrets.md @@ -0,0 +1,113 @@ +# Setting up DockerHub Secrets for GitHub Actions + +This guide will help you set up the required secrets for the Docker workflow to automatically build and push images to DockerHub. + +## Prerequisites + +1. A DockerHub account +2. Admin access to the GitHub repository +3. DockerHub access token + +## Step 1: Create a DockerHub Access Token + +1. Log in to [DockerHub](https://hub.docker.com/) +2. Go to your account settings +3. Navigate to "Security" → "Access Tokens" +4. Click "New Access Token" +5. Give it a name (e.g., "GitHub Actions") +6. Set the permissions to "Read & Write" +7. Copy the generated token (you won't be able to see it again!) + +## Step 2: Add Secrets to GitHub Repository + +1. Go to your GitHub repository +2. Navigate to "Settings" → "Secrets and variables" → "Actions" +3. Click "New repository secret" +4. Add the following secrets: + +### Required Secrets + +| Secret Name | Value | Description | +|-------------|-------|-------------| +| `DOCKERHUB_USERNAME` | Your DockerHub username | Your DockerHub username (e.g., `kyegomez`) | +| `DOCKERHUB_TOKEN` | Your DockerHub access token | The access token you created in Step 1 | + +## Step 3: Verify Setup + +1. Push a commit to the `main` branch +2. Go to the "Actions" tab in your GitHub repository +3. You should see the "Docker Build and Publish" workflow running +4. Check that it completes successfully + +## Troubleshooting + +### Common Issues + +1. **Authentication Failed** + - Double-check your DockerHub username and token + - Ensure the token has "Read & Write" permissions + - Make sure the token hasn't expired + +2. **Permission Denied** + - Verify you have admin access to the repository + - Check that the secrets are named exactly as shown above + +3. **Workflow Not Triggering** + - Ensure you're pushing to the `main` branch + - Check that the workflow file is in `.github/workflows/` + - Verify the workflow file has the correct triggers + +### Testing Locally + +You can test the Docker build locally before pushing: + +```bash +# Build the image locally +docker build -t swarms:test . + +# Test the image +docker run --rm swarms:test python test_docker.py + +# If everything works, push to GitHub +git add . +git commit -m "Add Docker support" +git push origin main +``` + +## Security Notes + +- Never commit secrets directly to your repository +- Use repository secrets for sensitive information +- Regularly rotate your DockerHub access tokens +- Consider using organization-level secrets for team repositories + +## Additional Configuration + +### Custom Registry + +If you want to use a different registry (not DockerHub), update the workflow file: + +```yaml +env: + REGISTRY: your-registry.com + IMAGE_NAME: your-org/your-repo +``` + +### Multiple Tags + +The workflow automatically creates tags based on: +- Git branch name +- Git commit SHA +- Version tags (v*.*.*) +- Latest tag for main branch + +You can customize this in the workflow file under the "Extract Docker metadata" step. + +## Support + +If you encounter issues: + +1. Check the GitHub Actions logs for detailed error messages +2. Verify your DockerHub credentials +3. Ensure the workflow file is properly configured +4. Open an issue in the repository with the error details \ No newline at end of file From cc37ec218a124949a056c5f742422e771ad51f0d Mon Sep 17 00:00:00 2001 From: CI-DEV <154627941+IlumCI@users.noreply.github.com> Date: Fri, 1 Aug 2025 12:36:19 +0300 Subject: [PATCH 06/33] Update README.md --- README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/README.md b/README.md index bfcf4264..e893bfc4 100644 --- a/README.md +++ b/README.md @@ -146,6 +146,24 @@ $ cd swarms $ pip install -e . ``` +### Using Docker + +The easiest way to get started with Swarms is using our pre-built Docker image: + +```bash +# Pull and run the latest image +$ docker pull kyegomez/swarms:latest +$ docker run --rm kyegomez/swarms:latest python -c "import swarms; print('Swarms is ready!')" + +# Run interactively for development +$ docker run -it --rm -v $(pwd):/app kyegomez/swarms:latest bash + +# Using docker-compose (recommended for development) +$ docker-compose up -d +``` + +For more Docker options and advanced usage, see our [Docker documentation](DOCKER.md). + --- ## Environment Configuration From 92d0f360f6c62e2bcd10ede69f942f74b1e11359 Mon Sep 17 00:00:00 2001 From: CI-DEV <154627941+IlumCI@users.noreply.github.com> Date: Fri, 1 Aug 2025 12:38:43 +0300 Subject: [PATCH 07/33] Add files via upload --- .github/workflows/docker-test.yml | 58 +++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 .github/workflows/docker-test.yml diff --git a/.github/workflows/docker-test.yml b/.github/workflows/docker-test.yml new file mode 100644 index 00000000..05ee8ed3 --- /dev/null +++ b/.github/workflows/docker-test.yml @@ -0,0 +1,58 @@ +name: Docker Test Build + +on: + pull_request: + branches: [ "master" ] + workflow_dispatch: + +env: + REGISTRY: docker.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + test-build: + runs-on: ubuntu-latest + permissions: + contents: read + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + # Setup QEMU for multi-platform builds + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + # Setup Docker BuildX + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + # Build Docker image (without pushing) + - name: Build Docker image + id: build + uses: docker/build-push-action@v6 + with: + context: . + push: false + tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:test + platforms: linux/amd64 + cache-from: type=gha + cache-to: type=gha,mode=max + build-args: | + BUILDKIT_INLINE_CACHE=1 + + # Test the built image + - name: Test Docker image + run: | + docker run --rm ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:test python test_docker.py + + # Show image size + - name: Show image size + run: | + docker images ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:test --format "table {{.Repository}}\t{{.Tag}}\t{{.Size}}" + + # Clean up test image + - name: Clean up test image + if: always() + run: | + docker rmi ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:test || true \ No newline at end of file From 88d690a55d7056fca8abf01bcc98bfba9b3a1f4a Mon Sep 17 00:00:00 2001 From: CI-DEV <154627941+IlumCI@users.noreply.github.com> Date: Fri, 1 Aug 2025 20:53:25 +0300 Subject: [PATCH 08/33] Create docker --- scripts/docker | 1 + 1 file changed, 1 insertion(+) create mode 100644 scripts/docker diff --git a/scripts/docker b/scripts/docker new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/scripts/docker @@ -0,0 +1 @@ + From dd76134ed313f65039a5fc376d1bee32dfded01a Mon Sep 17 00:00:00 2001 From: CI-DEV <154627941+IlumCI@users.noreply.github.com> Date: Fri, 1 Aug 2025 20:53:35 +0300 Subject: [PATCH 09/33] Delete scripts/docker --- scripts/docker | 1 - 1 file changed, 1 deletion(-) delete mode 100644 scripts/docker diff --git a/scripts/docker b/scripts/docker deleted file mode 100644 index 8b137891..00000000 --- a/scripts/docker +++ /dev/null @@ -1 +0,0 @@ - From 2299b48e0dd127c4be92b40dc064b23beea22855 Mon Sep 17 00:00:00 2001 From: CI-DEV <154627941+IlumCI@users.noreply.github.com> Date: Fri, 1 Aug 2025 20:53:53 +0300 Subject: [PATCH 10/33] Create file --- scripts/docker/file | 1 + 1 file changed, 1 insertion(+) create mode 100644 scripts/docker/file diff --git a/scripts/docker/file b/scripts/docker/file new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/scripts/docker/file @@ -0,0 +1 @@ + From ed1ba6cd741f195afe78b35eb63b4ae28e44e1f3 Mon Sep 17 00:00:00 2001 From: CI-DEV <154627941+IlumCI@users.noreply.github.com> Date: Fri, 1 Aug 2025 20:55:02 +0300 Subject: [PATCH 11/33] Update and rename file to test_docker.py --- scripts/docker/file | 1 - scripts/docker/test_docker.py | 66 +++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 1 deletion(-) delete mode 100644 scripts/docker/file create mode 100644 scripts/docker/test_docker.py diff --git a/scripts/docker/file b/scripts/docker/file deleted file mode 100644 index 8b137891..00000000 --- a/scripts/docker/file +++ /dev/null @@ -1 +0,0 @@ - diff --git a/scripts/docker/test_docker.py b/scripts/docker/test_docker.py new file mode 100644 index 00000000..70e9060b --- /dev/null +++ b/scripts/docker/test_docker.py @@ -0,0 +1,66 @@ + +#!/usr/bin/env python3 +""" +Test script to verify Swarms installation in Docker container. +""" + +import sys +from typing import Dict, Any + +def test_swarms_import() -> Dict[str, Any]: + """ + Test that swarms can be imported and basic functionality works. + + Returns: + Dict[str, Any]: Test results + """ + try: + import swarms + print(f" Swarms imported successfully. Version: {swarms.__version__}") + + # Test basic functionality + from swarms import Agent + print(" Agent class imported successfully") + + return { + "status": "success", + "version": swarms.__version__, + "message": "Swarms package is working correctly" + } + + except ImportError as e: + print(f" Failed to import swarms: {e}") + return { + "status": "error", + "error": str(e), + "message": "Swarms package import failed" + } + except Exception as e: + print(f" Unexpected error: {e}") + return { + "status": "error", + "error": str(e), + "message": "Unexpected error occurred" + } + +def main() -> None: + """Main function to run tests.""" + print(" Testing Swarms Docker Image...") + print("=" * 50) + + # Test Python version + print(f"Python version: {sys.version}") + + # Test swarms import + result = test_swarms_import() + + print("=" * 50) + if result["status"] == "success": + print(" All tests passed! Docker image is working correctly.") + sys.exit(0) + else: + print(" Tests failed! Please check the Docker image.") + sys.exit(1) + +if __name__ == "__main__": + main() From 5fd6eb8ff043c3a63bae9c0db495c61b4c09ca04 Mon Sep 17 00:00:00 2001 From: CI-DEV <154627941+IlumCI@users.noreply.github.com> Date: Fri, 1 Aug 2025 20:55:58 +0300 Subject: [PATCH 12/33] Create docker-compose.yml --- scripts/docker/docker-compose.yml | 71 +++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 scripts/docker/docker-compose.yml diff --git a/scripts/docker/docker-compose.yml b/scripts/docker/docker-compose.yml new file mode 100644 index 00000000..a0ef3a35 --- /dev/null +++ b/scripts/docker/docker-compose.yml @@ -0,0 +1,71 @@ +version: '3.8' + +services: + swarms: + build: + context: . + dockerfile: Dockerfile + image: swarms:latest + container_name: swarms-container + environment: + - PYTHONUNBUFFERED=1 + - PYTHONPATH=/app + # Add your API keys here or use .env file + # - OPENAI_API_KEY=${OPENAI_API_KEY} + # - ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY} + # - GOOGLE_API_KEY=${GOOGLE_API_KEY} + volumes: + - .:/app + - ./data:/app/data + - ./models:/app/models + working_dir: /app + command: python test_docker.py + restart: unless-stopped + healthcheck: + test: ["CMD", "python", "-c", "import swarms; print('Health check passed')"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s + + swarms-dev: + build: + context: . + dockerfile: Dockerfile + image: swarms:dev + container_name: swarms-dev-container + environment: + - PYTHONUNBUFFERED=1 + - PYTHONPATH=/app + volumes: + - .:/app + - ./data:/app/data + - ./models:/app/models + working_dir: /app + command: bash + stdin_open: true + tty: true + restart: unless-stopped + + swarms-api: + build: + context: . + dockerfile: Dockerfile + image: swarms:api + container_name: swarms-api-container + environment: + - PYTHONUNBUFFERED=1 + - PYTHONPATH=/app + volumes: + - .:/app + working_dir: /app + ports: + - "8000:8000" + command: python -m uvicorn main:app --host 0.0.0.0 --port 8000 --reload + restart: unless-stopped + depends_on: + - swarms + +networks: + default: + name: swarms-network From 62f02e133cb4fd69a012c9946d24db72c87ebca4 Mon Sep 17 00:00:00 2001 From: CI-DEV <154627941+IlumCI@users.noreply.github.com> Date: Fri, 1 Aug 2025 20:57:03 +0300 Subject: [PATCH 13/33] Create .dockerignore --- scripts/docker/.dockerignore | 296 +++++++++++++++++++++++++++++++++++ 1 file changed, 296 insertions(+) create mode 100644 scripts/docker/.dockerignore diff --git a/scripts/docker/.dockerignore b/scripts/docker/.dockerignore new file mode 100644 index 00000000..241d24cb --- /dev/null +++ b/scripts/docker/.dockerignore @@ -0,0 +1,296 @@ +.git +.gitignore +.env +__pycache__ +*.pyc +*.pyo +*.pyd +.Python +env/ +venv/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.log +.pytest_cache/ +.mypy_cache/ + +__pycache__/ +.venv/ + +.env + +image/ +audio/ +video/ +artifacts_three +dataframe/ +.ruff_cache +.pytest_cache +static/generated +runs +Financial-Analysis-Agent_state.json +experimental +artifacts_five +encryption +errors +chroma +agent_workspace +.pt +Accounting Assistant_state.json +Unit Testing Agent_state.json +sec_agent +Devin_state.json +poetry.lock +hire_researchers +agent_workspace +json_logs +Medical Image Diagnostic Agent_state.json +flight agent_state.json +D_state.json +artifacts_six +artifacts_seven +swarms/__pycache__ +artifacts_once +transcript_generator.json +venv +.DS_Store +Cargo.lock +.DS_STORE +artifacts_logs +Cargo.lock +Medical Treatment Recommendation Agent_state.json +swarms/agents/.DS_Store +artifacts_two +logs +T_state.json +_build +conversation.txt +t1_state.json +stderr_log.txt +t2_state.json +.vscode +.DS_STORE +# Byte-compiled / optimized / DLL files +Transcript Generator_state.json +__pycache__/ +*.py[cod] +*$py.class +.grit +swarm-worker-01_state.json +error.txt +Devin Worker 2_state.json +# C extensions +*.so +.ruff_cache + + +errors.txt + +Autonomous-Agent-XYZ1B_state.json +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py +.DS_Store + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +#pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/#use-with-ide +.pdm.toml + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# PyCharm +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +#.idea/ +.vscode/settings.json +# -*- mode: gitignore; -*- +*~ +\#*\# +/.emacs.desktop +/.emacs.desktop.lock +*.elc +auto-save-list +tramp +.\#* + +# Org-mode +.org-id-locations +*_archive + +# flymake-mode +*_flymake.* + +# eshell files +/eshell/history +/eshell/lastdir + +# elpa packages +/elpa/ + +# reftex files +*.rel + +# AUCTeX auto folder +/auto/ + +# cask packages +.cask/ +dist/ + +# Flycheck +flycheck_*.el + +# server auth directory +/server/ + +# projectiles files +.projectile + +# directory configuration +.dir-locals.el + +# network security +/network-security.data From 6a7071afd17721d64ebba32ceb16f4adf17e922a Mon Sep 17 00:00:00 2001 From: CI-DEV <154627941+IlumCI@users.noreply.github.com> Date: Fri, 1 Aug 2025 20:57:52 +0300 Subject: [PATCH 14/33] Create Dockerfile --- scripts/docker/Dockerfile | 48 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 scripts/docker/Dockerfile diff --git a/scripts/docker/Dockerfile b/scripts/docker/Dockerfile new file mode 100644 index 00000000..44392b09 --- /dev/null +++ b/scripts/docker/Dockerfile @@ -0,0 +1,48 @@ +# 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 \ + PATH="/opt/venv/bin:${PATH}" \ + PYTHONPATH="/app:${PYTHONPATH}" \ + USER=swarms + +# Set working directory +WORKDIR /app + +# 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 && \ + chown -R $USER:$USER /app + +# Copy application code +COPY --chown=$USER:$USER . . + +# Switch to non-root +USER $USER + +# Optional health check +HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \ + CMD python -c "import swarms; print('Health check passed')" || exit 1 From d6f6d05c90c173caccfe6bcb0f3f4fa24001e092 Mon Sep 17 00:00:00 2001 From: CI-DEV <154627941+IlumCI@users.noreply.github.com> Date: Fri, 1 Aug 2025 20:58:23 +0300 Subject: [PATCH 15/33] Create DOCKER.md --- scripts/docker/DOCKER.md | 225 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 225 insertions(+) create mode 100644 scripts/docker/DOCKER.md diff --git a/scripts/docker/DOCKER.md b/scripts/docker/DOCKER.md new file mode 100644 index 00000000..5eeee366 --- /dev/null +++ b/scripts/docker/DOCKER.md @@ -0,0 +1,225 @@ +# Swarms Docker Image + +This repository includes a Docker image for running Swarms, an AI agent framework. The image is automatically built and published to DockerHub on every push to the main branch and on version tags. + +## 🐳 Quick Start + +### Pull and Run + +```bash +# Pull the latest image +docker pull kyegomez/swarms:latest + +# Run a simple test +docker run --rm kyegomez/swarms:latest python test_docker.py + +# Run with interactive shell +docker run -it --rm kyegomez/swarms:latest bash +``` + +### Using Specific Versions + +```bash +# Pull a specific version +docker pull kyegomez/swarms:v8.0.4 + +# Run with specific version +docker run --rm kyegomez/swarms:v8.0.4 python -c "import swarms; print(swarms.__version__)" +``` + +## 🏗️ Building Locally + +### Prerequisites + +- Docker installed on your system +- Git to clone the repository + +### Build Steps + +```bash +# Clone the repository +git clone https://github.com/kyegomez/swarms.git +cd swarms + +# Build the image +docker build -t swarms:latest . + +# Test the image +docker run --rm swarms:latest python test_docker.py +``` + +## 🚀 Usage Examples + +### Basic Agent Example + +```bash +# Create a Python script (agent_example.py) +cat > agent_example.py << 'EOF' +from swarms import Agent + +# Create an agent +agent = Agent( + agent_name="test_agent", + system_prompt="You are a helpful AI assistant." +) + +# Run the agent +result = agent.run("Hello! How are you today?") +print(result) +EOF + +# Run in Docker +docker run --rm -v $(pwd):/app swarms:latest python /app/agent_example.py +``` + +### Interactive Development + +```bash +# Run with volume mount for development +docker run -it --rm \ + -v $(pwd):/app \ + -w /app \ + swarms:latest bash + +# Inside the container, you can now run Python scripts +python your_script.py +``` + +### Using Environment Variables + +```bash +# Run with environment variables +docker run --rm \ + -e OPENAI_API_KEY=your_api_key_here \ + -e ANTHROPIC_API_KEY=your_anthropic_key_here \ + swarms:latest python your_script.py +``` + +## 🔧 Configuration + +### Environment Variables + +The Docker image supports the following environment variables: + +- `OPENAI_API_KEY`: Your OpenAI API key +- `ANTHROPIC_API_KEY`: Your Anthropic API key +- `GOOGLE_API_KEY`: Your Google API key +- `PYTHONPATH`: Additional Python path entries +- `PYTHONUNBUFFERED`: Set to 1 for unbuffered output + +### Volume Mounts + +Common volume mount patterns: + +```bash +# Mount current directory for development +-v $(pwd):/app + +# Mount specific directories +-v $(pwd)/data:/app/data +-v $(pwd)/models:/app/models + +# Mount configuration files +-v $(pwd)/config:/app/config +``` + +## 🐛 Troubleshooting + +### Common Issues + +1. **Permission Denied** + ```bash + # Fix permission issues + docker run --rm -v $(pwd):/app:rw swarms:latest python your_script.py + ``` + +2. **Memory Issues** + ```bash + # Increase memory limit + docker run --rm --memory=4g swarms:latest python your_script.py + ``` + +3. **Network Issues** + ```bash + # Use host network + docker run --rm --network=host swarms:latest python your_script.py + ``` + +### Debug Mode + +```bash +# Run with debug output +docker run --rm -e PYTHONUNBUFFERED=1 swarms:latest python -u your_script.py + +# Run with interactive debugging +docker run -it --rm swarms:latest python -m pdb your_script.py +``` + +## 🔄 CI/CD Integration + +The Docker image is automatically built and published via GitHub Actions: + +- **Triggers**: Push to main branch, version tags (v*.*.*) +- **Platforms**: linux/amd64, linux/arm64 +- **Registry**: DockerHub (kyegomez/swarms) + +### GitHub Actions Secrets Required + +- `DOCKERHUB_USERNAME`: Your DockerHub username +- `DOCKERHUB_TOKEN`: Your DockerHub access token + +## 📊 Image Details + +### Base Image +- Python 3.11-slim-bullseye +- Multi-stage build for optimization +- UV package manager for faster installations + +### Image Size +- Optimized for minimal size +- Multi-stage build reduces final image size +- Only necessary dependencies included + +### Security +- Non-root user execution +- Minimal system dependencies +- Regular security updates + +## 🤝 Contributing + +To contribute to the Docker setup: + +1. Fork the repository +2. Make your changes to the Dockerfile +3. Test locally: `docker build -t swarms:test .` +4. Submit a pull request + +### Testing Changes + +```bash +# Build test image +docker build -t swarms:test . + +# Run tests +docker run --rm swarms:test python test_docker.py + +# Test with your code +docker run --rm -v $(pwd):/app swarms:test python your_test_script.py +``` + +## 📝 License + +This Docker setup is part of the Swarms project and follows the same MIT license. + +## 🆘 Support + +For issues with the Docker image: + +1. Check the troubleshooting section above +2. Review the GitHub Actions logs for build issues +3. Open an issue on GitHub with detailed error information +4. Include your Docker version and system information + +--- + +**Note**: This Docker image is automatically updated with each release. For production use, consider pinning to specific version tags for stability. From b1a438de6bfd29fbc38a698cadecff2495ae84ed Mon Sep 17 00:00:00 2001 From: CI-DEV <154627941+IlumCI@users.noreply.github.com> Date: Fri, 1 Aug 2025 20:59:25 +0300 Subject: [PATCH 16/33] Create docker-utils.sh --- scripts/docker/docker-utils.sh | 167 +++++++++++++++++++++++++++++++++ 1 file changed, 167 insertions(+) create mode 100644 scripts/docker/docker-utils.sh diff --git a/scripts/docker/docker-utils.sh b/scripts/docker/docker-utils.sh new file mode 100644 index 00000000..ca24332f --- /dev/null +++ b/scripts/docker/docker-utils.sh @@ -0,0 +1,167 @@ +#!/bin/bash + +# Docker utilities for Swarms project +# Usage: ./scripts/docker-utils.sh [command] + +set -e + +# Colors for output +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +NC='\033[0m' # No Color + +# Configuration +IMAGE_NAME="swarms" +REGISTRY="kyegomez" +FULL_IMAGE_NAME="${REGISTRY}/${IMAGE_NAME}" + +# Functions +print_usage() { + echo -e "${BLUE}Docker Utilities for Swarms${NC}" + echo "" + echo "Usage: $0 [command]" + echo "" + echo "Commands:" + echo " build Build the Docker image locally" + echo " test Test the Docker image" + echo " run Run the Docker image interactively" + echo " push Push to DockerHub (requires login)" + echo " clean Clean up Docker images and containers" + echo " logs Show logs from running containers" + echo " shell Open shell in running container" + echo " compose-up Start services with docker-compose" + echo " compose-down Stop services with docker-compose" + echo " help Show this help message" + echo "" +} + +build_image() { + echo -e "${GREEN}Building Docker image...${NC}" + docker build -t "${IMAGE_NAME}:latest" . + echo -e "${GREEN} Image built successfully!${NC}" +} + +test_image() { + echo -e "${GREEN}Testing Docker image...${NC}" + docker run --rm "${IMAGE_NAME}:latest" python test_docker.py + echo -e "${GREEN} Image test completed!${NC}" +} + +run_interactive() { + echo -e "${GREEN}Running Docker image interactively...${NC}" + docker run -it --rm \ + -v "$(pwd):/app" \ + -w /app \ + "${IMAGE_NAME}:latest" bash +} + +push_to_dockerhub() { + echo -e "${YELLOW}⚠ Make sure you're logged into DockerHub first!${NC}" + echo -e "${GREEN}Pushing to DockerHub...${NC}" + + # Tag the image + docker tag "${IMAGE_NAME}:latest" "${FULL_IMAGE_NAME}:latest" + + # Push to DockerHub + docker push "${FULL_IMAGE_NAME}:latest" + + echo -e "${GREEN} Image pushed to DockerHub!${NC}" +} + +clean_docker() { + echo -e "${YELLOW}Cleaning up Docker resources...${NC}" + + # Stop and remove containers + docker ps -aq | xargs -r docker rm -f + + # Remove images + docker images "${IMAGE_NAME}" -q | xargs -r docker rmi -f + + # Remove dangling images + docker image prune -f + + echo -e "${GREEN} Docker cleanup completed!${NC}" +} + +show_logs() { + echo -e "${GREEN}Showing logs from running containers...${NC}" + docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}" + echo "" + + # Show logs for swarms containers + for container in $(docker ps --filter "name=swarms" --format "{{.Names}}"); do + echo -e "${BLUE}Logs for $container:${NC}" + docker logs "$container" --tail 20 + echo "" + done +} + +open_shell() { + echo -e "${GREEN}Opening shell in running container...${NC}" + + # Find running swarms container + container=$(docker ps --filter "name=swarms" --format "{{.Names}}" | head -1) + + if [ -z "$container" ]; then + echo -e "${RED} No running swarms container found!${NC}" + echo "Start a container first with: $0 run" + exit 1 + fi + + echo -e "${BLUE}Opening shell in $container...${NC}" + docker exec -it "$container" bash +} + +compose_up() { + echo -e "${GREEN}Starting services with docker-compose...${NC}" + docker-compose up -d + echo -e "${GREEN} Services started!${NC}" + echo "Use 'docker-compose logs -f' to view logs" +} + +compose_down() { + echo -e "${YELLOW}Stopping services with docker-compose...${NC}" + docker-compose down + echo -e "${GREEN} Services stopped!${NC}" +} + +# Main script logic +case "${1:-help}" in + build) + build_image + ;; + test) + test_image + ;; + run) + run_interactive + ;; + push) + push_to_dockerhub + ;; + clean) + clean_docker + ;; + logs) + show_logs + ;; + shell) + open_shell + ;; + compose-up) + compose_up + ;; + compose-down) + compose_down + ;; + help|--help|-h) + print_usage + ;; + *) + echo -e "${RED} Unknown command: $1${NC}" + print_usage + exit 1 + ;; +esac From 72a5cff90e9af4efd60ab02f3aab1568241d5b40 Mon Sep 17 00:00:00 2001 From: CI-DEV <154627941+IlumCI@users.noreply.github.com> Date: Fri, 1 Aug 2025 21:00:17 +0300 Subject: [PATCH 17/33] Create docker-utils.ps1 --- scripts/docker/docker-utils.ps1 | 139 ++++++++++++++++++++++++++++++++ 1 file changed, 139 insertions(+) create mode 100644 scripts/docker/docker-utils.ps1 diff --git a/scripts/docker/docker-utils.ps1 b/scripts/docker/docker-utils.ps1 new file mode 100644 index 00000000..36ba12db --- /dev/null +++ b/scripts/docker/docker-utils.ps1 @@ -0,0 +1,139 @@ +# Docker utilities for Swarms project (PowerShell version) +# Usage: .\scripts\docker-utils.ps1 [command] + +param( + [Parameter(Position=0)] + [string]$Command = "help" +) + +# Configuration +$ImageName = "swarms" +$Registry = "kyegomez" +$FullImageName = "$Registry/$ImageName" + +# Functions +function Write-Usage { + Write-Host "Docker Utilities for Swarms" -ForegroundColor Blue + Write-Host "" + Write-Host "Usage: .\scripts\docker-utils.ps1 [command]" + Write-Host "" + Write-Host "Commands:" + Write-Host " build Build the Docker image locally" + Write-Host " test Test the Docker image" + Write-Host " run Run the Docker image interactively" + Write-Host " push Push to DockerHub (requires login)" + Write-Host " clean Clean up Docker images and containers" + Write-Host " logs Show logs from running containers" + Write-Host " shell Open shell in running container" + Write-Host " compose-up Start services with docker-compose" + Write-Host " compose-down Stop services with docker-compose" + Write-Host " help Show this help message" + Write-Host "" +} + +function Build-Image { + Write-Host "Building Docker image..." -ForegroundColor Green + docker build -t "$ImageName`:latest" . + Write-Host " Image built successfully!" -ForegroundColor Green +} + +function Test-Image { + Write-Host "Testing Docker image..." -ForegroundColor Green + docker run --rm "$ImageName`:latest" python test_docker.py + Write-Host " Image test completed!" -ForegroundColor Green +} + +function Run-Interactive { + Write-Host "Running Docker image interactively..." -ForegroundColor Green + docker run -it --rm -v "${PWD}:/app" -w /app "$ImageName`:latest" bash +} + +function Push-ToDockerHub { + Write-Host "⚠ Make sure you're logged into DockerHub first!" -ForegroundColor Yellow + Write-Host "Pushing to DockerHub..." -ForegroundColor Green + + # Tag the image + docker tag "$ImageName`:latest" "$FullImageName`:latest" + + # Push to DockerHub + docker push "$FullImageName`:latest" + + Write-Host " Image pushed to DockerHub!" -ForegroundColor Green +} + +function Clean-Docker { + Write-Host "Cleaning up Docker resources..." -ForegroundColor Yellow + + # Stop and remove containers + docker ps -aq | ForEach-Object { docker rm -f $_ } + + # Remove images + docker images "$ImageName" -q | ForEach-Object { docker rmi -f $_ } + + # Remove dangling images + docker image prune -f + + Write-Host " Docker cleanup completed!" -ForegroundColor Green +} + +function Show-Logs { + Write-Host "Showing logs from running containers..." -ForegroundColor Green + docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}" + Write-Host "" + + # Show logs for swarms containers + $containers = docker ps --filter "name=swarms" --format "{{.Names}}" + foreach ($container in $containers) { + Write-Host "Logs for $container:" -ForegroundColor Blue + docker logs $container --tail 20 + Write-Host "" + } +} + +function Open-Shell { + Write-Host "Opening shell in running container..." -ForegroundColor Green + + # Find running swarms container + $container = docker ps --filter "name=swarms" --format "{{.Names}}" | Select-Object -First 1 + + if (-not $container) { + Write-Host " No running swarms container found!" -ForegroundColor Red + Write-Host "Start a container first with: .\scripts\docker-utils.ps1 run" + exit 1 + } + + Write-Host "Opening shell in $container..." -ForegroundColor Blue + docker exec -it $container bash +} + +function Compose-Up { + Write-Host "Starting services with docker-compose..." -ForegroundColor Green + docker-compose up -d + Write-Host " Services started!" -ForegroundColor Green + Write-Host "Use 'docker-compose logs -f' to view logs" +} + +function Compose-Down { + Write-Host "Stopping services with docker-compose..." -ForegroundColor Yellow + docker-compose down + Write-Host " Services stopped!" -ForegroundColor Green +} + +# Main script logic +switch ($Command.ToLower()) { + "build" { Build-Image } + "test" { Test-Image } + "run" { Run-Interactive } + "push" { Push-ToDockerHub } + "clean" { Clean-Docker } + "logs" { Show-Logs } + "shell" { Open-Shell } + "compose-up" { Compose-Up } + "compose-down" { Compose-Down } + "help" { Write-Usage } + default { + Write-Host " Unknown command: $Command" -ForegroundColor Red + Write-Usage + exit 1 + } +} From 6ea348c08c314b04bbee4f61f402a90ae6e35285 Mon Sep 17 00:00:00 2001 From: CI-DEV <154627941+IlumCI@users.noreply.github.com> Date: Fri, 1 Aug 2025 21:01:09 +0300 Subject: [PATCH 18/33] Create docker-image.yml --- scripts/docker/docker-image.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 scripts/docker/docker-image.yml diff --git a/scripts/docker/docker-image.yml b/scripts/docker/docker-image.yml new file mode 100644 index 00000000..793d8e0e --- /dev/null +++ b/scripts/docker/docker-image.yml @@ -0,0 +1,18 @@ +name: Docker Image CI + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Build the Docker image + run: docker build . --file Dockerfile --tag my-image-name:$(date +%s) From 01b4fc7c2083fb7edf41c0ecc642d214d4849335 Mon Sep 17 00:00:00 2001 From: CI-DEV <154627941+IlumCI@users.noreply.github.com> Date: Fri, 1 Aug 2025 21:03:51 +0300 Subject: [PATCH 19/33] Create docker-publish.yml --- scripts/docker/docker-publish.yml | 76 +++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 scripts/docker/docker-publish.yml diff --git a/scripts/docker/docker-publish.yml b/scripts/docker/docker-publish.yml new file mode 100644 index 00000000..40fac9cb --- /dev/null +++ b/scripts/docker/docker-publish.yml @@ -0,0 +1,76 @@ +name: Docker Build and Publish + +on: + push: + branches: [ "master" ] + # Publish semver tags as releases + tags: [ 'v*.*.*' ] + pull_request: + branches: [ "master" ] + +env: + # Use docker.io for Docker Hub if empty + REGISTRY: docker.io + # github.repository as / + IMAGE_NAME: ${{ github.repository }} + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + # This is used to complete the identity challenge + # with sigstore/fulcio when running outside of PRs. + id-token: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + # Setup QEMU for multi-platform builds + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + # Setup Docker BuildX + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + # Login to Docker Hub + - name: Log into registry ${{ env.REGISTRY }} + if: github.event_name != 'pull_request' + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + # Extract metadata (tags, labels) for Docker + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + type=sha + type=raw,value=latest,enable={{is_default_branch}} + + # Build and push Docker image + - name: Build and push Docker image + id: build-and-push + uses: docker/build-push-action@v6 + with: + context: . + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + platforms: linux/amd64,linux/arm64 + cache-from: type=gha + cache-to: type=gha,mode=max + build-args: | + BUILDKIT_INLINE_CACHE=1 From 4ff2f224351ba2ef4239f8dc57323c585f20f69d Mon Sep 17 00:00:00 2001 From: CI-DEV <154627941+IlumCI@users.noreply.github.com> Date: Fri, 1 Aug 2025 21:04:25 +0300 Subject: [PATCH 20/33] Create docker-test.yml --- scripts/docker/docker-test.yml | 58 ++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 scripts/docker/docker-test.yml diff --git a/scripts/docker/docker-test.yml b/scripts/docker/docker-test.yml new file mode 100644 index 00000000..db83f238 --- /dev/null +++ b/scripts/docker/docker-test.yml @@ -0,0 +1,58 @@ +name: Docker Test Build + +on: + pull_request: + branches: [ "master" ] + workflow_dispatch: + +env: + REGISTRY: docker.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + test-build: + runs-on: ubuntu-latest + permissions: + contents: read + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + # Setup QEMU for multi-platform builds + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + # Setup Docker BuildX + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + # Build Docker image (without pushing) + - name: Build Docker image + id: build + uses: docker/build-push-action@v6 + with: + context: . + push: false + tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:test + platforms: linux/amd64 + cache-from: type=gha + cache-to: type=gha,mode=max + build-args: | + BUILDKIT_INLINE_CACHE=1 + + # Test the built image + - name: Test Docker image + run: | + docker run --rm ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:test python test_docker.py + + # Show image size + - name: Show image size + run: | + docker images ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:test --format "table {{.Repository}}\t{{.Tag}}\t{{.Size}}" + + # Clean up test image + - name: Clean up test image + if: always() + run: | + docker rmi ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:test || true From 19b9f7b8527fb7c7a3e88922591f53949cf03691 Mon Sep 17 00:00:00 2001 From: CI-DEV <154627941+IlumCI@users.noreply.github.com> Date: Fri, 1 Aug 2025 21:10:33 +0300 Subject: [PATCH 21/33] Delete test_docker.py --- test_docker.py | 65 -------------------------------------------------- 1 file changed, 65 deletions(-) delete mode 100644 test_docker.py diff --git a/test_docker.py b/test_docker.py deleted file mode 100644 index 4733fc0d..00000000 --- a/test_docker.py +++ /dev/null @@ -1,65 +0,0 @@ -#!/usr/bin/env python3 -""" -Test script to verify Swarms installation in Docker container. -""" - -import sys -from typing import Dict, Any - -def test_swarms_import() -> Dict[str, Any]: - """ - Test that swarms can be imported and basic functionality works. - - Returns: - Dict[str, Any]: Test results - """ - try: - import swarms - print(f"✅ Swarms imported successfully. Version: {swarms.__version__}") - - # Test basic functionality - from swarms import Agent - print("✅ Agent class imported successfully") - - return { - "status": "success", - "version": swarms.__version__, - "message": "Swarms package is working correctly" - } - - except ImportError as e: - print(f"❌ Failed to import swarms: {e}") - return { - "status": "error", - "error": str(e), - "message": "Swarms package import failed" - } - except Exception as e: - print(f"❌ Unexpected error: {e}") - return { - "status": "error", - "error": str(e), - "message": "Unexpected error occurred" - } - -def main() -> None: - """Main function to run tests.""" - print("🐝 Testing Swarms Docker Image...") - print("=" * 50) - - # Test Python version - print(f"Python version: {sys.version}") - - # Test swarms import - result = test_swarms_import() - - print("=" * 50) - if result["status"] == "success": - print("🎉 All tests passed! Docker image is working correctly.") - sys.exit(0) - else: - print("💥 Tests failed! Please check the Docker image.") - sys.exit(1) - -if __name__ == "__main__": - main() \ No newline at end of file From 01c4a2d28851dc50727cc5b8fa691aa8642debdc Mon Sep 17 00:00:00 2001 From: CI-DEV <154627941+IlumCI@users.noreply.github.com> Date: Fri, 1 Aug 2025 21:10:43 +0300 Subject: [PATCH 22/33] Delete docker-compose.yml --- docker-compose.yml | 71 ---------------------------------------------- 1 file changed, 71 deletions(-) delete mode 100644 docker-compose.yml diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index 8e4f2360..00000000 --- a/docker-compose.yml +++ /dev/null @@ -1,71 +0,0 @@ -version: '3.8' - -services: - swarms: - build: - context: . - dockerfile: Dockerfile - image: swarms:latest - container_name: swarms-container - environment: - - PYTHONUNBUFFERED=1 - - PYTHONPATH=/app - # Add your API keys here or use .env file - # - OPENAI_API_KEY=${OPENAI_API_KEY} - # - ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY} - # - GOOGLE_API_KEY=${GOOGLE_API_KEY} - volumes: - - .:/app - - ./data:/app/data - - ./models:/app/models - working_dir: /app - command: python test_docker.py - restart: unless-stopped - healthcheck: - test: ["CMD", "python", "-c", "import swarms; print('Health check passed')"] - interval: 30s - timeout: 10s - retries: 3 - start_period: 40s - - swarms-dev: - build: - context: . - dockerfile: Dockerfile - image: swarms:dev - container_name: swarms-dev-container - environment: - - PYTHONUNBUFFERED=1 - - PYTHONPATH=/app - volumes: - - .:/app - - ./data:/app/data - - ./models:/app/models - working_dir: /app - command: bash - stdin_open: true - tty: true - restart: unless-stopped - - swarms-api: - build: - context: . - dockerfile: Dockerfile - image: swarms:api - container_name: swarms-api-container - environment: - - PYTHONUNBUFFERED=1 - - PYTHONPATH=/app - volumes: - - .:/app - working_dir: /app - ports: - - "8000:8000" - command: python -m uvicorn main:app --host 0.0.0.0 --port 8000 --reload - restart: unless-stopped - depends_on: - - swarms - -networks: - default: - name: swarms-network \ No newline at end of file From 78a73c0d34fc095aed9f6e02924b571d7ce8718f Mon Sep 17 00:00:00 2001 From: CI-DEV <154627941+IlumCI@users.noreply.github.com> Date: Fri, 1 Aug 2025 21:10:52 +0300 Subject: [PATCH 23/33] Delete DOCKER.md --- DOCKER.md | 225 ------------------------------------------------------ 1 file changed, 225 deletions(-) delete mode 100644 DOCKER.md diff --git a/DOCKER.md b/DOCKER.md deleted file mode 100644 index 0b2ec1fb..00000000 --- a/DOCKER.md +++ /dev/null @@ -1,225 +0,0 @@ -# Swarms Docker Image - -This repository includes a Docker image for running Swarms, an AI agent framework. The image is automatically built and published to DockerHub on every push to the main branch and on version tags. - -## 🐳 Quick Start - -### Pull and Run - -```bash -# Pull the latest image -docker pull kyegomez/swarms:latest - -# Run a simple test -docker run --rm kyegomez/swarms:latest python test_docker.py - -# Run with interactive shell -docker run -it --rm kyegomez/swarms:latest bash -``` - -### Using Specific Versions - -```bash -# Pull a specific version -docker pull kyegomez/swarms:v8.0.4 - -# Run with specific version -docker run --rm kyegomez/swarms:v8.0.4 python -c "import swarms; print(swarms.__version__)" -``` - -## 🏗️ Building Locally - -### Prerequisites - -- Docker installed on your system -- Git to clone the repository - -### Build Steps - -```bash -# Clone the repository -git clone https://github.com/kyegomez/swarms.git -cd swarms - -# Build the image -docker build -t swarms:latest . - -# Test the image -docker run --rm swarms:latest python test_docker.py -``` - -## 🚀 Usage Examples - -### Basic Agent Example - -```bash -# Create a Python script (agent_example.py) -cat > agent_example.py << 'EOF' -from swarms import Agent - -# Create an agent -agent = Agent( - agent_name="test_agent", - system_prompt="You are a helpful AI assistant." -) - -# Run the agent -result = agent.run("Hello! How are you today?") -print(result) -EOF - -# Run in Docker -docker run --rm -v $(pwd):/app swarms:latest python /app/agent_example.py -``` - -### Interactive Development - -```bash -# Run with volume mount for development -docker run -it --rm \ - -v $(pwd):/app \ - -w /app \ - swarms:latest bash - -# Inside the container, you can now run Python scripts -python your_script.py -``` - -### Using Environment Variables - -```bash -# Run with environment variables -docker run --rm \ - -e OPENAI_API_KEY=your_api_key_here \ - -e ANTHROPIC_API_KEY=your_anthropic_key_here \ - swarms:latest python your_script.py -``` - -## 🔧 Configuration - -### Environment Variables - -The Docker image supports the following environment variables: - -- `OPENAI_API_KEY`: Your OpenAI API key -- `ANTHROPIC_API_KEY`: Your Anthropic API key -- `GOOGLE_API_KEY`: Your Google API key -- `PYTHONPATH`: Additional Python path entries -- `PYTHONUNBUFFERED`: Set to 1 for unbuffered output - -### Volume Mounts - -Common volume mount patterns: - -```bash -# Mount current directory for development --v $(pwd):/app - -# Mount specific directories --v $(pwd)/data:/app/data --v $(pwd)/models:/app/models - -# Mount configuration files --v $(pwd)/config:/app/config -``` - -## 🐛 Troubleshooting - -### Common Issues - -1. **Permission Denied** - ```bash - # Fix permission issues - docker run --rm -v $(pwd):/app:rw swarms:latest python your_script.py - ``` - -2. **Memory Issues** - ```bash - # Increase memory limit - docker run --rm --memory=4g swarms:latest python your_script.py - ``` - -3. **Network Issues** - ```bash - # Use host network - docker run --rm --network=host swarms:latest python your_script.py - ``` - -### Debug Mode - -```bash -# Run with debug output -docker run --rm -e PYTHONUNBUFFERED=1 swarms:latest python -u your_script.py - -# Run with interactive debugging -docker run -it --rm swarms:latest python -m pdb your_script.py -``` - -## 🔄 CI/CD Integration - -The Docker image is automatically built and published via GitHub Actions: - -- **Triggers**: Push to main branch, version tags (v*.*.*) -- **Platforms**: linux/amd64, linux/arm64 -- **Registry**: DockerHub (kyegomez/swarms) - -### GitHub Actions Secrets Required - -- `DOCKERHUB_USERNAME`: Your DockerHub username -- `DOCKERHUB_TOKEN`: Your DockerHub access token - -## 📊 Image Details - -### Base Image -- Python 3.11-slim-bullseye -- Multi-stage build for optimization -- UV package manager for faster installations - -### Image Size -- Optimized for minimal size -- Multi-stage build reduces final image size -- Only necessary dependencies included - -### Security -- Non-root user execution -- Minimal system dependencies -- Regular security updates - -## 🤝 Contributing - -To contribute to the Docker setup: - -1. Fork the repository -2. Make your changes to the Dockerfile -3. Test locally: `docker build -t swarms:test .` -4. Submit a pull request - -### Testing Changes - -```bash -# Build test image -docker build -t swarms:test . - -# Run tests -docker run --rm swarms:test python test_docker.py - -# Test with your code -docker run --rm -v $(pwd):/app swarms:test python your_test_script.py -``` - -## 📝 License - -This Docker setup is part of the Swarms project and follows the same MIT license. - -## 🆘 Support - -For issues with the Docker image: - -1. Check the troubleshooting section above -2. Review the GitHub Actions logs for build issues -3. Open an issue on GitHub with detailed error information -4. Include your Docker version and system information - ---- - -**Note**: This Docker image is automatically updated with each release. For production use, consider pinning to specific version tags for stability. \ No newline at end of file From 90cc77ed71bf30d26e9af5adfc159e051e299988 Mon Sep 17 00:00:00 2001 From: CI-DEV <154627941+IlumCI@users.noreply.github.com> Date: Fri, 1 Aug 2025 21:11:02 +0300 Subject: [PATCH 24/33] Delete Dockerfile --- Dockerfile | 48 ------------------------------------------------ 1 file changed, 48 deletions(-) delete mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 44392b09..00000000 --- a/Dockerfile +++ /dev/null @@ -1,48 +0,0 @@ -# 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 \ - PATH="/opt/venv/bin:${PATH}" \ - PYTHONPATH="/app:${PYTHONPATH}" \ - USER=swarms - -# Set working directory -WORKDIR /app - -# 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 && \ - chown -R $USER:$USER /app - -# Copy application code -COPY --chown=$USER:$USER . . - -# Switch to non-root -USER $USER - -# Optional health check -HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \ - CMD python -c "import swarms; print('Health check passed')" || exit 1 From 3519463d24ed8b5a37eda570d21f20f01e859362 Mon Sep 17 00:00:00 2001 From: CI-DEV <154627941+IlumCI@users.noreply.github.com> Date: Fri, 1 Aug 2025 21:11:16 +0300 Subject: [PATCH 25/33] Delete .dockerignore --- .dockerignore | 297 -------------------------------------------------- 1 file changed, 297 deletions(-) delete mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index 9b9944a2..00000000 --- a/.dockerignore +++ /dev/null @@ -1,297 +0,0 @@ -.git -.gitignore -.env -__pycache__ -*.pyc -*.pyo -*.pyd -.Python -env/ -venv/ -.tox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*.cover -*.log -.pytest_cache/ -.mypy_cache/ - -__pycache__/ -.venv/ - -.env - -image/ -audio/ -video/ -artifacts_three -dataframe/ -.ruff_cache -.pytest_cache -static/generated -runs -Financial-Analysis-Agent_state.json -experimental -artifacts_five -encryption -errors -chroma -agent_workspace -.pt -Accounting Assistant_state.json -Unit Testing Agent_state.json -sec_agent -Devin_state.json -poetry.lock -hire_researchers -agent_workspace -json_logs -Medical Image Diagnostic Agent_state.json -flight agent_state.json -D_state.json -artifacts_six -artifacts_seven -swarms/__pycache__ -artifacts_once -transcript_generator.json -venv -.DS_Store -Cargo.lock -.DS_STORE -artifacts_logs -Cargo.lock -Medical Treatment Recommendation Agent_state.json -swarms/agents/.DS_Store -artifacts_two -logs -T_state.json -_build -conversation.txt -t1_state.json -stderr_log.txt -t2_state.json -.vscode -.DS_STORE -# Byte-compiled / optimized / DLL files -Transcript Generator_state.json -__pycache__/ -*.py[cod] -*$py.class -.grit -swarm-worker-01_state.json -error.txt -Devin Worker 2_state.json -# C extensions -*.so -.ruff_cache - - -errors.txt - -Autonomous-Agent-XYZ1B_state.json -# Distribution / packaging -.Python -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -lib/ -lib64/ -parts/ -sdist/ -var/ -wheels/ -share/python-wheels/ -*.egg-info/ -.installed.cfg -*.egg -MANIFEST - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ -.tox/ -.nox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*.cover -*.py,cover -.hypothesis/ -.pytest_cache/ -cover/ - -# Translations -*.mo -*.pot - -# Django stuff: -*.log -local_settings.py -db.sqlite3 -db.sqlite3-journal - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -docs/_build/ - -# PyBuilder -.pybuilder/ -target/ - -# Jupyter Notebook -.ipynb_checkpoints - -# IPython -profile_default/ -ipython_config.py -.DS_Store - -# pyenv -# For a library or package, you might want to ignore these files since the code is -# intended to run in multiple environments; otherwise, check them in: -# .python-version - -# pipenv -# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. -# However, in case of collaboration, if having platform-specific dependencies or dependencies -# having no cross-platform support, pipenv may install dependencies that don't work, or not -# install all needed dependencies. -#Pipfile.lock - -# poetry -# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. -# This is especially recommended for binary packages to ensure reproducibility, and is more -# commonly ignored for libraries. -# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control -#poetry.lock - -# pdm -# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. -#pdm.lock -# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it -# in version control. -# https://pdm.fming.dev/#use-with-ide -.pdm.toml - -# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm -__pypackages__/ - -# Celery stuff -celerybeat-schedule -celerybeat.pid - -# SageMath parsed files -*.sage.py - -# Environments -.env -.venv -env/ -venv/ -ENV/ -env.bak/ -venv.bak/ - -# Spyder project settings -.spyderproject -.spyproject - -# Rope project settings -.ropeproject - -# mkdocs documentation -/site - -# mypy -.mypy_cache/ -.dmypy.json -dmypy.json - -# Pyre type checker -.pyre/ - -# pytype static type analyzer -.pytype/ - -# Cython debug symbols -cython_debug/ - -# PyCharm -# JetBrains specific template is maintained in a separate JetBrains.gitignore that can -# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore -# and can be added to the global gitignore or merged into this file. For a more nuclear -# option (not recommended) you can uncomment the following to ignore the entire idea folder. -#.idea/ -.vscode/settings.json -# -*- mode: gitignore; -*- -*~ -\#*\# -/.emacs.desktop -/.emacs.desktop.lock -*.elc -auto-save-list -tramp -.\#* - -# Org-mode -.org-id-locations -*_archive - -# flymake-mode -*_flymake.* - -# eshell files -/eshell/history -/eshell/lastdir - -# elpa packages -/elpa/ - -# reftex files -*.rel - -# AUCTeX auto folder -/auto/ - -# cask packages -.cask/ -dist/ - -# Flycheck -flycheck_*.el - -# server auth directory -/server/ - -# projectiles files -.projectile - -# directory configuration -.dir-locals.el - -# network security -/network-security.data - From f0c1544ec8a1b47d8b0ca0f59a702beea0fe6988 Mon Sep 17 00:00:00 2001 From: CI-DEV <154627941+IlumCI@users.noreply.github.com> Date: Fri, 1 Aug 2025 21:11:30 +0300 Subject: [PATCH 26/33] Delete scripts/docker-utils.ps1 --- scripts/docker-utils.ps1 | 139 --------------------------------------- 1 file changed, 139 deletions(-) delete mode 100644 scripts/docker-utils.ps1 diff --git a/scripts/docker-utils.ps1 b/scripts/docker-utils.ps1 deleted file mode 100644 index 59c94636..00000000 --- a/scripts/docker-utils.ps1 +++ /dev/null @@ -1,139 +0,0 @@ -# Docker utilities for Swarms project (PowerShell version) -# Usage: .\scripts\docker-utils.ps1 [command] - -param( - [Parameter(Position=0)] - [string]$Command = "help" -) - -# Configuration -$ImageName = "swarms" -$Registry = "kyegomez" -$FullImageName = "$Registry/$ImageName" - -# Functions -function Write-Usage { - Write-Host "Docker Utilities for Swarms" -ForegroundColor Blue - Write-Host "" - Write-Host "Usage: .\scripts\docker-utils.ps1 [command]" - Write-Host "" - Write-Host "Commands:" - Write-Host " build Build the Docker image locally" - Write-Host " test Test the Docker image" - Write-Host " run Run the Docker image interactively" - Write-Host " push Push to DockerHub (requires login)" - Write-Host " clean Clean up Docker images and containers" - Write-Host " logs Show logs from running containers" - Write-Host " shell Open shell in running container" - Write-Host " compose-up Start services with docker-compose" - Write-Host " compose-down Stop services with docker-compose" - Write-Host " help Show this help message" - Write-Host "" -} - -function Build-Image { - Write-Host "Building Docker image..." -ForegroundColor Green - docker build -t "$ImageName`:latest" . - Write-Host "✅ Image built successfully!" -ForegroundColor Green -} - -function Test-Image { - Write-Host "Testing Docker image..." -ForegroundColor Green - docker run --rm "$ImageName`:latest" python test_docker.py - Write-Host "✅ Image test completed!" -ForegroundColor Green -} - -function Run-Interactive { - Write-Host "Running Docker image interactively..." -ForegroundColor Green - docker run -it --rm -v "${PWD}:/app" -w /app "$ImageName`:latest" bash -} - -function Push-ToDockerHub { - Write-Host "⚠️ Make sure you're logged into DockerHub first!" -ForegroundColor Yellow - Write-Host "Pushing to DockerHub..." -ForegroundColor Green - - # Tag the image - docker tag "$ImageName`:latest" "$FullImageName`:latest" - - # Push to DockerHub - docker push "$FullImageName`:latest" - - Write-Host "✅ Image pushed to DockerHub!" -ForegroundColor Green -} - -function Clean-Docker { - Write-Host "Cleaning up Docker resources..." -ForegroundColor Yellow - - # Stop and remove containers - docker ps -aq | ForEach-Object { docker rm -f $_ } - - # Remove images - docker images "$ImageName" -q | ForEach-Object { docker rmi -f $_ } - - # Remove dangling images - docker image prune -f - - Write-Host "✅ Docker cleanup completed!" -ForegroundColor Green -} - -function Show-Logs { - Write-Host "Showing logs from running containers..." -ForegroundColor Green - docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}" - Write-Host "" - - # Show logs for swarms containers - $containers = docker ps --filter "name=swarms" --format "{{.Names}}" - foreach ($container in $containers) { - Write-Host "Logs for $container:" -ForegroundColor Blue - docker logs $container --tail 20 - Write-Host "" - } -} - -function Open-Shell { - Write-Host "Opening shell in running container..." -ForegroundColor Green - - # Find running swarms container - $container = docker ps --filter "name=swarms" --format "{{.Names}}" | Select-Object -First 1 - - if (-not $container) { - Write-Host "❌ No running swarms container found!" -ForegroundColor Red - Write-Host "Start a container first with: .\scripts\docker-utils.ps1 run" - exit 1 - } - - Write-Host "Opening shell in $container..." -ForegroundColor Blue - docker exec -it $container bash -} - -function Compose-Up { - Write-Host "Starting services with docker-compose..." -ForegroundColor Green - docker-compose up -d - Write-Host "✅ Services started!" -ForegroundColor Green - Write-Host "Use 'docker-compose logs -f' to view logs" -} - -function Compose-Down { - Write-Host "Stopping services with docker-compose..." -ForegroundColor Yellow - docker-compose down - Write-Host "✅ Services stopped!" -ForegroundColor Green -} - -# Main script logic -switch ($Command.ToLower()) { - "build" { Build-Image } - "test" { Test-Image } - "run" { Run-Interactive } - "push" { Push-ToDockerHub } - "clean" { Clean-Docker } - "logs" { Show-Logs } - "shell" { Open-Shell } - "compose-up" { Compose-Up } - "compose-down" { Compose-Down } - "help" { Write-Usage } - default { - Write-Host "❌ Unknown command: $Command" -ForegroundColor Red - Write-Usage - exit 1 - } -} \ No newline at end of file From ec495b6668de535976326adba9283c1287f949c4 Mon Sep 17 00:00:00 2001 From: CI-DEV <154627941+IlumCI@users.noreply.github.com> Date: Fri, 1 Aug 2025 21:11:37 +0300 Subject: [PATCH 27/33] Delete scripts/docker-utils.sh --- scripts/docker-utils.sh | 167 ---------------------------------------- 1 file changed, 167 deletions(-) delete mode 100644 scripts/docker-utils.sh diff --git a/scripts/docker-utils.sh b/scripts/docker-utils.sh deleted file mode 100644 index 5b86e7dd..00000000 --- a/scripts/docker-utils.sh +++ /dev/null @@ -1,167 +0,0 @@ -#!/bin/bash - -# Docker utilities for Swarms project -# Usage: ./scripts/docker-utils.sh [command] - -set -e - -# Colors for output -RED='\033[0;31m' -GREEN='\033[0;32m' -YELLOW='\033[1;33m' -BLUE='\033[0;34m' -NC='\033[0m' # No Color - -# Configuration -IMAGE_NAME="swarms" -REGISTRY="kyegomez" -FULL_IMAGE_NAME="${REGISTRY}/${IMAGE_NAME}" - -# Functions -print_usage() { - echo -e "${BLUE}Docker Utilities for Swarms${NC}" - echo "" - echo "Usage: $0 [command]" - echo "" - echo "Commands:" - echo " build Build the Docker image locally" - echo " test Test the Docker image" - echo " run Run the Docker image interactively" - echo " push Push to DockerHub (requires login)" - echo " clean Clean up Docker images and containers" - echo " logs Show logs from running containers" - echo " shell Open shell in running container" - echo " compose-up Start services with docker-compose" - echo " compose-down Stop services with docker-compose" - echo " help Show this help message" - echo "" -} - -build_image() { - echo -e "${GREEN}Building Docker image...${NC}" - docker build -t "${IMAGE_NAME}:latest" . - echo -e "${GREEN}✅ Image built successfully!${NC}" -} - -test_image() { - echo -e "${GREEN}Testing Docker image...${NC}" - docker run --rm "${IMAGE_NAME}:latest" python test_docker.py - echo -e "${GREEN}✅ Image test completed!${NC}" -} - -run_interactive() { - echo -e "${GREEN}Running Docker image interactively...${NC}" - docker run -it --rm \ - -v "$(pwd):/app" \ - -w /app \ - "${IMAGE_NAME}:latest" bash -} - -push_to_dockerhub() { - echo -e "${YELLOW}⚠️ Make sure you're logged into DockerHub first!${NC}" - echo -e "${GREEN}Pushing to DockerHub...${NC}" - - # Tag the image - docker tag "${IMAGE_NAME}:latest" "${FULL_IMAGE_NAME}:latest" - - # Push to DockerHub - docker push "${FULL_IMAGE_NAME}:latest" - - echo -e "${GREEN}✅ Image pushed to DockerHub!${NC}" -} - -clean_docker() { - echo -e "${YELLOW}Cleaning up Docker resources...${NC}" - - # Stop and remove containers - docker ps -aq | xargs -r docker rm -f - - # Remove images - docker images "${IMAGE_NAME}" -q | xargs -r docker rmi -f - - # Remove dangling images - docker image prune -f - - echo -e "${GREEN}✅ Docker cleanup completed!${NC}" -} - -show_logs() { - echo -e "${GREEN}Showing logs from running containers...${NC}" - docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}" - echo "" - - # Show logs for swarms containers - for container in $(docker ps --filter "name=swarms" --format "{{.Names}}"); do - echo -e "${BLUE}Logs for $container:${NC}" - docker logs "$container" --tail 20 - echo "" - done -} - -open_shell() { - echo -e "${GREEN}Opening shell in running container...${NC}" - - # Find running swarms container - container=$(docker ps --filter "name=swarms" --format "{{.Names}}" | head -1) - - if [ -z "$container" ]; then - echo -e "${RED}❌ No running swarms container found!${NC}" - echo "Start a container first with: $0 run" - exit 1 - fi - - echo -e "${BLUE}Opening shell in $container...${NC}" - docker exec -it "$container" bash -} - -compose_up() { - echo -e "${GREEN}Starting services with docker-compose...${NC}" - docker-compose up -d - echo -e "${GREEN}✅ Services started!${NC}" - echo "Use 'docker-compose logs -f' to view logs" -} - -compose_down() { - echo -e "${YELLOW}Stopping services with docker-compose...${NC}" - docker-compose down - echo -e "${GREEN}✅ Services stopped!${NC}" -} - -# Main script logic -case "${1:-help}" in - build) - build_image - ;; - test) - test_image - ;; - run) - run_interactive - ;; - push) - push_to_dockerhub - ;; - clean) - clean_docker - ;; - logs) - show_logs - ;; - shell) - open_shell - ;; - compose-up) - compose_up - ;; - compose-down) - compose_down - ;; - help|--help|-h) - print_usage - ;; - *) - echo -e "${RED}❌ Unknown command: $1${NC}" - print_usage - exit 1 - ;; -esac \ No newline at end of file From 753f284da2677b8eb409a99bf425f096b9a5ea0b Mon Sep 17 00:00:00 2001 From: CI-DEV <154627941+IlumCI@users.noreply.github.com> Date: Fri, 1 Aug 2025 21:11:58 +0300 Subject: [PATCH 28/33] Delete .github/workflows/docker-publish.yml --- .github/workflows/docker-publish.yml | 76 ---------------------------- 1 file changed, 76 deletions(-) delete mode 100644 .github/workflows/docker-publish.yml diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml deleted file mode 100644 index 40fac9cb..00000000 --- a/.github/workflows/docker-publish.yml +++ /dev/null @@ -1,76 +0,0 @@ -name: Docker Build and Publish - -on: - push: - branches: [ "master" ] - # Publish semver tags as releases - tags: [ 'v*.*.*' ] - pull_request: - branches: [ "master" ] - -env: - # Use docker.io for Docker Hub if empty - REGISTRY: docker.io - # github.repository as / - IMAGE_NAME: ${{ github.repository }} - -jobs: - build: - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - # This is used to complete the identity challenge - # with sigstore/fulcio when running outside of PRs. - id-token: write - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - # Setup QEMU for multi-platform builds - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - # Setup Docker BuildX - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - # Login to Docker Hub - - name: Log into registry ${{ env.REGISTRY }} - if: github.event_name != 'pull_request' - uses: docker/login-action@v3 - with: - registry: ${{ env.REGISTRY }} - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - # Extract metadata (tags, labels) for Docker - - name: Extract Docker metadata - id: meta - uses: docker/metadata-action@v5 - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - tags: | - type=ref,event=branch - type=ref,event=pr - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - type=semver,pattern={{major}} - type=sha - type=raw,value=latest,enable={{is_default_branch}} - - # Build and push Docker image - - name: Build and push Docker image - id: build-and-push - uses: docker/build-push-action@v6 - with: - context: . - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - platforms: linux/amd64,linux/arm64 - cache-from: type=gha - cache-to: type=gha,mode=max - build-args: | - BUILDKIT_INLINE_CACHE=1 From 945a43981977952c3ab1434fbfc186c781bd2631 Mon Sep 17 00:00:00 2001 From: CI-DEV <154627941+IlumCI@users.noreply.github.com> Date: Fri, 1 Aug 2025 21:12:05 +0300 Subject: [PATCH 29/33] Delete .github/workflows/docker-image.yml --- .github/workflows/docker-image.yml | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 .github/workflows/docker-image.yml diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml deleted file mode 100644 index 793d8e0e..00000000 --- a/.github/workflows/docker-image.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: Docker Image CI - -on: - push: - branches: [ "master" ] - pull_request: - branches: [ "master" ] - -jobs: - - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - name: Build the Docker image - run: docker build . --file Dockerfile --tag my-image-name:$(date +%s) From db3b8af6e8ca71207e5d17da00cdc655f170a000 Mon Sep 17 00:00:00 2001 From: CI-DEV <154627941+IlumCI@users.noreply.github.com> Date: Fri, 1 Aug 2025 21:12:13 +0300 Subject: [PATCH 30/33] Delete .github/workflows/docker-test.yml --- .github/workflows/docker-test.yml | 58 ------------------------------- 1 file changed, 58 deletions(-) delete mode 100644 .github/workflows/docker-test.yml diff --git a/.github/workflows/docker-test.yml b/.github/workflows/docker-test.yml deleted file mode 100644 index 05ee8ed3..00000000 --- a/.github/workflows/docker-test.yml +++ /dev/null @@ -1,58 +0,0 @@ -name: Docker Test Build - -on: - pull_request: - branches: [ "master" ] - workflow_dispatch: - -env: - REGISTRY: docker.io - IMAGE_NAME: ${{ github.repository }} - -jobs: - test-build: - runs-on: ubuntu-latest - permissions: - contents: read - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - # Setup QEMU for multi-platform builds - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - # Setup Docker BuildX - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - # Build Docker image (without pushing) - - name: Build Docker image - id: build - uses: docker/build-push-action@v6 - with: - context: . - push: false - tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:test - platforms: linux/amd64 - cache-from: type=gha - cache-to: type=gha,mode=max - build-args: | - BUILDKIT_INLINE_CACHE=1 - - # Test the built image - - name: Test Docker image - run: | - docker run --rm ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:test python test_docker.py - - # Show image size - - name: Show image size - run: | - docker images ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:test --format "table {{.Repository}}\t{{.Tag}}\t{{.Size}}" - - # Clean up test image - - name: Clean up test image - if: always() - run: | - docker rmi ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:test || true \ No newline at end of file From ff76d107ff9da6d5c58a0f5f46304336c6641373 Mon Sep 17 00:00:00 2001 From: CI-DEV <154627941+IlumCI@users.noreply.github.com> Date: Fri, 1 Aug 2025 21:13:29 +0300 Subject: [PATCH 31/33] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e893bfc4..88b23d59 100644 --- a/README.md +++ b/README.md @@ -162,7 +162,7 @@ $ docker run -it --rm -v $(pwd):/app kyegomez/swarms:latest bash $ docker-compose up -d ``` -For more Docker options and advanced usage, see our [Docker documentation](DOCKER.md). +For more Docker options and advanced usage, see our [Docker documentation](/scripts/docker/DOCKER.md). --- From 7ed500b7435ac0897da9ec49c2b266e2b8a947f9 Mon Sep 17 00:00:00 2001 From: CI-DEV <154627941+IlumCI@users.noreply.github.com> Date: Wed, 13 Aug 2025 20:23:36 +0300 Subject: [PATCH 32/33] Create setup_docker_secrets.MD --- scripts/docker/setup_docker_secrets.MD | 113 +++++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 scripts/docker/setup_docker_secrets.MD diff --git a/scripts/docker/setup_docker_secrets.MD b/scripts/docker/setup_docker_secrets.MD new file mode 100644 index 00000000..65f97183 --- /dev/null +++ b/scripts/docker/setup_docker_secrets.MD @@ -0,0 +1,113 @@ +# Setting up DockerHub Secrets for GitHub Actions + +This guide will help you set up the required secrets for the Docker workflow to automatically build and push images to DockerHub. + +## Prerequisites + +1. A DockerHub account +2. Admin access to the GitHub repository +3. DockerHub access token + +## Step 1: Create a DockerHub Access Token + +1. Log in to [DockerHub](https://hub.docker.com/) +2. Go to your account settings +3. Navigate to "Security" → "Access Tokens" +4. Click "New Access Token" +5. Give it a name (e.g., "GitHub Actions") +6. Set the permissions to "Read & Write" +7. Copy the generated token (you won't be able to see it again!) + +## Step 2: Add Secrets to GitHub Repository + +1. Go to your GitHub repository +2. Navigate to "Settings" → "Secrets and variables" → "Actions" +3. Click "New repository secret" +4. Add the following secrets: + +### Required Secrets + +| Secret Name | Value | Description | +|-------------|-------|-------------| +| `DOCKERHUB_USERNAME` | Your DockerHub username | Your DockerHub username (e.g., `kyegomez`) | +| `DOCKERHUB_TOKEN` | Your DockerHub access token | The access token you created in Step 1 | + +## Step 3: Verify Setup + +1. Push a commit to the `main` branch +2. Go to the "Actions" tab in your GitHub repository +3. You should see the "Docker Build and Publish" workflow running +4. Check that it completes successfully + +## Troubleshooting + +### Common Issues + +1. **Authentication Failed** + - Double-check your DockerHub username and token + - Ensure the token has "Read & Write" permissions + - Make sure the token hasn't expired + +2. **Permission Denied** + - Verify you have admin access to the repository + - Check that the secrets are named exactly as shown above + +3. **Workflow Not Triggering** + - Ensure you're pushing to the `main` branch + - Check that the workflow file is in `.github/workflows/` + - Verify the workflow file has the correct triggers + +### Testing Locally + +You can test the Docker build locally before pushing: + +```bash +# Build the image locally +docker build -t swarms:test . + +# Test the image +docker run --rm swarms:test python test_docker.py + +# If everything works, push to GitHub +git add . +git commit -m "Add Docker support" +git push origin main +``` + +## Security Notes + +- Never commit secrets directly to your repository +- Use repository secrets for sensitive information +- Regularly rotate your DockerHub access tokens +- Consider using organization-level secrets for team repositories + +## Additional Configuration + +### Custom Registry + +If you want to use a different registry (not DockerHub), update the workflow file: + +```yaml +env: + REGISTRY: your-registry.com + IMAGE_NAME: your-org/your-repo +``` + +### Multiple Tags + +The workflow automatically creates tags based on: +- Git branch name +- Git commit SHA +- Version tags (v*.*.*) +- Latest tag for main branch + +You can customize this in the workflow file under the "Extract Docker metadata" step. + +## Support + +If you encounter issues: + +1. Check the GitHub Actions logs for detailed error messages +2. Verify your DockerHub credentials +3. Ensure the workflow file is properly configured +4. Open an issue in the repository with the error details From e657324bf24e4afd9b20c55b841a56e0e94daa86 Mon Sep 17 00:00:00 2001 From: CI-DEV <154627941+IlumCI@users.noreply.github.com> Date: Wed, 13 Aug 2025 20:23:49 +0300 Subject: [PATCH 33/33] Delete scripts/setup-dockerhub-secrets.md --- scripts/setup-dockerhub-secrets.md | 113 ----------------------------- 1 file changed, 113 deletions(-) delete mode 100644 scripts/setup-dockerhub-secrets.md diff --git a/scripts/setup-dockerhub-secrets.md b/scripts/setup-dockerhub-secrets.md deleted file mode 100644 index ac4dd691..00000000 --- a/scripts/setup-dockerhub-secrets.md +++ /dev/null @@ -1,113 +0,0 @@ -# Setting up DockerHub Secrets for GitHub Actions - -This guide will help you set up the required secrets for the Docker workflow to automatically build and push images to DockerHub. - -## Prerequisites - -1. A DockerHub account -2. Admin access to the GitHub repository -3. DockerHub access token - -## Step 1: Create a DockerHub Access Token - -1. Log in to [DockerHub](https://hub.docker.com/) -2. Go to your account settings -3. Navigate to "Security" → "Access Tokens" -4. Click "New Access Token" -5. Give it a name (e.g., "GitHub Actions") -6. Set the permissions to "Read & Write" -7. Copy the generated token (you won't be able to see it again!) - -## Step 2: Add Secrets to GitHub Repository - -1. Go to your GitHub repository -2. Navigate to "Settings" → "Secrets and variables" → "Actions" -3. Click "New repository secret" -4. Add the following secrets: - -### Required Secrets - -| Secret Name | Value | Description | -|-------------|-------|-------------| -| `DOCKERHUB_USERNAME` | Your DockerHub username | Your DockerHub username (e.g., `kyegomez`) | -| `DOCKERHUB_TOKEN` | Your DockerHub access token | The access token you created in Step 1 | - -## Step 3: Verify Setup - -1. Push a commit to the `main` branch -2. Go to the "Actions" tab in your GitHub repository -3. You should see the "Docker Build and Publish" workflow running -4. Check that it completes successfully - -## Troubleshooting - -### Common Issues - -1. **Authentication Failed** - - Double-check your DockerHub username and token - - Ensure the token has "Read & Write" permissions - - Make sure the token hasn't expired - -2. **Permission Denied** - - Verify you have admin access to the repository - - Check that the secrets are named exactly as shown above - -3. **Workflow Not Triggering** - - Ensure you're pushing to the `main` branch - - Check that the workflow file is in `.github/workflows/` - - Verify the workflow file has the correct triggers - -### Testing Locally - -You can test the Docker build locally before pushing: - -```bash -# Build the image locally -docker build -t swarms:test . - -# Test the image -docker run --rm swarms:test python test_docker.py - -# If everything works, push to GitHub -git add . -git commit -m "Add Docker support" -git push origin main -``` - -## Security Notes - -- Never commit secrets directly to your repository -- Use repository secrets for sensitive information -- Regularly rotate your DockerHub access tokens -- Consider using organization-level secrets for team repositories - -## Additional Configuration - -### Custom Registry - -If you want to use a different registry (not DockerHub), update the workflow file: - -```yaml -env: - REGISTRY: your-registry.com - IMAGE_NAME: your-org/your-repo -``` - -### Multiple Tags - -The workflow automatically creates tags based on: -- Git branch name -- Git commit SHA -- Version tags (v*.*.*) -- Latest tag for main branch - -You can customize this in the workflow file under the "Extract Docker metadata" step. - -## Support - -If you encounter issues: - -1. Check the GitHub Actions logs for detailed error messages -2. Verify your DockerHub credentials -3. Ensure the workflow file is properly configured -4. Open an issue in the repository with the error details \ No newline at end of file