Sign inSign up

suxin1110/caddy

By suxin1110

Updated over 7 years ago

Image
0

331

suxin1110/caddy repository overview

adriel/caddy https://www.github.com/adriel/caddy-docker

Dockerfile

FROM alpine:latest MAINTAINER Adriel Kloppenburg

LABEL caddy_version="1.0.0" architecture="amd64"

ARG plugins=http.git,tls.dns.cloudflare

RUN apk add --no-cache git tar curl

RUN curl --silent --show-error --fail --location
--header "Accept: application/tar+gzip, application/x-gzip, application/octet-stream" -o -
"https://caddyserver.com/download/linux/amd64?plugins=${plugins}&license=personal&telemetry=on"
| tar --no-same-owner -C /usr/bin/ -xz caddy
&& chmod 0755 /usr/bin/caddy
&& /usr/bin/caddy -version

EXPOSE 80 443 2015 VOLUME /root/.caddy /srv WORKDIR /srv

COPY Caddyfile /etc/Caddyfile COPY index.html /srv/index.html

ENTRYPOINT ["/usr/bin/caddy"] CMD ["--conf", "/etc/Caddyfile", "--log", "stdout", "--agree"]


Caddy A Docker image for Caddy. This image includes the git and cloudflare plugins. Plugins can also be configured via the plugins build arg.

Credit A big thank you to abiosoft whos this image is forked off.

Telemetry Telemetry has been enabled by default on this image! If you do not want this please use another docker image.

Getting Started $ docker run -d -p 2015:2015 suxin1110/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
suxin1110/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
suxin1110/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 :[-]php variant of this image bundles PHP-FPM alongside essential php extensions and composer. e.g. :php, :0.10-php

$ docker run -d -p 2015:2015 suxin1110/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 suxin1110/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 Cloudflare Caddy can talk to Cloudflare via their API to automaticly confugure/update your Let's Encrypt certificates using the Cloudflare plugin (which has been included in this image).

Follow the instrutions here to set it up.

Using git sources Caddy can serve sites from git repository using git plugin.

Create Caddyfile Replace github.com/adriel/webtest with your repository.

$ printf "0.0.0.0\nroot src\ngit github.com/adriel/webtest" > Caddyfile Run the image $ docker run -d -v $(pwd)/Caddyfile:/etc/Caddyfile -p 2015:2015 suxin1110/caddy Point your browser to http://127.0.0.1:2015.

Usage Default Caddyfile The image contains a default Caddyfile.

0.0.0.0 browse fastcgi / 127.0.0.1:9000 php # php variant only 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
suxin1110/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
suxin1110/caddy

Tag summary

Content type

Image

Digest

Size

20.6 MB

Last updated

over 7 years ago

docker pull suxin1110/caddy