Skip to content

astrolox/docker-hugo-caddy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hugo and Caddy in Docker

This is a really simple set of files for building a static site with Hugo and bundling it in to a container with Caddy.

There are other approaches to using Caddy and Hugo, such as the official example in the Caddy docs. However I prefer to have my websites as self contained docker images for various administrative reasons.

How to use

Place your hugo site in the src folder. If you haven't created it then see the Hugo quick start guide or just run hugo new site src. You could use the provided hugo docker image to perform this step, but I'll leave working out how to do that as an exercise for the reader.

Once you have your Hugo site in src, simply build these three docker containers.

docker build -t hugo -f Dockerfile-hugo .
docker build -t caddy -f Dockerfile-caddy .
docker build -t mywebsite .

You will likely want to customise the Caddyfile to enable Letsnecrypt SSL. Do this by simply editing the provided config/Caddyfile file and then rebuilding your website container with docker build -t mywebsite .

Finally run your web server:

docker run --name mywebsite -d --restart=always -p 2015:2015 mywebsite

If you have enabled Letsencrypt SSL then you will want to persist the /root/ folder and expose the standard web ports instead. For example:

export LOCALPATH=/root/mywebsite-container-root/
docker run --name mywebsite -d --restart=always -v ${LOCALPATH}:/root/ -p 80:80 -p 443:443 mywebsite

About

Hugo and Caddy in Docker

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages