Skip to content

Commit

Permalink
Add caddy-eventsexec custom build (closes #19)
Browse files Browse the repository at this point in the history
  • Loading branch information
serfriz committed May 15, 2024
1 parent 8c256b2 commit 9697311
Show file tree
Hide file tree
Showing 5 changed files with 157 additions and 1 deletion.
105 changes: 105 additions & 0 deletions .github/workflows/build.caddy-eventsexec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# Workflow to build and push a Docker image to Docker Hub, GitHub and Quay Container Registries
name: Build caddy-eventsexec

# Controls when the action will run
on:
workflow_dispatch: # allows to run the workflow manually from the Actions tab
push:
branches: main
paths:
- caddy-eventsexec/Dockerfile

# Environment variables available to all jobs and steps in this workflow
env:
DOCKER_BUILDKIT: 1
DOCKER_NAME: caddy-eventsexec
DOCKER_DESCRIPTION: "Caddy Docker custom build with Events Exec module"

# 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@v5
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 }}
1 change: 1 addition & 0 deletions .github/workflows/update-tag-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ env:
caddy-duckdns-crowdsec
caddy-duckdns-ddns
caddy-duckdns-ddns-crowdsec
caddy-eventsexec
caddy-netcup
caddy-netcup-ddns
caddy-ratelimit-dockerproxy-sablier
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ If you are looking for a specific custom build not available yet in this reposit
- [**caddy-duckdns-crowdsec**](https://github.com/serfriz/caddy-custom-builds/tree/main/caddy-duckdns-crowdsec): includes DuckDNS DNS and CrowdSec Bouncer modules.
- [**caddy-duckdns-ddns**](https://github.com/serfriz/caddy-custom-builds/tree/main/caddy-duckdns-ddns): includes DuckDNS Dynamic DNS module.
- [**caddy-duckdns-ddns-crowdsec**](https://github.com/serfriz/caddy-custom-builds/tree/main/caddy-duckdns-ddns-crowdsec): includes DuckDNS Dynamic DNS and CrowdSec Bouncer modules.
- [**caddy-eventsexec**](https://github.com/serfriz/caddy-custom-builds/tree/main/caddy-eventsexec): includes Events Exec 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-ratelimit-dockerproxy-sablier**](https://github.com/serfriz/caddy-custom-builds/tree/main/caddy-ratelimit-dockerproxy-sablier): includes Rate Limit, Docker Proxy and Sablier modules.
Expand All @@ -43,7 +44,8 @@ If you are looking for a specific custom build not available yet in this reposit
- [**Caddy Security**](https://github.com/serfriz/caddy-custom-builds?tab=readme-ov-file#caddy-security): to add different authentication methods including MFA/2FA support | [greenpau/caddy-security](https://github.com/greenpau/caddy-security)
- [**Docker Proxy**](https://github.com/serfriz/caddy-custom-builds?tab=readme-ov-file#docker-proxy): enables Caddy to be used for Docker containers via labels | [lucaslorentz/caddy-docker-proxy](https://github.com/lucaslorentz/caddy-docker-proxy)
- [**Sablier**](https://github.com/serfriz/caddy-custom-builds?tab=readme-ov-file#sablier): to start your containers on demand and shut them down automatically | [acouvreur/sablier](https://github.com/acouvreur/sablier)
- [**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)
- [**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)
- [**Events Exec**](https://github.com/serfriz/caddy-custom-builds?tab=readme-ov-file#events-exec): implements an event handler that allows to execute commands on the system | [mholt/caddy-events-exec](https://github.com/mholt/caddy-events-exec)

## Usage

Expand Down Expand Up @@ -307,6 +309,10 @@ Allows Caddy to filter traffic based on the client's IP address location. This m

Information and examples about the usage of this module can be found on the on the [Caddy website's plugin page](https://caddyserver.com/docs/modules/http.matchers.maxmind_geolocation) and the [porech/caddy-maxmind-geolocation](https://github.com/porech/caddy-maxmind-geolocation) repository.

## Events Exec

It can be used to execute commands on the system based on specific events, such as when a certificate is renewed. This is configured in the `Caddyfile` using the standard [events](https://caddyserver.com/docs/modules/events) directive along with the [events.handlers.exec](https://caddyserver.com/docs/modules/events.handlers.exec) module. Additional information and examples can be found in the [mholt/caddy-events-exec](https://github.com/mholt/caddy-events-exec) repository. Please be mindful of any security implications of the commands you run and how you configure this module.

## 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).
Expand Down
9 changes: 9 additions & 0 deletions caddy-eventsexec/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# syntax=docker/dockerfile:1
FROM caddy:2.7.6-builder AS builder

RUN xcaddy build \
--with github.com/mholt/caddy-events-exec

FROM caddy:2.7.6

COPY --from=builder /usr/bin/caddy /usr/bin/caddy
35 changes: 35 additions & 0 deletions caddy-eventsexec/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Caddy Docker build with Events Exec module

[![Docker Hub](https://img.shields.io/badge/Docker%20Hub%20-%20serfriz%2Fcaddy--eventsexec%20-%20%230db7ed?style=flat&logo=docker)](https://hub.docker.com/r/serfriz/caddy-eventsexec)
[![GitHub](https://img.shields.io/badge/GitHub%20-%20serfriz%2Fcaddy--eventsexec%20-%20%23333?style=flat&logo=github)](https://ghcr.io/serfriz/caddy-eventsexec)
[![Quay](https://img.shields.io/badge/Quay%20-%20serfriz%2Fcaddy--eventsexec%20-%20%23CC0000?style=flat&logo=redhat)](https://quay.io/serfriz/caddy-eventsexec)

[![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-eventsexec.yml?label=Build)](https://github.com/serfriz/caddy-custom-builds/actions/workflows/build.caddy-eventsexec.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 module:
- [**Events Exec**](https://github.com/serfriz/caddy-custom-builds?tab=readme-ov-file#events-exec): implements an event handler that allows to execute commands on the system | [mholt/caddy-events-exec](https://github.com/mholt/caddy-events-exec)

## 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-eventsexec) `docker pull serfriz/caddy-eventsexec:latest`
- [**GitHub Packages**](https://ghcr.io/serfriz/caddy-eventsexec) `docker pull ghcr.io/serfriz/caddy-eventsexec:latest`
- [**Quay**](https://quay.io/serfriz/caddy-eventsexec) `docker pull quay.io/serfriz/caddy-eventsexec:latest`

### Tags

The following tags are available for the `serfriz/caddy-eventsexec` image:

- `latest`
- `<version>` (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.

0 comments on commit 9697311

Please sign in to comment.