/docker-hugo-caddy

hugo + caddy , perfect static site.

Primary LanguageDockerfileMIT LicenseMIT

Hugo with Caddy

A Docker image for Hugo with Caddy webserver. This image includes the git plugin. Plugins can be configured via the plugins build arg.

Build Status

Getting Started

$ docker run -d -p 2015:2015 muninn/hugo-caddy

Point your browser to http://127.0.0.1:2015.

Be aware! If you don't bind mount the location certificates are saved to, you may hit Let's Encrypt rate limits rending further certificate generation or renewal disallowed (for a fixed period)! See "Saving Certificates" below!

Saving Certificates

Save certificates on host machine to prevent regeneration every time container starts. Let's Encrypt has rate limit.

$ docker run -d \
    -v $(pwd)/Caddyfile:/etc/Caddyfile \
    -v $HOME/.caddy:/root/.caddy \
    -p 80:80 -p 443:443 \
    muninn/hugo-caddy

Here, /root/.caddy is the location inside the container where caddy will save certificates.

Additionally, you can use an environment variable to define the exact location caddy should save generated certificates:

$ docker run -d \
    -e "CADDYPATH=/etc/caddycerts" \
    -v $HOME/.caddy:/etc/caddycerts \
    -p 80:80 -p 443:443 \
    muninn/hugo-caddy

Above, we utilize the CADDYPATH environment variable to define a different location inside the container for certificates to be stored. This is probably the safest option as it ensures any future docker image changes don't interfere with your ability to save certificates!

Using git sources

Caddy can serve sites from git repository using git plugin.