feat 使用ko进行构建
Some checks failed
Build image / build (push) Failing after 1m23s

This commit is contained in:
timerzz 2024-05-23 11:19:43 +08:00
parent 1cfe78538d
commit 0edc7d8678
2 changed files with 24 additions and 10 deletions

View File

@ -4,13 +4,11 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: https://gitea.timerzz.com/timerzz/checkout@v4
- name: build
run: docker build -t ${{ vars.DOCKER_REGISTRY }}/${{ vars.IMAGE_NAME }}:1.3 -f Dockerfile .
- name: tag
run: docker tag ${{ vars.DOCKER_REGISTRY }}/${{ vars.IMAGE_NAME }}:1.3 ${{ vars.DOCKER_REGISTRY }}/${{ vars.IMAGE_NAME }}:latest
- name: push 1.3
run: docker push ${{ vars.DOCKER_REGISTRY }}/${{ vars.IMAGE_NAME }}:1.3
- name: push latest
run: docker push ${{ vars.DOCKER_REGISTRY }}/${{ vars.IMAGE_NAME }}:latest
- uses: https://gitea.timerzz.com/timerzz/setup-go@v4
with:
go-version: '1.22.x'
- uses: https://gitea.timerzz.com/timerzz/checkout@v4
- uses: https://gitea.timerzz.com/timerzz/setup-ko@v0.6
env:
KO_DOCKER_REPO: registry.timerzz.com:20443/kedaya/watcher
- run: ko build --bare ./main

16
.ko.yaml Normal file
View File

@ -0,0 +1,16 @@
defaultPlatforms:
- linux/amd64
defaultBaseImage: alpine:latest
builds:
- id: watcher
dir: . # default is .
main: ./main
env:
- CGO_ENABLED=0
- GOPROXY=https://goproxy.cn,direct
- GOPRIVATE=gitea.timerzz.com
- GONOSUMDB=gitea.timerzz.com
- GONOPROXY=gitea.timerzz.com
ldflags:
- -s -w
- -extldflags "-static"