Skip to content

Commit 9daf928

Browse files
committed
fix: docker images build
1 parent d0c26bd commit 9daf928

File tree

6 files changed

+32
-12
lines changed

6 files changed

+32
-12
lines changed

.github/workflows/ci-agent.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252

5353
- name: Skip (no project structure)
5454
if: steps.modroot.outputs.found != 'true'
55-
run: 'echo "Skipped: no go.mod + cmd/runner-manager in this repo."'
55+
run: 'echo "Skipped: no go.mod + cmd/runner-agent in this repo."'
5656

5757
build:
5858
name: Build
@@ -88,4 +88,4 @@ jobs:
8888

8989
- name: Skip (no project structure)
9090
if: steps.modroot.outputs.found != 'true'
91-
run: 'echo "Skipped: no go.mod + cmd/runner-manager in this repo."'
91+
run: 'echo "Skipped: no go.mod + cmd/runner-agent in this repo."'

.github/workflows/publish-image-agent.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,15 @@ jobs:
7777
id: runner-tags
7878
run: |
7979
echo "tags<<EOF" >> "$GITHUB_OUTPUT"
80-
echo "${{ steps.meta.outputs.tags }}" | sed '/./s/\(:.*\)$/\1-runner/' >> "$GITHUB_OUTPUT"
80+
# metadata-action 可能输出逗号/换行分隔;每行 image:tag 转为 image:tag-runner
81+
echo "${{ steps.meta.outputs.tags }}" | tr ',' '\n' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//' | while IFS= read -r line; do
82+
[ -z "$line" ] && continue
83+
if [[ "$line" == *:* ]]; then
84+
echo "$line" | sed 's/\(:.*\)$/\1-runner/'
85+
else
86+
echo "${line}:latest-runner"
87+
fi
88+
done >> "$GITHUB_OUTPUT"
8189
echo "EOF" >> "$GITHUB_OUTPUT"
8290
8391
- name: Build and push Runner image (container mode)

.github/workflows/publish-image-manager.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,7 @@ jobs:
7373
type=semver,pattern={{major}},enable=${{ startsWith(github.ref, 'refs/tags/v') }}
7474
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v') }}
7575
76-
- name: Prepare config for image
77-
run: cp config.yaml.example config.yaml
78-
working-directory: ${{ env.DOCKER_CONTEXT }}
76+
# Dockerfile 内已 COPY config.yaml.example 并 sed 为 config.yaml,无需在 workflow 中准备
7977

8078
- name: Build and push Manager image
8179
uses: docker/build-push-action@v6

.github/workflows/release-agent.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ jobs:
5252

5353
- name: Compute canonical image name (lowercase for GHCR)
5454
id: vars
55+
shell: bash
5556
run: |
57+
set -eu
5658
CANONICAL="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}"
5759
echo "canonical=${CANONICAL,,}" >> "$GITHUB_OUTPUT"
5860
@@ -72,7 +74,15 @@ jobs:
7274
id: runner-tags
7375
run: |
7476
echo "tags<<EOF" >> "$GITHUB_OUTPUT"
75-
echo "${{ steps.meta.outputs.tags }}" | sed '/./s/\(:.*\)$/\1-runner/' >> "$GITHUB_OUTPUT"
77+
# metadata-action 可能输出逗号/换行分隔;每行 image:tag 转为 image:tag-runner
78+
echo "${{ steps.meta.outputs.tags }}" | tr ',' '\n' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//' | while IFS= read -r line; do
79+
[ -z "$line" ] && continue
80+
if [[ "$line" == *:* ]]; then
81+
echo "$line" | sed 's/\(:.*\)$/\1-runner/'
82+
else
83+
echo "${line}:latest-runner"
84+
fi
85+
done >> "$GITHUB_OUTPUT"
7686
echo "EOF" >> "$GITHUB_OUTPUT"
7787
7888
- name: Build and push Runner Docker image (container mode)

.github/workflows/release-manager.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,7 @@ jobs:
6868
cd dist
6969
sha256sum * > checksums.txt
7070
71-
- name: Prepare config for image
72-
run: cp config.yaml.example config.yaml
73-
working-directory: ${{ env.DOCKER_CONTEXT }}
71+
# Dockerfile 内已 COPY config.yaml.example 并 sed 为 config.yaml,无需在 workflow 中准备
7472

7573
- name: Set up Docker Buildx
7674
uses: docker/setup-buildx-action@v3
@@ -86,7 +84,9 @@ jobs:
8684

8785
- name: Compute canonical image name (lowercase for GHCR)
8886
id: vars
87+
shell: bash
8988
run: |
89+
set -eu
9090
CANONICAL="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}"
9191
echo "canonical=${CANONICAL,,}" >> "$GITHUB_OUTPUT"
9292

Dockerfile.runner

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
# Runner 容器镜像(容器模式用):仅包含 Agent + Runner 运行依赖,Runner 目录由 Manager 挂载到 /runner
2-
FROM golang:1.26.0-bookworm AS builder
2+
# 使用 BUILDPLATFORM 在宿主机(amd64)上构建,TARGETOS/TARGETARCH 交叉编译,避免 QEMU 下 go build 失败
3+
ARG BUILDPLATFORM=linux/amd64
4+
FROM --platform=$BUILDPLATFORM golang:1.26-bookworm AS builder
35
WORKDIR /app
46
COPY go.mod go.sum ./
57
RUN go mod download
68
COPY . .
7-
RUN CGO_ENABLED=0 go build -o runner-agent ./cmd/runner-agent
9+
ARG TARGETOS=linux
10+
ARG TARGETARCH=amd64
11+
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -o runner-agent ./cmd/runner-agent
812

913
FROM ubuntu:24.04
1014
LABEL org.opencontainers.image.title="Runner Fleet Runner" \

0 commit comments

Comments
 (0)