From a290492477a6cb9912d2ff641b09a9b70f15dfdb Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Mon, 27 May 2024 11:12:55 +0200 Subject: [PATCH] build: ko, gha --- .github/workflows/build-publish.yaml | 42 ++++++++++++++++++++++++++++ .ko.yml | 3 ++ Dockerfile | 20 ------------- 3 files changed, 45 insertions(+), 20 deletions(-) create mode 100644 .github/workflows/build-publish.yaml create mode 100644 .ko.yml delete mode 100644 Dockerfile diff --git a/.github/workflows/build-publish.yaml b/.github/workflows/build-publish.yaml new file mode 100644 index 0000000..925edaa --- /dev/null +++ b/.github/workflows/build-publish.yaml @@ -0,0 +1,42 @@ +name: Build and Publish + +on: + push: + +permissions: + packages: write + contents: write + +jobs: + build-and-push-docker-image: + name: Build Docker image and push + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup Go + uses: actions/setup-go@v4 + with: + go-version: 'stable' + + - name: Setup ko + uses: ko-build/setup-ko@v0.6 + + - name: Login to Github Packages + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build containers + run: | + descr=$(git describe) + export version="${descr#v}" + ko build --bare --sbom=none -t latest -t "$version" . + env: + KO_DOCKER_REPO: ghcr.io/syncthing/infra/roadmap-votes diff --git a/.ko.yml b/.ko.yml new file mode 100644 index 0000000..a1affb8 --- /dev/null +++ b/.ko.yml @@ -0,0 +1,3 @@ +defaultPlatforms: +- linux/arm64 +- linux/amd64 diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 89aff0f..0000000 --- a/Dockerfile +++ /dev/null @@ -1,20 +0,0 @@ -ARG GOVERSION=latest -FROM golang:$GOVERSION AS builder - -WORKDIR /src -COPY . . - -ENV CGO_ENABLED=0 -RUN rm -f roadmap-votes && go build -v - -FROM alpine - -EXPOSE 8080 -ENV LISTEN_ADDRESS=:8080 - -RUN apk add --no-cache ca-certificates tzdata - -COPY --from=builder /src/roadmap-votes /bin/roadmap-votes - -ENTRYPOINT ["/bin/roadmap-votes"] -