Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 88 additions & 16 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
12 changes: 6 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile.proxy_only
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name="optillm",
version="0.0.34",
version="0.0.35",
packages=find_packages(),
py_modules=['optillm'],
package_data={
Expand Down