Skip to content

7.4 billion tokens per month. 34 free LLM providers. 635 free model endpoints. All behind one /v1 endpoint, plus any custom OpenAI-compatible endpoint. Smart routing, automatic failover, encrypted keys. Personal experimentation only.

TypeScript

ci(docker): native per-arch builds, no QEMU — fixes 20-min/failed arm64 legs

Tashfeena4b3adb50d11
diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml
index 880760f3..324e0cf3 100644
--- a/.github/workflows/docker.yml
+++ b/.github/workflows/docker.yml
@@ -11,17 +11,36 @@ permissions:
contents: read
packages: write
+env:
+ IMAGE: ghcr.io/${{ github.repository_owner }}/freellmapi
+
+# Each platform builds NATIVELY (ubuntu-24.04-arm is free for public repos) —
+# no QEMU. Emulated arm64 builds took ~20 min cold (better-sqlite3 compiles
+# via node-gyp) and their giant gha-cache exports hit backend errors; native
+# legs build in ~3 min with small per-arch caches. Pushes are by digest, then
+# a merge job stitches the multi-arch manifest. PRs only build (no push).
jobs:
build:
- name: Build Docker image
- runs-on: ubuntu-latest
+ name: Build (${{ matrix.platform }})
+ runs-on: ${{ matrix.runner }}
+ strategy:
+ fail-fast: false
+ matrix:
+ include:
+ - platform: linux/amd64
+ runner: ubuntu-latest
+ - platform: linux/arm64
+ runner: ubuntu-24.04-arm
steps:
- uses: actions/checkout@v4
- - uses: docker/setup-qemu-action@v3
-
- uses: docker/setup-buildx-action@v3
+ - name: Platform slug
+ run: |
+ platform="${{ matrix.platform }}"
+ echo "PLATFORM_PAIR=${platform//\//-}" >> "$GITHUB_ENV"
+
- name: Log in to GHCR
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
@@ -34,21 +53,75 @@ jobs:
id: meta
uses: docker/metadata-action@v5
with:
- images: ghcr.io/${{ github.repository_owner }}/freellmapi
- tags: |
- type=ref,event=branch
- type=ref,event=tag
- type=sha,prefix=sha-
- type=raw,value=latest,enable={{is_default_branch}}
+ images: ${{ env.IMAGE }}
- - name: Build and publish
+ - name: Build (and push by digest)
+ id: build
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
- platforms: linux/amd64,linux/arm64
- push: ${{ github.event_name != 'pull_request' }}
- tags: ${{ steps.meta.outputs.tags }}
+ platforms: ${{ matrix.platform }}
labels: ${{ steps.meta.outputs.labels }}
- cache-from: type=gha
- cache-to: type=gha,mode=max
+ cache-from: type=gha,scope=${{ env.PLATFORM_PAIR }}
+ cache-to: type=gha,mode=max,scope=${{ env.PLATFORM_PAIR }}
+ outputs: type=image,name=${{ env.IMAGE }},push-by-digest=true,name-canonical=true,push=${{ github.event_name != 'pull_request' }}
+
+ - name: Export digest
+ if: github.event_name != 'pull_request'
+ run: |
+ mkdir -p "${{ runner.temp }}/digests"
+ digest="${{ steps.build.outputs.digest }}"
+ touch "${{ runner.temp }}/digests/${digest#sha256:}"
+
+ - name: Upload digest
+ if: github.event_name != 'pull_request'
+ uses: actions/upload-artifact@v4
+ with:
+ name: digests-${{ env.PLATFORM_PAIR }}
+ path: ${{ runner.temp }}/digests/*
+ if-no-files-found: error
+ retention-days: 1
+
+ merge:
+ name: Merge manifest and push
+ if: github.event_name != 'pull_request'
+ runs-on: ubuntu-latest
+ needs: [build]
+ steps:
+ - name: Download digests
+ uses: actions/download-artifact@v4
+ with:
+ path: ${{ runner.temp }}/digests
+ pattern: digests-*
+ merge-multiple: true
+
+ - uses: docker/setup-buildx-action@v3
+
+ - name: Log in to GHCR
+ uses: docker/login-action@v3
+ with:
+ registry: ghcr.io
+ username: ${{ github.actor }}
+ password: ${{ secrets.GITHUB_TOKEN }}
+
+ - name: Docker metadata
+ id: meta
+ uses: docker/metadata-action@v5
+ with:
+ images: ${{ env.IMAGE }}
+ tags: |
+ type=ref,event=branch
+ type=ref,event=tag
+ type=sha,prefix=sha-
+ type=raw,value=latest,enable={{is_default_branch}}
+
+ - name: Create manifest list and push
+ working-directory: ${{ runner.temp }}/digests
+ run: |
+ docker buildx imagetools create \
+ $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
+ $(printf "${IMAGE}@sha256:%s " *)
+
+ - name: Inspect image
+ run: docker buildx imagetools inspect "${IMAGE}:${{ steps.meta.outputs.version }}"