interplane.Get Omega
Read in your language

MojoLlama

Archived Mojo/MAX quantizer and serving research repository (read-only history)

Brought by drakestapleton

branch main Branches Tags History

MojoLlama / src / mojollama / .github / workflows / docker.yml

196 lines · 6343 bytes Raw Blame History
1# ============================================================
2# MojoLlama Docker Build & Publish Workflow
3# ============================================================
4# Builds multi-arch Docker images for MojoLlama and pushes
5# to GitHub Container Registry (ghcr.io).
6#
7# Triggered on:
8# - Push to main, dev branches (tagged releases)
9# - PRs to main (build only, no push)
10# - Manual workflow_dispatch
11#
12# Image tags:
13# ghcr.io/a730/mojollama:latest — latest main branch
14# ghcr.io/a730/mojollama:dev — latest dev branch
15# ghcr.io/a730/mojollama:X.Y.Z — tagged release
16# ghcr.io/a730/mojollama:nightly — nightly build
17# ============================================================
18
19name: Docker Build & Publish
20
21on:
22 push:
23 branches:
24 - main
25 - dev
26 tags:
27 - 'v*'
28 pull_request:
29 branches:
30 - main
31 schedule:
32 - cron: '0 6 * * *' # daily 06:00 UTC — nightly build
33 workflow_dispatch:
34 inputs:
35 tags:
36 description: 'Additional docker tags (comma-separated)'
37 required: false
38 default: ''
39 platforms:
40 description: 'Platforms (linux/amd64,linux/arm64)'
41 required: false
42 default: 'linux/amd64'
43
44env:
45 REGISTRY: ghcr.io
46 IMAGE_NAME: ${{ github.repository_owner }}/mojollama
47 LLAMA_CPP_VERSION: b4729
48
49jobs:
50 # ── Build and push Docker image ──
51 docker:
52 runs-on: ubuntu-24.04
53 permissions:
54 contents: read
55 packages: write
56 attestations: write
57 id-token: write
58
59 steps:
60 - name: Checkout repository
61 uses: actions/checkout@v4
62 with:
63 fetch-depth: 1
64 lfs: false
65
66 - name: Set up QEMU (for multi-arch)
67 uses: docker/setup-qemu-action@v3
68
69 - name: Set up Docker Buildx
70 uses: docker/setup-buildx-action@v3
71 with:
72 buildkitd-flags: --debug
73 driver-opts: |
74 image=moby/buildkit:master
75 network=host
76
77 - name: Log into GitHub Container Registry
78 if: github.event_name != 'pull_request'
79 uses: docker/login-action@v3
80 with:
81 registry: ${{ env.REGISTRY }}
82 username: ${{ github.actor }}
83 password: ${{ secrets.GITHUB_TOKEN }}
84
85 - name: Generate Docker metadata (tags + labels)
86 id: meta
87 uses: docker/metadata-action@v5
88 with:
89 images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
90 tags: |
91 type=ref,event=branch
92 type=ref,event=pr
93 type=semver,pattern={{version}}
94 type=semver,pattern={{major}}.{{minor}}
95 type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
96 type=raw,value=dev,enable=${{ github.ref == format('refs/heads/{0}', 'dev') }}
97 type=raw,value=nightly,enable=${{ github.event_name == 'schedule' }}
98 type=sha,format=short
99 flavor: |
100 latest=false
101
102 - name: Append manual tags
103 if: github.event_name == 'workflow_dispatch' && inputs.tags != ''
104 id: meta-manual
105 run: |
106 IFS=',' read -ra TAGS <<< "${{ inputs.tags }}"
107 for tag in "${TAGS[@]}"; do
108 echo "tags=${{ steps.meta.outputs.tags }},ghcr.io/${{ env.IMAGE_NAME }}:${tag}" >> $GITHUB_ENV
109 done
110
111 - name: Build and export to Docker
112 uses: docker/build-push-action@v6
113 id: build
114 with:
115 context: .
116 file: ./Dockerfile
117 platforms: ${{ inputs.platforms || 'linux/amd64' }}
118 push: ${{ github.event_name != 'pull_request' }}
119 tags: ${{ steps.meta.outputs.tags }}
120 labels: ${{ steps.meta.outputs.labels }}
121 cache-from: type=gha
122 cache-to: type=gha,mode=max
123 build-args: |
124 LLAMA_CPP_VERSION=${{ env.LLAMA_CPP_VERSION }}
125 provenance: true
126 sbom: true
127
128 - name: Generate artifact attestation
129 if: github.event_name != 'pull_request'
130 uses: actions/attest-build-provenance@v1
131 with:
132 subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
133 subject-digest: ${{ steps.build.outputs.digest }}
134 push-to-registry: true
135
136 - name: Image digest
137 run: echo "Pushed ${{ steps.meta.outputs.tags }} @ ${{ steps.build.outputs.digest }}"
138
139 # ── Smoke test the built image ──
140 smoke-test:
141 runs-on: ubuntu-24.04
142 needs: [docker]
143 if: github.event_name != 'pull_request'
144
145 steps:
146 - name: Log into GHCR
147 uses: docker/login-action@v3
148 with:
149 registry: ${{ env.REGISTRY }}
150 username: ${{ github.actor }}
151 password: ${{ secrets.GITHUB_TOKEN }}
152
153 - name: Pull built image
154 run: |
155 docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:dev || \
156 docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
157
158 - name: Test --help
159 run: |
160 IMG="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}"
161 TAG="dev"
162 docker run --rm "$IMG:$TAG" --help 2>&1 | head -20
163
164 - name: Test --version
165 run: |
166 IMG="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}"
167 TAG="dev"
168 docker run --rm "$IMG:$TAG" --version
169
170 - name: Test info
171 run: |
172 IMG="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}"
173 TAG="dev"
174 docker run --rm "$IMG:$TAG" info
175
176 - name: Test TinyLlama inference
177 run: |
178 IMG="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}"
179 TAG="dev"
180 # Download a tiny model
181 docker run --rm -v /tmp/models:/models "$IMG:$TAG" \
182 bench -m /models/tl-Q4_0.gguf -n 10 -t 4 2>&1 | tail -10
183
184 - name: Test llama.cpp fallback
185 run: |
186 which llama-cli && echo "llama-cli available" || echo "llama-cli missing"
187 which llama-server && echo "llama-server available" || echo "llama-server missing"
188
189 - name: Test server starts
190 run: |
191 IMG="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}"
192 TAG="dev"
193 docker run --rm -d --name ml-test -p 8080:8080 "$IMG:$TAG" serve --port 8080
194 sleep 3
195 curl -s http://localhost:8080/health 2>&1 | head -5 || echo "Server health check skipped"
196 docker stop ml-test 2>/dev/null || true