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

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"