ci: update go build path on Dockerfile and update CI file
All checks were successful
CI / build (push) Successful in 1m38s

This commit is contained in:
Fijxu 2025-02-20 02:12:42 -03:00
parent 340ee021bb
commit f66aa3efa6
Signed by: Fijxu
GPG key ID: 32C1DDF333EDA6A4
2 changed files with 15 additions and 20 deletions

View file

@ -2,9 +2,8 @@ name: "CI"
on: on:
workflow_dispatch: workflow_dispatch:
inputs: {}
push: push:
branches: ["*"] branches: ["main", "master"]
jobs: jobs:
build: build:
@ -14,21 +13,6 @@ jobs:
- name: Checkout repo - name: Checkout repo
uses: actions/checkout@v4 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 - name: Setup Docker BuildX system
uses: docker/setup-buildx-action@v3 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=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') }} 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 uses: docker/build-push-action@v6
with: with:
context: . context: .
platforms: linux/amd64 platforms: linux/amd64
# platforms: linux/amd64,linux/arm64/v8
push: true push: true
tags: ${{ steps.meta.outputs.tags }} tags: ${{ steps.meta.outputs.tags }}

View file

@ -1,6 +1,7 @@
FROM golang:alpine3.21 AS build FROM golang:alpine3.21 AS build
WORKDIR /app/ WORKDIR /app/
RUN go env -w GOMODCACHE=/root/.cache/go-build
RUN apk add --no-cache build-base libwebp-dev git RUN apk add --no-cache build-base libwebp-dev git
@ -8,7 +9,7 @@ COPY .git .git
COPY . . COPY . .
RUN --mount=type=cache,target=/root/.cache/go-build \ 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 FROM alpine:3.21