Skip to content

Commit 2a4bc4f

Browse files
committed
feat: fix Dockerfile for hanzo-engine, add compose.yml and GHCR CI
- Dockerfile now builds hanzo-engine binary (not just mistralrs-server) - Build context includes both engine/ and ml/ for workspace deps - CPU-only build (--no-default-features) for linux/amd64 cloud - compose.yml for local dev with HF cache mount - build-image.yml workflow on self-hosted hanzo-deploy-linux-amd64 - Image: ghcr.io/hanzoai/engine
1 parent 5e3e846 commit 2a4bc4f

3 files changed

Lines changed: 103 additions & 9 deletions

File tree

.github/workflows/build-image.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Build Docker Image
2+
3+
on:
4+
push:
5+
branches: [main]
6+
tags: ["v*"]
7+
workflow_dispatch:
8+
9+
concurrency:
10+
group: docker-${{ github.ref }}
11+
cancel-in-progress: false
12+
13+
permissions:
14+
contents: read
15+
packages: write
16+
17+
jobs:
18+
build:
19+
name: Build and Push
20+
runs-on: hanzo-deploy-linux-amd64
21+
22+
steps:
23+
- uses: actions/checkout@v4
24+
with:
25+
path: engine
26+
27+
- uses: actions/checkout@v4
28+
with:
29+
repository: hanzoai/ml
30+
path: ml
31+
32+
- name: Set up Docker Buildx
33+
uses: docker/setup-buildx-action@v3
34+
35+
- name: Log in to GHCR
36+
uses: docker/login-action@v3
37+
with:
38+
registry: ghcr.io
39+
username: ${{ github.actor }}
40+
password: ${{ secrets.GITHUB_TOKEN }}
41+
42+
- name: Extract metadata
43+
id: meta
44+
uses: docker/metadata-action@v5
45+
with:
46+
images: ghcr.io/hanzoai/engine
47+
tags: |
48+
type=ref,event=branch
49+
type=semver,pattern={{version}}
50+
type=semver,pattern={{major}}.{{minor}}
51+
type=sha,prefix=
52+
type=raw,value=latest,enable={{is_default_branch}}
53+
54+
- name: Build and push
55+
uses: docker/build-push-action@v6
56+
with:
57+
context: .
58+
file: engine/Dockerfile
59+
push: true
60+
platforms: linux/amd64
61+
tags: ${{ steps.meta.outputs.tags }}
62+
labels: ${{ steps.meta.outputs.labels }}
63+
cache-from: type=gha
64+
cache-to: type=gha,mode=max

Dockerfile

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,18 @@
33
# Stage 1: Build environment
44
FROM rust:latest AS builder
55

6-
# Set working directory and copy files
7-
WORKDIR /engine
8-
COPY . .
6+
# Set working directory
7+
WORKDIR /build
8+
9+
# Copy ml dependency (must be present at ../ml relative to engine)
10+
COPY ml/ /build/ml/
11+
12+
# Copy engine source
13+
COPY engine/ /build/engine/
914

1015
# Build the project in release mode, excluding the specified workspace
11-
RUN cargo build --release --workspace --exclude mistralrs-pyo3
16+
WORKDIR /build/engine
17+
RUN cargo build --release --workspace --exclude mistralrs-pyo3 --no-default-features
1218

1319

1420
# Stage 2: Minimal runtime environment
@@ -29,11 +35,19 @@ RUN <<HEREDOC
2935
HEREDOC
3036

3137
# Copy the built binaries from the builder stage
32-
COPY --chmod=755 --from=builder /engine/target/release/mistralrs-bench /usr/local/bin/
33-
COPY --chmod=755 --from=builder /engine/target/release/mistralrs-server /usr/local/bin/
34-
COPY --chmod=755 --from=builder /engine/target/release/mistralrs-web-chat /usr/local/bin/
38+
COPY --chmod=755 --from=builder /build/engine/target/release/hanzo-engine /usr/local/bin/
39+
COPY --chmod=755 --from=builder /build/engine/target/release/mistralrs-server /usr/local/bin/
40+
COPY --chmod=755 --from=builder /build/engine/target/release/mistralrs-bench /usr/local/bin/
3541
# Copy chat templates for users running models which may not include them
36-
COPY --from=builder /engine/chat_templates /chat_templates
42+
COPY --from=builder /build/engine/chat_templates /chat_templates
3743

3844
ENV HUGGINGFACE_HUB_CACHE=/data \
39-
PORT=80
45+
PORT=36900 \
46+
RUST_LOG=info
47+
48+
EXPOSE 36900
49+
50+
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
51+
CMD curl -f http://localhost:36900/health || exit 1
52+
53+
ENTRYPOINT ["hanzo-engine"]

compose.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
services:
2+
engine:
3+
image: ghcr.io/hanzoai/engine:latest
4+
ports:
5+
- "36900:36900"
6+
volumes:
7+
- ~/.cache/huggingface:/data
8+
environment:
9+
- RUST_LOG=info
10+
- PORT=36900
11+
healthcheck:
12+
test: ["CMD", "curl", "-f", "http://localhost:36900/health"]
13+
interval: 30s
14+
timeout: 10s
15+
start_period: 60s
16+
retries: 3

0 commit comments

Comments
 (0)