feat(llm-api): add CI/CD, Dockerfile, compose, Traefik routing

- infra/docker/llm-api.Dockerfile — multi-stage Rust build with cargo-chef
- infra/compose/llm-api.yml — service with model volume mount & healthcheck
- infra/traefik/dynamic/apps.yaml — router for ai.asepharyana.my.id
- CI: build-push workflow detects llm-api changes, builds image
- CD: deploy workflow includes llm-api.yml in compose stack
This commit is contained in:
asepharyana
2026-07-25 12:06:39 +07:00
parent 781e091508
commit b4a55cfa7b
5 changed files with 99 additions and 4 deletions
+28
View File
@@ -0,0 +1,28 @@
services:
llm-api:
container_name: llm-api
image: ghcr.io/asepharyana/asepharyana-hub/llm-api:latest
restart: always
networks:
app-shared-net:
aliases:
- llm-api
volumes:
- /root/models/gguf:/root/models/gguf:ro
environment:
- MODEL_PATH=/root/models/gguf/MiniCPM-V-4.6-Q4_K_M.gguf
healthcheck:
test: ['CMD-SHELL', 'curl -so /dev/null --connect-timeout 5 http://localhost:8080/health || test $? -eq 22']
interval: 30s
timeout: 10s
retries: 5
start_period: 30s
labels:
prometheus.io/scrape: "true"
prometheus.io/port: "8080"
prometheus.io/path: "/metrics"
networks:
app-shared-net:
name: app-shared-net
external: true
+45
View File
@@ -0,0 +1,45 @@
# ── Build stage: cargo-chef ──
FROM lukemathwalker/cargo-chef:latest-rust-1.89.0 AS chef
RUN apt-get update && apt-get install -y --no-install-recommends \
libclang-dev cmake \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
FROM chef AS planner
COPY apps/llm-api .
RUN cargo chef prepare --recipe-path recipe.json
FROM chef AS builder
COPY --from=planner /app/recipe.json recipe.json
RUN --mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=/app/target \
cargo chef cook --release --recipe-path recipe.json
COPY apps/llm-api .
RUN --mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=/app/target \
cargo build --release && \
cp target/release/llm-api /app/llm-api
# ── Runtime image ──
FROM debian:bookworm-slim AS runtime
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
curl \
libssl3 \
libgomp1 \
&& rm -rf /var/lib/apt/lists/*
RUN groupadd -g 1001 appgroup && \
useradd -u 1001 -g appgroup -s /bin/sh appuser
WORKDIR /app
COPY --from=builder /app/llm-api /app/llm-api
# Model will be mounted at runtime
RUN mkdir -p /root/models/gguf && chown -R appuser:appgroup /root/models/gguf
USER appuser
EXPOSE 8080
CMD ["./llm-api"]
+12
View File
@@ -42,6 +42,14 @@ http:
rule: Host(`auth.asepharyana.my.id`) || Host(`auth.asepharyana.web.id`)
service: rust-auth-service
tls: {}
llm-api:
entryPoints:
- websecure
middlewares:
- common-chain@file
rule: Host(`ai.asepharyana.my.id`) || Host(`ai.asepharyana.web.id`)
service: llm-api-service
tls: {}
scraper:
entryPoints:
- websecure
@@ -76,6 +84,10 @@ http:
loadBalancer:
servers:
- url: http://rust-auth:3000
llm-api-service:
loadBalancer:
servers:
- url: http://llm-api:8080
scraper-service:
loadBalancer:
servers: