• Stars
    star
    768
  • Rank 59,159 (Top 2 %)
  • Language
    Shell
  • License
    MIT License
  • Created over 9 years ago
  • Updated almost 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Docker container for Caddy

caddy

A Docker image for Caddy. This image includes git, cors, realip, expires, cache and cloudflare plugins.

Plugins can be configured via the plugins build arg.

Check abiosoft/caddy:builder for generating cross-platform Caddy binaries.

License

This image is built from source code. As such, it is subject to the project's Apache 2.0 license, but it neither contains nor is subject to the EULA for Caddy's official binary distributions.

Let's Encrypt Subscriber Agreement

Caddy may prompt to agree to Let's Encrypt Subscriber Agreement. This is configurable with ACME_AGREE environment variable. Set it to true to agree. ACME_AGREE=true.

Telemetry Stats

Starting from v0.11.0, Telemetry stats are submitted to Caddy by default. To use Caddy without telemetry, use the :no-stats or :<version>-no-stats tags. e.g. :0.11.0-no-stats, :0.11.0-php-no-stats.

Getting Started

$ docker run -d -p 2015:2015 abiosoft/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 \
    abiosoft/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 \
    abiosoft/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!

PHP

:[<version>-]php variant of this image bundles PHP-FPM alongside essential php extensions and composer. e.g. :php, :0.10.14-php

$ docker run -d -p 2015:2015 abiosoft/caddy:php

Point your browser to http://127.0.0.1:2015 and you will see a php info page.

Local php source

Replace /path/to/php/src with your php sources directory.

$ docker run -d -v /path/to/php/src:/srv -p 2015:2015 abiosoft/caddy:php

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

Note

Your Caddyfile must include the line on startup php-fpm7. For Caddy to be PID 1 in the container, php-fpm7 could not be started.

Using git sources

Caddy can serve sites from git repository using git plugin.

Create Caddyfile

Replace github.com/abiosoft/webtest with your repository.

$ printf "0.0.0.0\nroot src\ngit github.com/abiosoft/webtest" > Caddyfile
Run the image
$ docker run -d -v $(pwd)/Caddyfile:/etc/Caddyfile -p 2015:2015 abiosoft/caddy

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

Custom plugins

You can build a docker image with custom plugins by specifying plugins build arg as shown in the example below.

docker build --build-arg \
    plugins=git,linode \
    github.com/abiosoft/caddy-docker.git

Usage

Default Caddyfile

The image contains a default Caddyfile.

0.0.0.0
browse
fastcgi / 127.0.0.1:9000 php # php variant only
on startup php-fpm7 # php variant only

The last 2 lines are only present in the php variant.

Paths in container

Caddyfile: /etc/Caddyfile

Sites root: /srv

Using local Caddyfile and sites root

Replace /path/to/Caddyfile and /path/to/sites/root accordingly.

$ docker run -d \
    -v /path/to/sites/root:/srv \
    -v path/to/Caddyfile:/etc/Caddyfile \
    -p 2015:2015 \
    abiosoft/caddy

Let's Encrypt Auto SSL

Note that this does not work on local environments.

Use a valid domain and add email to your Caddyfile to avoid prompt at runtime. Replace mydomain.com with your domain and [email protected] with your email.

mydomain.com
tls [email protected]
Run the image

You can change the the ports if ports 80 and 443 are not available on host. e.g. 81:80, 444:443

$ docker run -d \
    -v $(pwd)/Caddyfile:/etc/Caddyfile \
    -p 80:80 -p 443:443 \
    abiosoft/caddy

More Repositories

1

colima

Container runtimes on macOS (and Linux) with minimal setup
Go
18,415
star
2

ishell

Library for creating interactive cli applications.
Go
1,671
star
3

caddy-git

git middleware for Caddy
Go
205
star
4

dockward

Port forwarding tool for Docker containers
Go
137
star
5

caddy-json-schema

JSON schema generator for Caddy v2
Go
130
star
6

caddy-exec

Caddy v2 module for running one-off commands
Go
102
star
7

DevReload

Auto reload for ASP.NET core development
C#
61
star
8

autoplank

automatically move Plank to the active monitor
Go
51
star
9

semaphore

Wrapping sync.Mutex for familiar semaphore api
Go
44
star
10

runcmd

Wrapper for cli apps. Write less commands.
Go
43
star
11

caddyplug

Experimental Caddy plugin manager using Go plugins
Go
40
star
12

river

River is a simple and lightweight REST server
Go
37
star
13

gocalc

Simple Go Calculator
Go
34
star
14

dotfiles

dotfiles. zsh, neovim, tmux, i3 e.t.c.
Vim Script
33
star
15

caddy-yaml

Alternative Caddy YAML config adapter with extra features
Go
27
star
16

crostini-docker

Docker for Crostini with fixed binariest that work
Shell
25
star
17

caddy-json-parse

Caddy v2 module for parsing json request
Go
18
star
18

parent

A minimal process wrapper
Go
15
star
19

caddy-named-routes

named routes support for Caddy v2
Go
14
star
20

lineprefix

io.Writer wrapper with line prefix and color customizations.
Go
13
star
21

launchar

minimal GTK application launcher
Vala
11
star
22

hello-elementary

quick start elementary OS application
Vala
10
star
23

caddy-hmac

Caddy v2 hmac signature validation middleware
Go
8
star
24

cmdplay

Prototype shell session recorder and player
Go
5
star
25

bgrun

Run processes in background
Python
5
star
26

hello-caddy

Sample external middleware for Caddy
Go
4
star
27

colima-core

Dependencies for Colima
Shell
4
star
28

caddyserver.com

Source of the Caddy website
HTML
4
star
29

forloopui2017

Code used for forloop UI 2017 talk
Go
3
star
30

webtest

Basically web repo to test servers
HTML
3
star
31

atom-go-imports

Auto import Go packages via the goimports tool
CoffeeScript
3
star
32

errs

convenience wrapper for chaining multiple error returning functions.
Go
3
star
33

injekt

Pluggable service injector
Go
3
star
34

hcl2json

HCL to JSON converter
Go
3
star
35

servefile

File Server for any directory or file
Go
2
star
36

buildsrv

The Caddy build server
Go
2
star
37

gistdl

Download github gists as files
Python
2
star
38

ghrelease

A tool to download latest release archive for a GitHub project using GitHub API.
Go
2
star
39

node-graceful

Gracefully shutdown your node app. Graceful interrupts SIGTERM and SIGINT signals.
JavaScript
2
star
40

codementorhannah

Mentorship codes
Go
1
star
41

lexicon

CSC 332 Assignment
JavaScript
1
star
42

gopages-sample

Sample blog using gopages and mgo
1
star
43

structures

CSC 341 assignment
Go
1
star
44

stack

Simple Stack
Go
1
star
45

goutils

A set of utilities for Go
Go
1
star