From f66aa3efa6e773f4c47d4291a94ba3b92bd81ee6 Mon Sep 17 00:00:00 2001 From: Fijxu Date: Thu, 20 Feb 2025 02:12:42 -0300 Subject: [PATCH] ci: update go build path on Dockerfile and update CI file --- .forgejo/workflows/ci.yml | 32 +++++++++++++------------------- Dockerfile | 3 ++- 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/.forgejo/workflows/ci.yml b/.forgejo/workflows/ci.yml index 9ac1292..93130e5 100644 --- a/.forgejo/workflows/ci.yml +++ b/.forgejo/workflows/ci.yml @@ -2,9 +2,8 @@ name: "CI" on: workflow_dispatch: - inputs: {} push: - branches: ["*"] + branches: ["main", "master"] jobs: build: @@ -14,21 +13,6 @@ jobs: - name: Checkout repo uses: actions/checkout@v4 - # - name: Set up QEMU for ARM64 builds - # uses: docker/setup-qemu-action@v3 - # with: - # platforms: arm64 - - - name: Cache Go packages - uses: actions/cache@v3 - with: - path: | - ~/.cache/go-build - ~/go/pkg/mod - key: ${{ runner.os }}-golang-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-golang- - - name: Setup Docker BuildX system uses: docker/setup-buildx-action@v3 @@ -48,11 +32,21 @@ jobs: type=sha,format=short,prefix={{date 'YYYY.MM.DD'}}-,enable=${{ github.ref == format('refs/heads/{0}', 'main') }} type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }} - - name: Build and push Docker AMD64/ARM64 + - name: Go Build Cache for Docker + uses: actions/cache@v4 + with: + path: go-build-cache + key: ${{ runner.os }}-go-build-cache-${{ hashFiles('**/go.sum') }} + + - name: Inject go-build-cache + uses: https://github.com/reproducible-containers/buildkit-cache-dance@v3 + with: + cache-source: go-build-cache + + - name: Build and push Docker uses: docker/build-push-action@v6 with: context: . platforms: linux/amd64 - # platforms: linux/amd64,linux/arm64/v8 push: true tags: ${{ steps.meta.outputs.tags }} diff --git a/Dockerfile b/Dockerfile index 92c5e22..1c8a158 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,7 @@ FROM golang:alpine3.21 AS build WORKDIR /app/ +RUN go env -w GOMODCACHE=/root/.cache/go-build RUN apk add --no-cache build-base libwebp-dev git @@ -8,7 +9,7 @@ COPY .git .git COPY . . RUN --mount=type=cache,target=/root/.cache/go-build \ - go build -ldflags "-s -w -X 'main.version=$(date '+%Y-%m-%d')-$(git rev-list --abbrev-commit -1 HEAD)'" + go build -ldflags "-s -w -X 'main.version=$(date '+%Y-%m-%d')-$(git rev-list --abbrev-commit -1 HEAD)'" ./cmd/http3-ytproxy FROM alpine:3.21