├── .dockerignore ├── BUILDER.md ├── Caddyfile ├── Dockerfile ├── Dockerfile-no-stats ├── LICENSE ├── README.md ├── builder ├── Dockerfile └── builder.sh ├── index.html └── php ├── Caddyfile ├── Dockerfile ├── Dockerfile-no-stats └── index.php /.dockerignore: -------------------------------------------------------------------------------- 1 | LICENSE* 2 | README* 3 | -------------------------------------------------------------------------------- /BUILDER.md: -------------------------------------------------------------------------------- 1 | # builder 2 | 3 | Docker image for building Caddy binaries. 4 | 5 | ## Usage 6 | 7 | Example 8 | 9 | ``` 10 | docker run --rm -v $(pwd):/install -e PLUGINS=git,filebrowser abiosoft/caddy:builder 11 | 12 | ``` 13 | 14 | ### Volumes 15 | 16 | - `/install` - Mount a volume to save the Caddy binary e.g. `-v $(pwd):/install` 17 | 18 | ### Environment Variables 19 | 20 | - `PLUGINS` - comma separated Caddy plugins. e.g. `-e PLUGINS=git,linode` 21 | - `VERSION` - Caddy version or repository branch. Default `1.0.3` 22 | - `ENABLE_TELEMETRY` - Enable telemetry stats. Options `true`|`false`. Default `true` 23 | - `GOOS`, `GOARCH` and `GOARM` are all supported. Default `GOOS=linux`, `GOARCH=amd64` 24 | -------------------------------------------------------------------------------- /Caddyfile: -------------------------------------------------------------------------------- 1 | 0.0.0.0 2 | 3 | browse 4 | 5 | log stdout 6 | 7 | errors stdout 8 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # Builder 3 | # 4 | FROM abiosoft/caddy:builder as builder 5 | 6 | ARG version="1.0.3" 7 | ARG plugins="git,cors,realip,expires,cache,cloudflare" 8 | ARG enable_telemetry="true" 9 | 10 | # process wrapper 11 | RUN go get -v github.com/abiosoft/parent 12 | 13 | RUN VERSION=${version} PLUGINS=${plugins} ENABLE_TELEMETRY=${enable_telemetry} /bin/sh /usr/bin/builder.sh 14 | 15 | # 16 | # Final stage 17 | # 18 | FROM alpine:3.10 19 | LABEL maintainer "Abiola Ibrahim " 20 | 21 | ARG version="1.0.3" 22 | LABEL caddy_version="$version" 23 | 24 | # Let's Encrypt Agreement 25 | ENV ACME_AGREE="false" 26 | 27 | # Telemetry Stats 28 | ENV ENABLE_TELEMETRY="$enable_telemetry" 29 | 30 | RUN apk add --no-cache \ 31 | ca-certificates \ 32 | git \ 33 | mailcap \ 34 | openssh-client \ 35 | tzdata 36 | 37 | # install caddy 38 | COPY --from=builder /install/caddy /usr/bin/caddy 39 | 40 | # validate install 41 | RUN /usr/bin/caddy -version 42 | RUN /usr/bin/caddy -plugins 43 | 44 | EXPOSE 80 443 2015 45 | VOLUME /root/.caddy /srv 46 | WORKDIR /srv 47 | 48 | COPY Caddyfile /etc/Caddyfile 49 | COPY index.html /srv/index.html 50 | 51 | # install process wrapper 52 | COPY --from=builder /go/bin/parent /bin/parent 53 | 54 | ENTRYPOINT ["/bin/parent", "caddy"] 55 | CMD ["--conf", "/etc/Caddyfile", "--log", "stdout", "--agree=$ACME_AGREE"] 56 | -------------------------------------------------------------------------------- /Dockerfile-no-stats: -------------------------------------------------------------------------------- 1 | # 2 | # Builder 3 | # 4 | FROM abiosoft/caddy:builder as builder 5 | 6 | ARG version="1.0.3" 7 | ARG plugins="git,cors,realip,expires,cache,cloudflare" 8 | 9 | # process wrapper 10 | RUN go get -v github.com/abiosoft/parent 11 | 12 | RUN VERSION=${version} PLUGINS=${plugins} ENABLE_TELEMETRY=false /bin/sh /usr/bin/builder.sh 13 | 14 | # 15 | # Final stage 16 | # 17 | FROM alpine:3.10 18 | LABEL maintainer "Abiola Ibrahim " 19 | 20 | ARG version="1.0.3" 21 | LABEL caddy_version="$version" 22 | 23 | # Let's Encrypt Agreement 24 | ENV ACME_AGREE="false" 25 | 26 | # Telemetry Stats 27 | ENV ENABLE_TELEMETRY="false" 28 | 29 | RUN apk add --no-cache \ 30 | ca-certificates \ 31 | git \ 32 | mailcap \ 33 | openssh-client \ 34 | tzdata 35 | 36 | # install caddy 37 | COPY --from=builder /install/caddy /usr/bin/caddy 38 | 39 | # validate install 40 | RUN /usr/bin/caddy -version 41 | RUN /usr/bin/caddy -plugins 42 | 43 | EXPOSE 80 443 2015 44 | VOLUME /root/.caddy /srv 45 | WORKDIR /srv 46 | 47 | COPY Caddyfile /etc/Caddyfile 48 | COPY index.html /srv/index.html 49 | 50 | # install process wrapper 51 | COPY --from=builder /go/bin/parent /bin/parent 52 | 53 | ENTRYPOINT ["/bin/parent", "caddy"] 54 | CMD ["--conf", "/etc/Caddyfile", "--log", "stdout", "--agree=$ACME_AGREE"] 55 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Abiola Ibrahim 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # caddy 2 | 3 | A [Docker](https://docker.com) image for [Caddy](https://caddyserver.com). This image includes [git](https://caddyserver.com/docs/http.git), [cors](https://caddyserver.com/docs/http.cors), [realip](https://caddyserver.com/docs/http.realip), [expires](https://caddyserver.com/docs/http.expires), [cache](https://caddyserver.com/docs/http.cache) and [cloudflare](https://caddyserver.com/docs/tls.dns.cloudflare) plugins. 4 | 5 | Plugins can be configured via the [`plugins` build arg](#custom-plugins). 6 | 7 | [![](https://images.microbadger.com/badges/image/abiosoft/caddy.svg)](https://microbadger.com/images/abiosoft/caddy "Get your own image badge on microbadger.com") 8 | [![](https://img.shields.io/badge/version-1.0.3-blue.svg)](https://github.com/caddyserver/caddy/tree/v1.0.3) 9 | 10 | Check [abiosoft/caddy:builder](https://github.com/abiosoft/caddy-docker/blob/master/BUILDER.md) for generating cross-platform Caddy binaries. 11 | 12 | ### License 13 | 14 | This image is built from [source code](https://github.com/caddyserver/caddy). As such, it is subject to the project's [Apache 2.0 license](https://github.com/caddyserver/caddy/blob/baf6db5b570e36ea2fee30d50f879255a5895370/LICENSE.txt), but it neither contains nor is subject to [the EULA for Caddy's official binary distributions](https://github.com/caddyserver/caddy/blob/545fa844bbd188c1e5bff6926e5c410e695571a0/dist/EULA.txt). 15 | 16 | ### Let's Encrypt Subscriber Agreement 17 | 18 | Caddy may prompt to agree to [Let's Encrypt Subscriber Agreement](https://letsencrypt.org/documents/2017.11.15-LE-SA-v1.2.pdf). This is configurable with `ACME_AGREE` environment variable. Set it to true to agree. `ACME_AGREE=true`. 19 | 20 | ### Telemetry Stats 21 | 22 | Starting from `v0.11.0`, [Telemetry stats](https://caddyserver.com/docs/telemetry) are submitted to Caddy by default. To use Caddy without telemetry, use the `:no-stats` or `:-no-stats` tags. e.g. `:0.11.0-no-stats`, `:0.11.0-php-no-stats`. 23 | 24 | ## Getting Started 25 | 26 | ```sh 27 | $ docker run -d -p 2015:2015 abiosoft/caddy 28 | ``` 29 | 30 | Point your browser to `http://127.0.0.1:2015`. 31 | 32 | > Be aware! If you don't bind mount the location certificates are saved to, you may hit Let's Encrypt rate [limits](https://letsencrypt.org/docs/rate-limits/) rending further certificate generation or renewal disallowed (for a fixed period)! See "Saving Certificates" below! 33 | 34 | ### Saving Certificates 35 | 36 | Save certificates on host machine to prevent regeneration every time container starts. 37 | Let's Encrypt has [rate limit](https://community.letsencrypt.org/t/rate-limits-for-lets-encrypt/6769). 38 | 39 | ```sh 40 | $ docker run -d \ 41 | -v $(pwd)/Caddyfile:/etc/Caddyfile \ 42 | -v $HOME/.caddy:/root/.caddy \ 43 | -p 80:80 -p 443:443 \ 44 | abiosoft/caddy 45 | ``` 46 | 47 | Here, `/root/.caddy` is the location _inside_ the container where caddy will save certificates. 48 | 49 | Additionally, you can use an _environment variable_ to define the exact location caddy should save generated certificates: 50 | 51 | ```sh 52 | $ docker run -d \ 53 | -e "CADDYPATH=/etc/caddycerts" \ 54 | -v $HOME/.caddy:/etc/caddycerts \ 55 | -p 80:80 -p 443:443 \ 56 | abiosoft/caddy 57 | ``` 58 | 59 | Above, we utilize the `CADDYPATH` environment variable to define a different location inside the container for 60 | 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! 61 | 62 | ### PHP 63 | 64 | `:[-]php` variant of this image bundles PHP-FPM alongside essential php extensions and [composer](https://getcomposer.org). e.g. `:php`, `:0.10.14-php` 65 | 66 | ```sh 67 | $ docker run -d -p 2015:2015 abiosoft/caddy:php 68 | ``` 69 | 70 | Point your browser to `http://127.0.0.1:2015` and you will see a php info page. 71 | 72 | ##### Local php source 73 | 74 | Replace `/path/to/php/src` with your php sources directory. 75 | 76 | ```sh 77 | $ docker run -d -v /path/to/php/src:/srv -p 2015:2015 abiosoft/caddy:php 78 | ``` 79 | 80 | Point your browser to `http://127.0.0.1:2015`. 81 | 82 | ##### Note 83 | 84 | 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. 85 | 86 | ### Using git sources 87 | 88 | Caddy can serve sites from git repository using [git](https://caddyserver.com/docs/http.git) plugin. 89 | 90 | ##### Create Caddyfile 91 | 92 | Replace `github.com/abiosoft/webtest` with your repository. 93 | 94 | ```sh 95 | $ printf "0.0.0.0\nroot src\ngit github.com/abiosoft/webtest" > Caddyfile 96 | ``` 97 | 98 | ##### Run the image 99 | 100 | ```sh 101 | $ docker run -d -v $(pwd)/Caddyfile:/etc/Caddyfile -p 2015:2015 abiosoft/caddy 102 | ``` 103 | 104 | Point your browser to `http://127.0.0.1:2015`. 105 | 106 | ## Custom plugins 107 | 108 | You can build a docker image with custom plugins by specifying `plugins` build arg as shown in the example below. 109 | 110 | ``` 111 | docker build --build-arg \ 112 | plugins=git,linode \ 113 | github.com/abiosoft/caddy-docker.git 114 | ``` 115 | 116 | ## Usage 117 | 118 | #### Default Caddyfile 119 | 120 | The image contains a default Caddyfile. 121 | 122 | ``` 123 | 0.0.0.0 124 | browse 125 | fastcgi / 127.0.0.1:9000 php # php variant only 126 | on startup php-fpm7 # php variant only 127 | ``` 128 | 129 | The last 2 lines are only present in the php variant. 130 | 131 | #### Paths in container 132 | 133 | Caddyfile: `/etc/Caddyfile` 134 | 135 | Sites root: `/srv` 136 | 137 | #### Using local Caddyfile and sites root 138 | 139 | Replace `/path/to/Caddyfile` and `/path/to/sites/root` accordingly. 140 | 141 | ```sh 142 | $ docker run -d \ 143 | -v /path/to/sites/root:/srv \ 144 | -v path/to/Caddyfile:/etc/Caddyfile \ 145 | -p 2015:2015 \ 146 | abiosoft/caddy 147 | ``` 148 | 149 | ### Let's Encrypt Auto SSL 150 | 151 | **Note** that this does not work on local environments. 152 | 153 | Use a valid domain and add email to your Caddyfile to avoid prompt at runtime. 154 | Replace `mydomain.com` with your domain and `user@host.com` with your email. 155 | 156 | ``` 157 | mydomain.com 158 | tls user@host.com 159 | ``` 160 | 161 | ##### Run the image 162 | 163 | You can change the the ports if ports 80 and 443 are not available on host. e.g. 81:80, 444:443 164 | 165 | ```sh 166 | $ docker run -d \ 167 | -v $(pwd)/Caddyfile:/etc/Caddyfile \ 168 | -p 80:80 -p 443:443 \ 169 | abiosoft/caddy 170 | ``` 171 | -------------------------------------------------------------------------------- /builder/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:1.13-alpine 2 | 3 | RUN apk add --no-cache git gcc musl-dev 4 | 5 | COPY builder.sh /usr/bin/builder.sh 6 | 7 | CMD ["/bin/sh", "/usr/bin/builder.sh"] 8 | -------------------------------------------------------------------------------- /builder/builder.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | VERSION=${VERSION:-"1.0.3"} 4 | TELEMETRY=${ENABLE_TELEMETRY:-"true"} 5 | IMPORT="github.com/caddyserver/caddy" 6 | 7 | # version <1.0.1 needs to use old import path 8 | new_import=true 9 | if [ "$(echo $VERSION | cut -c1)" -eq 0 ] 2>/dev/null || [ "$VERSION" = "1.0.0" ]; then 10 | IMPORT="github.com/mholt/caddy" && new_import=false 11 | fi 12 | 13 | # add `v` prefix for version numbers 14 | [ "$(echo $VERSION | cut -c1)" -ge 0 ] 2>/dev/null && VERSION="v$VERSION" 15 | 16 | stage() { 17 | STAGE="$1" 18 | echo 19 | echo starting stage: $STAGE 20 | } 21 | 22 | end_stage() { 23 | if [ $? -ne 0 ]; then 24 | >&2 echo error at \'$STAGE\' 25 | exit 1 26 | fi 27 | echo finished stage: $STAGE ✓ 28 | echo 29 | } 30 | 31 | use_new_import() ( 32 | cd $1 33 | find . -name '*.go' | while read -r f; do 34 | sed -i.bak 's/\/mholt\/caddy/\/caddyserver\/caddy/g' $f && rm $f.bak 35 | done 36 | ) 37 | 38 | get_package() { 39 | # go module require special dns handling 40 | if $go_mod && [ -f /dnsproviders/$1/$1.go ]; then 41 | mkdir -p /caddy/dnsproviders/$1 42 | cp -r /dnsproviders/$1/$1.go /caddy/dnsproviders/$1/$1.go 43 | echo "caddy/dnsproviders/$1" 44 | else 45 | GO111MODULE=off GOOS=linux GOARCH=amd64 caddyplug package $1 2> /dev/null 46 | fi 47 | } 48 | 49 | dns_plugins() { 50 | git clone https://github.com/caddyserver/dnsproviders /dnsproviders 51 | # temp hack for repo rename 52 | if $new_import; then use_new_import /dnsproviders; fi 53 | } 54 | 55 | plugins() { 56 | mkdir -p /plugins 57 | for plugin in $(echo $PLUGINS | tr "," " "); do \ 58 | import_package=$(get_package $plugin) 59 | $go_mod || go get -v "$import_package" ; # not needed for modules 60 | $go_mod && package="main" || package="caddyhttp" 61 | printf "package $package\nimport _ \"$import_package\"" > \ 62 | /plugins/$plugin.go ; \ 63 | done 64 | } 65 | 66 | module() { 67 | mkdir -p /caddy 68 | cd /caddy # build dir 69 | 70 | # setup module 71 | go mod init caddy 72 | go get -v $IMPORT@$VERSION 73 | 74 | # plugins 75 | cp -r /plugins/. . 76 | 77 | # temp hack for repo rename 78 | go get -v -d # download possible plugin deps 79 | if $new_import; then use_new_import /go/pkg/mod; fi 80 | 81 | # main and telemetry 82 | cat > main.go < "$run_file.disablestats.go" < 2 | 3 | 4 | Caddy 5 | 11 | 12 | 13 |

