caddy-docker
caddy-docker copied to clipboard
Split caddy and php-fpm in different images
Split php-fpm to a independent image and change fastcgi destination from 127.0.0.1 to an environment variabne with default (set by dockerfile) for example "php"?
So with docker swarm a second service with name "php" (or without swarm docker linked container) is used to forward php requests to?
I test a custom dockerfile / build with build-arg for caddy plugins and alpine packages. Caddyfile generated by ENV.
dockerfile
#
# Builder
#
FROM abiosoft/caddy:builder as builder
ARG version="1.0.0"
ARG plugins=""
ARG enable_telemetry="false"
RUN VERSION=${version} PLUGINS=${plugins} ENABLE_TELEMETRY=${enable_telemetry} /bin/sh /usr/bin/builder.sh
# validate build
RUN /install/caddy -version
RUN /install/caddy -plugins
#
# Final stage
#
FROM alpine:3.9
ARG version="1.0.0"
LABEL caddy_version="$version"
# Telemetry Stats
ENV ENABLE_TELEMETRY="$enable_telemetry"
ARG packages=""
RUN [ ! -z "$packages" ] && apk --update --no-cache add $packages || true
EXPOSE 80 443 2015
WORKDIR /srv
# base Caddyfile config
ENV CADDYCONF="0.0.0.0\nlog stdout\nerrors stdout"
# install caddy
COPY --from=builder /install/caddy /usr/bin/caddy
COPY files/ /
# entrypoint generate the Caddyfile during startup
ENTRYPOINT ["entrypoint-caddy"]
CMD ["caddy", "--conf", "/etc/Caddyfile", "--log", "stdout"]
files/usr/local/bin/entrypoint-caddy
#!/bin/sh
printf "$CADDYCONF" > /etc/Caddyfile
exec $@