From f11cca18609ef270fbfdc4fb20f568c357eae4e6 Mon Sep 17 00:00:00 2001 From: Codex Test Date: Wed, 29 Jul 2026 17:25:58 +0800 Subject: [PATCH] ci: build and run a test Docker image --- .dockerignore | 3 +++ .gitea/workflows/test.yaml | 15 ++++++++++++++- Dockerfile | 15 +++++++++++++++ hello.c | 7 +++++++ 4 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 hello.c diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..b8178b2 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +.git +.gitea +codex-ssh-test.md diff --git a/.gitea/workflows/test.yaml b/.gitea/workflows/test.yaml index 613ee78..b529b9d 100644 --- a/.gitea/workflows/test.yaml +++ b/.gitea/workflows/test.yaml @@ -8,6 +8,9 @@ jobs: image: ubuntu:latest steps: + - name: Checkout Repository + uses: actions/checkout@v4 + - name: Say Hello run: echo "Testing connection..." @@ -31,4 +34,14 @@ jobs: echo "正在嘗試連線 Docker API..." echo "DOCKER_HOST = $DOCKER_HOST" docker ps - echo "成功!可以看到上面的容器列表了!" \ No newline at end of file + echo "成功!可以看到上面的容器列表了!" + + - name: Build Test Image + run: | + docker build --progress=plain -t test-runner:ci . + + - name: Run Test Image + run: | + output="$(docker run --rm test-runner:ci)" + echo "$output" + test "$output" = "Gitea Runner Docker build succeeded." diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a1ac6e1 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +FROM alpine:3.22.5 AS builder + +RUN apk add --no-cache build-base + +WORKDIR /src +COPY hello.c . + +RUN mkdir -p /out \ + && cc -O2 -Wall -Wextra -Werror -static hello.c -o /out/hello + +FROM scratch + +COPY --from=builder /out/hello /hello + +ENTRYPOINT ["/hello"] diff --git a/hello.c b/hello.c new file mode 100644 index 0000000..9b71c94 --- /dev/null +++ b/hello.c @@ -0,0 +1,7 @@ +#include + +int main(void) +{ + puts("Gitea Runner Docker build succeeded."); + return 0; +}