I currently run caddy on the host to protect my docker containers. I’m familiar with building with plugins and copying it on the host level. However, I would like to move this to a container that I could have watchtower auto update. I’m not finding much information on how to add the arguments in a docker compose file for this. Would anyone be able to point me in the right direction?
I’m not 100% sure what you’re asking, so I’m going to assume you want:
- an automated docker image build process which would also include your plugins every time there’s a new version of the upstream Caddy docker image available
- an automated update of your running container every time there’s a new version of your docker image available
If you like you can take a look at my repo and adjust the following to your needs:
- Dockerfile in my repo is used to build my own Caddy image with the plugins I need, and then
- my automated Docker GitHub Action workflow docker-publish.yml makes sure that my new image is automatically built on a regular basis every time there’s a new upstream Caddy docker image available. Once it’s built, it gets pushed to my Docker Hub and GitHub Container Registry repositories.
Caddy in my environment is then installed (pulled) from one of those two repos. So when watchtower starts monitoring for the updates, it talks to my Docker Hub or GitHub Container Registry repo, depending on which one I used to install my Caddy container, to see if there’s a newer version.
The workflow I’ve described above is fully a free tier for everything. But in case you have a paid Docker Hub Pro account, you can do the entire workflow just within the Docker Hub.
After reading it again, I think you might be asking about this?
services: caddy: image: caddy:<version> restart: unless-stopped ports: - "80:80" - "443:443" - "443:443/udp" volumes: - $PWD/Caddyfile:/etc/caddy/Caddyfile - $PWD/site:/srv - caddy_data:/data - caddy_config:/config command: add-package MODULE volumes: caddy_data: external: true caddy_config:
I was trying to do something like this. However, I may give your command: option a try.
version: "3" services: caddy: build: context: . dockerfile: Dockerfile args: --with github.com/caddy-dns/cloudflare \ --with github.com/kirsch33/realip \ --with github.com/greenpau/caddy-security \ --with github.com/hslatman/caddy-crowdsec-bouncer image: caddy/caddy:builder-alpine container_name: caddy ports: - 80:80 - 443:443 volumes: - /docker/caddy/config:/config
See https://hub.docker.com/_/caddy, there’s instructions for writing a Dockerfile to make a custom build of Caddy.
caddy. It’s not the same.