Caddy web server.

14 |

If you see this page, Caddy container works.

15 | 16 |

More instructions about this image is here.

17 |

More instructions about Caddy is here.

18 | 19 | -------------------------------------------------------------------------------- /php/Caddyfile: -------------------------------------------------------------------------------- 1 | 0.0.0.0 2 | 3 | browse 4 | 5 | fastcgi / 127.0.0.1:9000 php 6 | 7 | on startup php-fpm7 8 | 9 | log stdout 10 | 11 | errors stdout -------------------------------------------------------------------------------- /php/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # Builder 3 | # 4 | FROM abiosoft/caddy:builder as builder 5 | 6 | ARG version="1.0.3" 7 | ARG plugins="git,cors,realip,expires,cache,cloudflare" 8 | ARG enable_telemetry="true" 9 | 10 | # Process Wrapper 11 | RUN go get -v github.com/abiosoft/parent 12 | 13 | RUN VERSION=${version} PLUGINS=${plugins} ENABLE_TELEMETRY=${enable_telemetry} /bin/sh /usr/bin/builder.sh 14 | 15 | # 16 | # Final Stage 17 | # 18 | FROM alpine:3.10 19 | LABEL maintainer "Abiola Ibrahim " 20 | 21 | ARG version="1.0.3" 22 | LABEL caddy_version="$version" 23 | 24 | # PHP www-user UID and GID 25 | ARG PUID="1000" 26 | ARG PGID="1000" 27 | 28 | # Let's Encrypt Agreement 29 | ENV ACME_AGREE="false" 30 | 31 | # Telemetry Stats 32 | ENV ENABLE_TELEMETRY="$enable_telemetry" 33 | 34 | RUN apk add --no-cache \ 35 | ca-certificates \ 36 | curl \ 37 | git \ 38 | mailcap \ 39 | openssh-client \ 40 | php7-fpm \ 41 | tar \ 42 | tzdata 43 | 44 | # Essential PHP Extensions 45 | RUN apk add --no-cache \ 46 | php7-bcmath \ 47 | php7-ctype \ 48 | php7-curl \ 49 | php7-dom \ 50 | php7-exif \ 51 | php7-fileinfo \ 52 | php7-gd \ 53 | php7-iconv \ 54 | php7-json \ 55 | php7-mbstring \ 56 | php7-mysqli \ 57 | php7-opcache \ 58 | php7-openssl \ 59 | php7-pdo \ 60 | php7-pdo_mysql \ 61 | php7-pdo_pgsql \ 62 | php7-pdo_sqlite \ 63 | php7-pgsql \ 64 | php7-phar \ 65 | php7-session \ 66 | php7-simplexml \ 67 | php7-sqlite3 \ 68 | php7-tokenizer \ 69 | php7-xml \ 70 | php7-xmlreader \ 71 | php7-xmlwriter \ 72 | php7-zip 73 | 74 | # Symlink php7 to php 75 | RUN ln -sf /usr/bin/php7 /usr/bin/php 76 | 77 | # Symlink php-fpm7 to php-fpm 78 | RUN ln -sf /usr/bin/php-fpm7 /usr/bin/php-fpm 79 | 80 | # Add a PHP www-user instead of nobody 81 | RUN addgroup -g ${PGID} www-user && \ 82 | adduser -D -H -u ${PUID} -G www-user www-user && \ 83 | sed -i "s|^user = .*|user = www-user|g" /etc/php7/php-fpm.d/www.conf && \ 84 | sed -i "s|^group = .*|group = www-user|g" /etc/php7/php-fpm.d/www.conf 85 | 86 | # Composer 87 | RUN curl --silent --show-error --fail --location \ 88 | --header "Accept: application/tar+gzip, application/x-gzip, application/octet-stream" \ 89 | "https://getcomposer.org/installer" \ 90 | | php -- --install-dir=/usr/bin --filename=composer 91 | 92 | # Allow environment variable access 93 | RUN echo "clear_env = no" >> /etc/php7/php-fpm.conf 94 | 95 | # Install Caddy 96 | COPY --from=builder /install/caddy /usr/bin/caddy 97 | 98 | # Validate install 99 | RUN /usr/bin/caddy -version 100 | RUN /usr/bin/caddy -plugins 101 | 102 | EXPOSE 80 443 2015 103 | VOLUME /root/.caddy /srv 104 | WORKDIR /srv 105 | 106 | COPY Caddyfile /etc/Caddyfile 107 | COPY index.php /srv/index.php 108 | 109 | # Install Process Wrapper 110 | COPY --from=builder /go/bin/parent /bin/parent 111 | 112 | ENTRYPOINT ["/bin/parent", "caddy"] 113 | CMD ["--conf", "/etc/Caddyfile", "--log", "stdout", "--agree=$ACME_AGREE"] 114 | -------------------------------------------------------------------------------- /php/Dockerfile-no-stats: -------------------------------------------------------------------------------- 1 | # 2 | # Builder 3 | # 4 | FROM abiosoft/caddy:builder as builder 5 | 6 | ARG version="1.0.3" 7 | ARG plugins="git,cors,realip,expires,cache,cloudflare" 8 | 9 | # Process Wrapper 10 | RUN go get -v github.com/abiosoft/parent 11 | 12 | RUN VERSION=${version} PLUGINS=${plugins} ENABLE_TELEMETRY=false /bin/sh /usr/bin/builder.sh 13 | 14 | # 15 | # Final Stage 16 | # 17 | FROM alpine:3.10 18 | LABEL maintainer "Abiola Ibrahim " 19 | 20 | ARG version="1.0.3" 21 | LABEL caddy_version="$version" 22 | 23 | # PHP www-user UID and GID 24 | ARG PUID="1000" 25 | ARG PGID="1000" 26 | 27 | # Let's Encrypt Agreement 28 | ENV ACME_AGREE="false" 29 | 30 | # Telemetry Stats 31 | ENV ENABLE_TELEMETRY="false" 32 | 33 | RUN apk add --no-cache \ 34 | ca-certificates \ 35 | curl \ 36 | git \ 37 | mailcap \ 38 | openssh-client \ 39 | php7-fpm \ 40 | tar \ 41 | tzdata 42 | 43 | # Essential PHP Extensions 44 | RUN apk add --no-cache \ 45 | php7-bcmath \ 46 | php7-ctype \ 47 | php7-curl \ 48 | php7-dom \ 49 | php7-exif \ 50 | php7-fileinfo \ 51 | php7-gd \ 52 | php7-iconv \ 53 | php7-json \ 54 | php7-mbstring \ 55 | php7-mysqli \ 56 | php7-opcache \ 57 | php7-openssl \ 58 | php7-pdo \ 59 | php7-pdo_mysql \ 60 | php7-pdo_pgsql \ 61 | php7-pdo_sqlite \ 62 | php7-pgsql \ 63 | php7-phar \ 64 | php7-session \ 65 | php7-simplexml \ 66 | php7-sqlite3 \ 67 | php7-tokenizer \ 68 | php7-xml \ 69 | php7-xmlreader \ 70 | php7-xmlwriter \ 71 | php7-zip 72 | 73 | # Symlink php7 to php 74 | RUN ln -sf /usr/bin/php7 /usr/bin/php 75 | 76 | # Symlink php-fpm7 to php-fpm 77 | RUN ln -sf /usr/bin/php-fpm7 /usr/bin/php-fpm 78 | 79 | # Add a PHP www-user instead of nobody 80 | RUN addgroup -g ${PGID} www-user && \ 81 | adduser -D -H -u ${PUID} -G www-user www-user && \ 82 | sed -i "s|^user = .*|user = www-user|g" /etc/php7/php-fpm.d/www.conf && \ 83 | sed -i "s|^group = .*|group = www-user|g" /etc/php7/php-fpm.d/www.conf 84 | 85 | # Composer 86 | RUN curl --silent --show-error --fail --location \ 87 | --header "Accept: application/tar+gzip, application/x-gzip, application/octet-stream" \ 88 | "https://getcomposer.org/installer" \ 89 | | php -- --install-dir=/usr/bin --filename=composer 90 | 91 | # Allow environment variable access 92 | RUN echo "clear_env = no" >> /etc/php7/php-fpm.conf 93 | 94 | # Install Caddy 95 | COPY --from=builder /install/caddy /usr/bin/caddy 96 | 97 | # Validate install 98 | RUN /usr/bin/caddy -version 99 | RUN /usr/bin/caddy -plugins 100 | 101 | EXPOSE 80 443 2015 102 | VOLUME /root/.caddy /srv 103 | WORKDIR /srv 104 | 105 | COPY Caddyfile /etc/Caddyfile 106 | COPY index.php /srv/index.php 107 | 108 | # Install Process Wrapper 109 | COPY --from=builder /go/bin/parent /bin/parent 110 | 111 | ENTRYPOINT ["/bin/parent", "caddy"] 112 | CMD ["--conf", "/etc/Caddyfile", "--log", "stdout", "--agree=$ACME_AGREE"] 113 | -------------------------------------------------------------------------------- /php/index.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Caddy 5 | 11 | 12 | 13 |

Caddy web server.

14 |

If you see PHP info below, Caddy with PHP container works.

15 | 16 |

More instructions about this image is here.

17 |

More instructions about Caddy is here.

18 | 21 | 22 | --------------------------------------------------------------------------------