diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index e331605..0f0595b 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -38,11 +38,40 @@ jobs: steps: - uses: actions/checkout@v4 + # Add aggressive cleanup before any Docker operations + - name: Free disk space + run: | + # Remove large unnecessary packages + sudo apt-get remove -y '^dotnet-.*' '^llvm-.*' 'php.*' azure-cli google-cloud-sdk mongodb-org + sudo apt-get autoremove -y + sudo apt-get clean + + # Remove large directories + sudo rm -rf /usr/share/dotnet + sudo rm -rf /usr/local/lib/android + sudo rm -rf /opt/ghc + sudo rm -rf /opt/hostedtoolcache + sudo rm -rf /usr/local/.ghcup + sudo rm -rf /usr/local/share/powershell + sudo rm -rf /usr/local/share/chromium + + # Clean Docker + docker system prune -af + docker image prune -af + docker builder prune -af + + df -h + - name: Set up QEMU uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + with: + driver-opts: | + image=moby/buildkit:buildx-stable-1 + network=host + buildkitd-flags: --debug - name: Log in to GitHub Container Registry uses: docker/login-action@v3 @@ -64,29 +93,50 @@ jobs: type=semver,pattern={{major}}.{{minor}} type=raw,value=latest - # Build and push proxy image - - name: Build and push proxy_only Docker image + # Build and push proxy AMD64 + - name: Build and push proxy_only Docker image AMD64 uses: docker/build-push-action@v5 with: context: . file: Dockerfile.proxy_only push: true - platforms: linux/amd64,linux/arm64 + platforms: linux/amd64 tags: ${{ steps.meta-proxy.outputs.tags }} labels: ${{ steps.meta-proxy.outputs.labels }} - cache-from: type=gha,scope=proxy - cache-to: type=gha,scope=proxy,mode=max - - # Add cleanup steps after proxy build - - name: Clean up disk space after proxy build + cache-from: type=gha,scope=proxy-amd64 + cache-to: type=gha,scope=proxy-amd64,mode=max + outputs: type=registry,compression=zstd,compression-level=5 + + # Cleanup after AMD64 build + - name: Cleanup after AMD64 build + run: | + docker system prune -af + docker builder prune -af + df -h + + # Build proxy ARM64 + - name: Build and push proxy_only Docker image ARM64 + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.proxy_only + push: true + platforms: linux/arm64 + tags: ${{ steps.meta-proxy.outputs.tags }} + labels: ${{ steps.meta-proxy.outputs.labels }} + cache-from: type=gha,scope=proxy-arm64 + cache-to: type=gha,scope=proxy-arm64,mode=max + outputs: type=registry,compression=zstd,compression-level=5 + + # Cleanup after proxy builds + - name: Cleanup after proxy builds run: | - # Remove all unused docker data including stopped containers, unused networks, dangling images, and build cache docker system prune -af - # Remove all unused build cache docker builder prune -af - # Clean only user-owned files in /tmp, ignore permission errors find /tmp -type f -user $(id -u) -exec rm -f {} + 2>/dev/null || true + df -h + # Extract metadata for full image - name: Extract metadata for Docker id: meta uses: docker/metadata-action@v5 @@ -96,14 +146,36 @@ jobs: type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} latest - - - name: Build and push Docker image + + # Build full image AMD64 + - name: Build and push Docker image AMD64 + uses: docker/build-push-action@v5 + with: + context: . + push: true + platforms: linux/amd64 + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha,scope=full-amd64 + cache-to: type=gha,scope=full-amd64,mode=max + outputs: type=registry,compression=zstd,compression-level=5 + + # Cleanup between architectures + - name: Cleanup between architectures + run: | + docker system prune -af + docker builder prune -af + df -h + + # Build full image ARM64 + - name: Build and push Docker image ARM64 uses: docker/build-push-action@v5 with: context: . push: true - platforms: linux/amd64,linux/arm64 + platforms: linux/arm64 tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - cache-from: type=gha - cache-to: type=gha,mode=max + cache-from: type=gha,scope=full-arm64 + cache-to: type=gha,scope=full-arm64,mode=max + outputs: type=registry,compression=zstd,compression-level=5 diff --git a/Dockerfile b/Dockerfile index 2a0f33f..6253809 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,13 +10,13 @@ ENV OPTILLM_PORT=$PORT WORKDIR /app # Install system dependencies -RUN --mount=type=cache,target=/var/cache/apt \ - --mount=type=cache,target=/var/lib/apt \ - apt-get update && apt-get install -y --no-install-recommends \ +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ build-essential \ python3-dev \ gcc \ g++ \ + && apt-get clean \ && rm -rf /var/lib/apt/lists/* # Copy only the requirements file first to leverage Docker cache @@ -34,10 +34,10 @@ LABEL org.opencontainers.image.description="OptiLLM full image with model servin LABEL org.opencontainers.image.licenses="Apache-2.0" # Install curl for the healthcheck -RUN --mount=type=cache,target=/var/cache/apt \ - --mount=type=cache,target=/var/lib/apt \ - apt-get update && apt-get install -y --no-install-recommends \ +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ curl \ + && apt-get clean \ && rm -rf /var/lib/apt/lists/* # Set working directory diff --git a/Dockerfile.proxy_only b/Dockerfile.proxy_only index f261795..dc8bdc3 100644 --- a/Dockerfile.proxy_only +++ b/Dockerfile.proxy_only @@ -10,13 +10,13 @@ ENV OPTILLM_PORT=$PORT WORKDIR /app # Install system dependencies -RUN --mount=type=cache,target=/var/cache/apt \ - --mount=type=cache,target=/var/lib/apt \ - apt-get update && apt-get install -y --no-install-recommends \ +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ build-essential \ python3-dev \ gcc \ g++ \ + && apt-get clean \ && rm -rf /var/lib/apt/lists/* # Copy only the requirements file first to leverage Docker cache diff --git a/setup.py b/setup.py index ce0fdb8..b43cc1d 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ setup( name="optillm", - version="0.0.34", + version="0.0.35", packages=find_packages(), py_modules=['optillm'], package_data={