From 5aec831956616c1a55c7ca3bf2e0c5f838a7931c Mon Sep 17 00:00:00 2001 From: guochao Date: Wed, 19 Feb 2025 17:49:35 +0800 Subject: [PATCH] build on gitea action --- .gitea/workflows/container-build.yaml | 43 +++++++++++++++++++++++++++ Dockerfile | 3 +- compose.yaml | 8 +++-- 3 files changed, 50 insertions(+), 4 deletions(-) create mode 100644 .gitea/workflows/container-build.yaml diff --git a/.gitea/workflows/container-build.yaml b/.gitea/workflows/container-build.yaml new file mode 100644 index 0000000..170b299 --- /dev/null +++ b/.gitea/workflows/container-build.yaml @@ -0,0 +1,43 @@ +name: build container + +run-name: build container on ${{ gitea.actor }} +on: [push] + +env: + GOPROXY: ${{ vars.GOPROXY }} + +jobs: + test: + runs-on: bookworm + steps: + - name: Setup apt mirror + run: sed -i "s,deb.debian.org,${{ vars.DEBIAN_MIRROR }},g" ${{ vars.DEBIAN_APT_SOURCES }} + if: ${{ vars.DEBIAN_MIRROR && vars.DEBIAN_APT_SOURCES }} + - name: Setup Debian environment + run: apt update && apt install -y nodejs + - name: Setup Golang + uses: actions/setup-go + - name: Check out repository code + uses: actions/checkout@v4 + - name: Run tests + run: go test -v ./... + + build-container: + runs-on: bookworm + needs: + - test + steps: + - name: Setup apt mirror + run: sed -i "s,deb.debian.org,${{ vars.DEBIAN_MIRROR }},g" ${{ vars.DEBIAN_APT_SOURCES }} + if: ${{ vars.DEBIAN_MIRROR && vars.DEBIAN_APT_SOURCES }} + - name: Setup debian environment + run: apt update && apt install -y podman podman-compose nodejs + - name: Check out repository code + uses: actions/checkout@v4 + - name: Build container + run: REGISTRY=${{ github.server_url}}; REGISTRY=${REGISTRY##https://}; REGISTRY=${REGISTRY##http://}; podman build -t $REGISTRY/${{ github.repository }} . + - name: Login to Container Registry + run: echo "${{ secrets.ACTION_PACKAGE_WRITE_TOKEN }}" | podman login ${{ github.server_url }} -u ${{ github.repository_owner }} --password-stdin + - name: Push Container Image + run: REGISTRY=${{ github.server_url}}; REGISTRY=${REGISTRY##https://}; REGISTRY=${REGISTRY##http://}; podman push --log-level=trace $REGISTRY/${{ github.repository }} + diff --git a/Dockerfile b/Dockerfile index 322d0d1..aca1ae8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,8 @@ FROM docker.io/library/golang:1.23-alpine +ARG GOPROXY WORKDIR /src COPY go.mod go.sum ./ -RUN go mod download +RUN env GOPROXY=${GOPROXY:-direct} go mod download ADD . /src RUN go build -o /cache-proxy ./cmd/proxy diff --git a/compose.yaml b/compose.yaml index 2457ae3..a7e06e2 100644 --- a/compose.yaml +++ b/compose.yaml @@ -1,7 +1,9 @@ services: cache-proxy: - image: 100.64.0.2/guochao/cache-proxy:20250207 - build: . + image: 100.64.0.2:3000/guochao/cache-proxy + build: + args: + GOPROXY: ${GOPROXY:-direct} pull_policy: always restart: always @@ -16,4 +18,4 @@ services: - HTTP_PROXY=http://100.64.0.23:7890 - ALL_PROXY=http://100.64.0.23:7890 - SENTRY_DSN=http://3b7336602c77427d96318074cd86ee04@100.64.0.2:8000/2 - - LOG_LEVEL=debug \ No newline at end of file + - LOG_LEVEL=debug