From 7b3b7ddc1a2ce28d197c71d95d362904bad2ec75 Mon Sep 17 00:00:00 2001 From: Cromefire_ Date: Sun, 22 Oct 2023 17:40:21 +0200 Subject: [PATCH] Use alpine for architectures that distroless doesn't support --- .github/workflows/docker-publish.yml | 11 ++++++--- alpine.Dockerfile | 36 ++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 alpine.Dockerfile diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index d03cbb4..66f7787 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -19,7 +19,6 @@ env: # github.repository as / IMAGE_NAME: ${{ github.repository }} - jobs: build: strategy: @@ -28,18 +27,23 @@ jobs: platform: - docker: linux/amd64 go: amd64 + dockerfile: Dockerfile - docker: linux/arm/v6 go: arm qemu: arm + dockerfile: alpine.Dockerfile - docker: linux/arm/v7 go: arm qemu: arm + dockerfile: Dockerfile - docker: linux/arm64 go: arm64 qemu: arm64 + dockerfile: Dockerfile - docker: linux/riscv64 go: riscv64 qemu: riscv64 + dockerfile: alpine.Dockerfile runs-on: ubuntu-latest permissions: contents: read @@ -62,9 +66,9 @@ jobs: # https://github.com/sigstore/cosign-installer - name: Install cosign if: github.event_name != 'pull_request' - uses: sigstore/cosign-installer@v3.1.1 + uses: sigstore/cosign-installer@v3.1.2 with: - cosign-release: 'v2.1.1' + cosign-release: 'v2.2.0' # Set up BuildKit Docker container builder to be able to build # multi-platform images and export cache @@ -103,6 +107,7 @@ jobs: uses: docker/build-push-action@v5.0.0 with: context: . + file: ${{ matrix.platform.dockerfile }} build-args: GOARCH=${{ matrix.platform.go }} platforms: ${{ matrix.platform.docker }} push: ${{ github.event_name != 'pull_request' }} diff --git a/alpine.Dockerfile b/alpine.Dockerfile new file mode 100644 index 0000000..9437575 --- /dev/null +++ b/alpine.Dockerfile @@ -0,0 +1,36 @@ +FROM golang:1.21-alpine as server_build + +WORKDIR /appbuild + +ARG GOARCH + +# Add build deps +RUN apk add --update gcc g++ git + +COPY go.mod go.sum /appbuild/ + +COPY ./ /appbuild + +RUN CGO_ENABLED=0 GOOS=linux go build -o fritzbox-cloudflare-dyndns + +# Build deployable server +FROM alpine:3 + +ENV FRITZBOX_ENDPOINT_URL=${FRITZBOX_ENDPOINT_URL:-http://fritz.box:49000} \ + FRITZBOX_ENDPOINT_TIMEOUT=${FRITZBOX_ENDPOINT_TIMEOUT:-30s} \ + DYNDNS_SERVER_BIND=${DYNDNS_SERVER_BIND:-:8080} \ + DYNDNS_SERVER_USERNAME=${DYNDNS_SERVER_USERNAME} \ + DYNDNS_SERVER_PASSWORD=${DYNDNS_SERVER_PASSWORD} \ + CLOUDFLARE_API_EMAIL="" \ + CLOUDFLARE_API_KEY="" \ + CLOUDFLARE_ZONES_IPV4="" \ + CLOUDFLARE_ZONES_IPV6="" \ + CLOUDFLARE_LOCAL_ADDRESS_IPV6="" + +WORKDIR /app + +COPY --from=server_build /appbuild/fritzbox-cloudflare-dyndns /app/fritzbox-cloudflare-dyndns + +EXPOSE 8080 + +CMD ["./fritzbox-cloudflare-dyndns"]