From 703a4f0b9e3c565cfa655c47c884e4d4e3003f80 Mon Sep 17 00:00:00 2001 From: Sergio Fraile Izquierdo <37709447+serfriz@users.noreply.github.com> Date: Tue, 12 Nov 2024 16:45:54 -0800 Subject: [PATCH] Add caddy-netcup-ddns-geoip custom build (closes #37) --- .../build.caddy-netcup-ddns-geoip.yml | 107 ++++++++++++++++++ .github/workflows/update-tag-release.yml | 1 + README.md | 1 + caddy-netcup-ddns-geoip/Dockerfile | 12 ++ caddy-netcup-ddns-geoip/README.md | 37 ++++++ 5 files changed, 158 insertions(+) create mode 100644 .github/workflows/build.caddy-netcup-ddns-geoip.yml create mode 100644 caddy-netcup-ddns-geoip/Dockerfile create mode 100644 caddy-netcup-ddns-geoip/README.md diff --git a/.github/workflows/build.caddy-netcup-ddns-geoip.yml b/.github/workflows/build.caddy-netcup-ddns-geoip.yml new file mode 100644 index 0000000..ba26d2a --- /dev/null +++ b/.github/workflows/build.caddy-netcup-ddns-geoip.yml @@ -0,0 +1,107 @@ +# Workflow to build and push a Docker image to Docker Hub, GitHub and Quay Container Registries +name: Build caddy-netcup-ddns-geoip + +# Controls when the action will run +on: + workflow_dispatch: # allows to run the workflow manually from the Actions tab + schedule: + - cron: '0 0 1 * *' # runs at 00:00 on the first day of every month + push: + branches: main + paths: + - caddy-netcup-ddns-geoip/Dockerfile + +# Environment variables available to all jobs and steps in this workflow +env: + DOCKER_BUILDKIT: 1 + DOCKER_NAME: caddy-netcup-ddns-geoip + DOCKER_DESCRIPTION: "Caddy Docker custom build with Netcup Dynamic DNS and GeoIP Filter modules" + +# Jobs to run once the workflow is triggered +jobs: + # Job to get image and repository details + metadata: + name: Get image and repository details + runs-on: ubuntu-latest + + outputs: + version: ${{ steps.version.outputs.version }} + labels: ${{ steps.metadata.outputs.labels }} + tags: ${{ steps.metadata.outputs.tags }} + platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x,linux/arm/v7,linux/arm/v6 + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + ref: main + + - name: Parse Caddy version + id: version + run: echo "version=$(grep -Eo 'caddy:[0-9]+\.[0-9]+\.[0-9]+$' $DOCKER_NAME/Dockerfile | cut -d ':' -f2)" | tee -a $GITHUB_OUTPUT + + - name: Generate image metadata with Caddy version + uses: docker/metadata-action@v5 + id: metadata + with: + images: | + docker.io/${{ github.actor }}/${{ env.DOCKER_NAME }} + ghcr.io/${{ github.actor }}/${{ env.DOCKER_NAME }} + quay.io/${{ github.actor }}/${{ env.DOCKER_NAME }} + tags: | + type=semver,pattern={{version}},value=v${{ steps.version.outputs.version }} + type=semver,pattern={{major}}.{{minor}},value=v${{ steps.version.outputs.version }} + type=semver,pattern={{major}},value=v${{ steps.version.outputs.version }} + labels: | + org.opencontainers.image.title=${{ env.DOCKER_NAME }} + org.opencontainers.image.description=${{ env.DOCKER_DESCRIPTION }} + + # Job to build and publish Docker image + build: + name: Build and publish Docker image + runs-on: ubuntu-latest + needs: metadata + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + ref: main + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ github.actor }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Login to GitHub Container Repository + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ github.token }} + + - name: Login to Quay Container Registry + uses: docker/login-action@v3 + with: + registry: quay.io + username: ${{ github.actor }} + password: ${{ secrets.QUAY_TOKEN }} + + - name: Build and publish container image + uses: docker/build-push-action@v6 + id: build + with: + context: . + file: ./${{ env.DOCKER_NAME }}/Dockerfile + push: true + provenance: false + tags: ${{ needs.metadata.outputs.tags }} + labels: ${{ needs.metadata.outputs.labels }} + platforms: ${{ needs.metadata.outputs.platforms }} \ No newline at end of file diff --git a/.github/workflows/update-tag-release.yml b/.github/workflows/update-tag-release.yml index 94513f3..afd4b0d 100644 --- a/.github/workflows/update-tag-release.yml +++ b/.github/workflows/update-tag-release.yml @@ -33,6 +33,7 @@ env: caddy-gandi caddy-netcup caddy-netcup-ddns + caddy-netcup-ddns-geoip caddy-ovh-crowdsec-geoip caddy-porkbun-dockerproxy caddy-ratelimit-dockerproxy-sablier diff --git a/README.md b/README.md index a1ae532..d3306e2 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,7 @@ If you are looking for a specific custom build not available yet in this reposit - [**caddy-gandi**](https://github.com/serfriz/caddy-custom-builds/tree/main/caddy-gandi): includes Gandi DNS module. - [**caddy-netcup**](https://github.com/serfriz/caddy-custom-builds/tree/main/caddy-netcup): includes Netcup DNS module. - [**caddy-netcup-ddns**](https://github.com/serfriz/caddy-custom-builds/tree/main/caddy-netcup): includes Netcup Dynamic DNS module. +- [**caddy-netcup-ddns-geoip**](https://github.com/serfriz/caddy-custom-builds/tree/main/caddy-netcup-geoip): includes Netcup Dynamic DNS and GeoIP Filter modules. - [**caddy-ovh-crowdsec-geoip**](https://github.com/serfriz/caddy-custom-builds/tree/main/caddy-ovh-crowdsec-geoip): includes OVH DNS, CrowdSec Bouncer and GeoIP Filter modules. - [**caddy-porkbun-dockerproxy**](https://github.com/serfriz/caddy-custom-builds/tree/main/caddy-porkbun-dockerproxy): includes Porkbun DNS and Docker Proxy modules. - [**caddy-ratelimit-dockerproxy-sablier**](https://github.com/serfriz/caddy-custom-builds/tree/main/caddy-ratelimit-dockerproxy-sablier): includes Rate Limit, Docker Proxy and Sablier modules. diff --git a/caddy-netcup-ddns-geoip/Dockerfile b/caddy-netcup-ddns-geoip/Dockerfile new file mode 100644 index 0000000..4463df8 --- /dev/null +++ b/caddy-netcup-ddns-geoip/Dockerfile @@ -0,0 +1,12 @@ +# syntax=docker/dockerfile:1 +FROM caddy:2.8.4-builder AS builder + +RUN xcaddy build \ + --with github.com/caddy-dns/netcup \ + --with github.com/mholt/caddy-dynamicdns \ + --replace github.com/libdns/netcup=github.com/Monviech/libdns-netcup@libdns-patch \ + --with github.com/porech/caddy-maxmind-geolocation + +FROM caddy:2.8.4 + +COPY --from=builder /usr/bin/caddy /usr/bin/caddy \ No newline at end of file diff --git a/caddy-netcup-ddns-geoip/README.md b/caddy-netcup-ddns-geoip/README.md new file mode 100644 index 0000000..9206466 --- /dev/null +++ b/caddy-netcup-ddns-geoip/README.md @@ -0,0 +1,37 @@ +# Caddy Docker build with Netcup Dynamic DNS and GeoIP Filter modules + +[![Docker Hub](https://img.shields.io/badge/Docker%20Hub%20-%20serfriz%2Fcaddy--netcup--ddns--geoip%20-%20%230db7ed?style=flat&logo=docker)](https://hub.docker.com/r/serfriz/caddy-netcup-ddns-geoip) +[![GitHub](https://img.shields.io/badge/GitHub%20-%20serfriz%2Fcaddy--netcup--ddns--geoip%20-%20%23333?style=flat&logo=github)](https://ghcr.io/serfriz/caddy-netcup-ddns-geoip) +[![Quay](https://img.shields.io/badge/Quay%20-%20serfriz%2Fcaddy--netcup--ddns--geoip%20-%20%23CC0000?style=flat&logo=redhat)](https://quay.io/serfriz/caddy-netcup-ddns-geoip) + +[![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/serfriz/caddy-custom-builds?label=Release)](https://github.com/serfriz/caddy-custom-builds/releases) +[![GitHub build status](https://img.shields.io/github/actions/workflow/status/serfriz/caddy-custom-builds/build.caddy-netcup-ddns-geoip.yml?label=Build)](https://github.com/serfriz/caddy-custom-builds/actions/workflows/build.caddy-netcup-ddns-geoip.yml) + +This image is updated automatically by GitHub Actions when a new version of [Caddy](https://github.com/caddyserver/caddy) is released using the official [Caddy Docker](https://hub.docker.com/_/caddy) image and the following modules: +- [**Netcup DNS**](https://github.com/serfriz/caddy-custom-builds?tab=readme-ov-file#dns-modules): for Netcup DNS-01 ACME validation support | [caddy-dns/netcup](https://github.com/caddy-dns/netcup-ddns) +- [**Dynamic DNS**](https://github.com/serfriz/caddy-custom-builds?tab=readme-ov-file#dynamic-dns): updates the DNS records with the public IP address of your instance | [mholt/caddy-dynamicdns](https://caddyserver.com/docs/modules/dynamic_dns) +- [**GeoIP Filter:**](https://github.com/serfriz/caddy-custom-builds?tab=readme-ov-file#geoip-filter) to allow or block traffic from specific regions based on [Maxmind GeoLite2 database](https://dev.maxmind.com/geoip/geolite2-free-geolocation-data) | [porech/caddy-maxmind-geolocation](https://github.com/porech/caddy-maxmind-geolocation) + +## Usage + +Since this image built off the official Caddy Docker image, the same [volumes](https://docs.docker.com/storage/volumes/) and/or [bind mounts](https://docs.docker.com/storage/bind-mounts/), ports mapping, etc. can be used with this container. Additional [environment variables](https://caddyserver.com/docs/caddyfile/concepts#environment-variables) may be needed for the added modules. Please, refer to the repository's [README](https://github.com/serfriz/caddy-custom-builds?tab=readme-ov-file#container-creation) file for further usage instructions. + +Docker builds for all Caddy supported platforms available at the following container registries: +- [**Docker Hub**](https://hub.docker.com/r/serfriz/caddy-netcup-ddns-geoip) `docker pull serfriz/caddy-netcup-ddns-geoip:latest` +- [**GitHub Packages**](https://ghcr.io/serfriz/caddy-netcup-ddns-geoip) `docker pull ghcr.io/serfriz/caddy-netcup-ddns-geoip:latest` +- [**Quay**](https://quay.io/serfriz/caddy-netcup-ddns-geoip) `docker pull quay.io/serfriz/caddy-netcup-ddns-geoip:latest` + +### Tags + +The following tags are available for the `serfriz/caddy-netcup-ddns-geoip` image: + +- `latest` +- `` (eg: `2.7.4`, including: `2.7`, `2`, etc.) + +## Contributing + +Feel free to contribute, request additional Caddy images with your preferred modules, and make things better by opening an [Issue](https://github.com/serfriz/caddy-custom-builds/issues) or [Pull Request](https://github.com/serfriz/caddy-custom-builds/pulls). + +## License + +Software under [GPL-3.0](https://github.com/serfriz/caddy-custom-builds/blob/main/LICENSE) ensures users' freedom to use, modify, and distribute it while keeping the source code accessible. It promotes transparency, collaboration, and knowledge sharing. Users agree to comply with the GPL-3.0 license terms and provide the same freedom to others. \ No newline at end of file