From a6ee35499ffaf6ee1931e6616169629e29e3bf7f Mon Sep 17 00:00:00 2001 From: Haitao Pan Date: Thu, 4 Dec 2025 22:57:12 +0800 Subject: [PATCH] ci(docker): simplify Go builder pipeline and trim runtime images --- account/Dockerfile | 4 +-- deploy/base-images/go-runtime.Dockerfile | 38 +++++++++++------------- rag-server/Dockerfile | 6 ++-- 3 files changed, 20 insertions(+), 28 deletions(-) diff --git a/account/Dockerfile b/account/Dockerfile index e6795d1..675be4a 100644 --- a/account/Dockerfile +++ b/account/Dockerfile @@ -17,9 +17,7 @@ RUN make build && make -pv /out/ && cp account /out/ # ------------------------------ # Stage 2 — Runtime # ------------------------------ -ARG GO_RUNTIME_IMAGE=ghcr.io/cloud-neutral-toolkit/go-runtime:latest -ARG INSTALL_GO=false # runtime 不安装 Go SDK -FROM ${GO_RUNTIME_IMAGE} AS runtime +FROM ubuntu:24.04 AS runtime RUN apt-get update \ && apt-get install -y --no-install-recommends \ diff --git a/deploy/base-images/go-runtime.Dockerfile b/deploy/base-images/go-runtime.Dockerfile index a58f4e4..3e2aa50 100644 --- a/deploy/base-images/go-runtime.Dockerfile +++ b/deploy/base-images/go-runtime.Dockerfile @@ -16,7 +16,6 @@ LABEL maintainer="XControl" \ ENV CGO_ENABLED=0 \ TZ=Etc/UTC -ARG INSTALL_GO="false" ARG GO_VERSION="1.24.5" RUN set -eux; \ @@ -29,30 +28,27 @@ RUN set -eux; \ rm -rf /var/lib/apt/lists/* # ======================================================= -# 可选:安装 Go SDK(用于 make build 的情况) +# 安装 Go SDK(默认开启) # ======================================================= -RUN if [ "$INSTALL_GO" = "true" ]; then \ - set -eux; \ - arch="$(uname -m)"; \ - case "$arch" in \ - x86_64|amd64) goarch="amd64" ;; \ - aarch64|arm64) goarch="arm64" ;; \ - *) echo "Unsupported arch: $arch"; exit 1 ;; \ - esac; \ - tarball="go${GO_VERSION}.linux-${goarch}.tar.gz"; \ - url="https://go.dev/dl/${tarball}"; \ - echo "Installing Go ${GO_VERSION} for ${goarch}"; \ - wget -q "$url" -O "/tmp/go.tgz"; \ - rm -rf /usr/local/go; \ - tar -C /usr/local -xzf "/tmp/go.tgz"; \ - rm /tmp/go.tgz; \ - echo 'export PATH=$PATH:/usr/local/go/bin' > /etc/profile.d/go.sh; \ - fi +RUN set -eux; \ + arch="$(uname -m)"; \ + case "$arch" in \ + x86_64|amd64) goarch="amd64" ;; \ + aarch64|arm64) goarch="arm64" ;; \ + *) echo "Unsupported arch: $arch"; exit 1 ;; \ + esac; \ + tarball="go${GO_VERSION}.linux-${goarch}.tar.gz"; \ + url="https://go.dev/dl/${tarball}"; \ + echo "=== Installing Go ${GO_VERSION} (${goarch}) ==="; \ + wget -q "$url" -O "/tmp/go.tgz"; \ + rm -rf /usr/local/go; \ + tar -C /usr/local -xzf "/tmp/go.tgz"; \ + rm /tmp/go.tgz; \ + echo 'export PATH=$PATH:/usr/local/go/bin' > /etc/profile.d/go.sh; ENV PATH="${PATH}:/usr/local/go/bin" -# ---- 应用目录 ---- +# ---- 应用构建目录(builder 用) ---- WORKDIR /app -# ---- 默认 shell 入口(最终服务会覆盖 CMD) ---- CMD ["/bin/sh"] diff --git a/rag-server/Dockerfile b/rag-server/Dockerfile index 8264715..41604fe 100644 --- a/rag-server/Dockerfile +++ b/rag-server/Dockerfile @@ -2,7 +2,7 @@ # Stage 1 — Builder # ======================================================= ARG GO_RUNTIME_IMAGE=ghcr.io/cloud-neutral-toolkit/go-runtime:latest -ARG INSTALL_GO=true # 为 builder 启用 Go SDK(go-runtime.Dockerfile 会处理) + FROM ${GO_RUNTIME_IMAGE} AS builder # 在 builder 中启用 Go SDK @@ -24,9 +24,7 @@ RUN make build && mkdir -p /out && cp rag-server /out/rag-server # ======================================================= # Stage 2 — Runtime # ======================================================= -ARG GO_RUNTIME_IMAGE=ghcr.io/cloud-neutral-toolkit/go-runtime:latest -ARG INSTALL_GO=false # runtime 不安装 Go SDK -FROM ${GO_RUNTIME_IMAGE} AS runtime +FROM ubuntu:24.04 AS runtime WORKDIR /app