Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
47 lines (40 loc) · 1.72 KB
/
Copy pathDockerfile
File metadata and controls
47 lines (40 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# syntax=docker/dockerfile:1.7
# Build stage for the frontend
# 前端产物与目标架构无关,固定跑在构建机原生平台,
# 避免在 arm64 目标下经由 QEMU 模拟重复构建一遍
FROM --platform=$BUILDPLATFORM node:20 AS frontend-build
WORKDIR /app
# pnpm-workspace.yaml 定义 ignoredBuiltDependencies,必须与 lockfile 一起拷贝,
# 否则 pnpm 会因未批准的构建脚本而中断安装
COPY webui/package.json webui/pnpm-lock.yaml webui/pnpm-workspace.yaml ./
RUN npm install -g pnpm@10
RUN --mount=type=cache,target=/root/.local/share/pnpm/store pnpm install --frozen-lockfile
COPY webui/ .
RUN pnpm run build
# Build stage for the backend
# 同样跑在原生平台:Go 可直接交叉编译出目标架构的二进制,
# 无需在 QEMU 模拟环境中执行
FROM --platform=$BUILDPLATFORM golang:1.26.11 AS backend-build
ARG VERSION=dev
ARG TARGETOS
ARG TARGETARCH
WORKDIR /app
COPY go.mod go.sum ./
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
GOPROXY='https://goproxy.io|direct' go mod download
COPY . .
# Copy the built frontend from frontend build stage
COPY --from=frontend-build /app/dist ./webui/dist
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -trimpath -ldflags="-s -w -X github.com/atopos31/llmio/consts.Version=${VERSION}" -o llmio .
# Final stage
# 固定 alpine 小版本:保证基础层可复现,zlib 等系统包随 3.24 稳定分支更新
FROM alpine:3.24
WORKDIR /app
# Copy the binary from backend build stage
COPY --from=backend-build /app/llmio .
EXPOSE 7070
# Command to run the application
CMD ["./llmio"]