Add caddy custom docker image build scripts

This commit is contained in:
Alice Gaudon 2019-05-21 02:02:53 +02:00
parent f3ef58f0bc
commit d2c12a2a10
5 changed files with 156 additions and 0 deletions

View File

@ -0,0 +1,11 @@
0.0.0.0
browse
fastcgi / 127.0.0.1:9000 php
on startup php-fpm7
log stdout
errors stdout

View File

@ -0,0 +1,98 @@
#
# Builder
#
FROM abiosoft/caddy:builder as builder
ARG version="1.0.0"
ARG plugins="git,cors,realip,expires,cache"
# process wrapper
RUN go get -v github.com/abiosoft/parent
RUN VERSION=${version} PLUGINS=${plugins} /bin/sh /usr/bin/builder.sh
#
# Final stage
#
FROM alpine:3.8
LABEL maintainer "Abiola Ibrahim <abiola89@gmail.com>"
ARG version="1.0.0"
LABEL caddy_version="$version"
# PHP www-user UID and GID
ARG PUID="1000"
ARG PGID="1000"
# Let's Encrypt Agreement
ENV ACME_AGREE="false"
RUN apk add --no-cache openssh-client git tar php7-fpm curl
# essential php libs
RUN apk add --no-cache \
php7-bcmath \
php7-ctype \
php7-curl \
php7-dom \
php7-fileinfo \
php7-gd \
php7-iconv \
php7-json \
php7-mbstring \
php7-mysqli \
php7-openssl \
php7-pdo \
php7-pdo_mysql \
php7-pgsql \
php7-phar \
php7-session \
php7-simplexml \
php7-sqlite3 \
php7-tokenizer \
php7-xml \
php7-xmlreader \
php7-xmlwriter \
php7-zip
# symblink php7 to php
RUN ln -sf /usr/bin/php7 /usr/bin/php
# symlink php-fpm7 to php-fpm
RUN ln -sf /usr/bin/php-fpm7 /usr/bin/php-fpm
# add a php www-user instead of nobody
RUN addgroup -g ${PGID} www-user && \
adduser -D -H -u ${PUID} -G www-user www-user && \
sed -i "s|^user = .*|user = www-user|g" /etc/php7/php-fpm.d/www.conf && \
sed -i "s|^group = .*|group = www-user|g" /etc/php7/php-fpm.d/www.conf
# composer
RUN curl --silent --show-error --fail --location \
--header "Accept: application/tar+gzip, application/x-gzip, application/octet-stream" \
"https://getcomposer.org/installer" \
| php -- --install-dir=/usr/bin --filename=composer
# allow environment variable access.
RUN echo "clear_env = no" >> /etc/php7/php-fpm.conf
# install caddy
COPY --from=builder /install/caddy /usr/bin/caddy
# validate install
RUN /usr/bin/caddy -version
RUN /usr/bin/caddy -plugins
EXPOSE 80 443 2015
VOLUME /root/.caddy /srv
WORKDIR /srv
COPY Caddyfile /etc/Caddyfile
COPY index.php /srv/index.php
# install process wrapper
COPY --from=builder /go/bin/parent /bin/parent
ENTRYPOINT ["/bin/parent", "caddy"]
CMD ["--conf", "/etc/Caddyfile", "--log", "stdout", "--agree=$ACME_AGREE"]

View File

@ -0,0 +1,9 @@
#!/bin/sh
if [ $# -eq 0 ]
then
echo "Usage: <script> <id>"
else
ID=$1
docker build --build-arg PUID=$ID --build-arg PGID=$ID .
fi

View File

@ -0,0 +1,16 @@
#!/bin/sh
if [ $# -eq 0 ]
then
echo "Usage: <script> <container_id>"
else
CONTAINER_ID=$1
docker run -d --restart always \
-v /home/website/caddy/caddy.conf:/etc/Caddyfile \
-v /home/website/.caddy:/root/.caddy \
-v /home/arisu/rtmp:/home/arisu/rtmp \
-v /home/website:/home/website \
-p 80:80 -p 443:443 -p 2015:2015 \
-e ACME_AGREE=true \
$CONTAINER_ID
fi

View File

@ -0,0 +1,22 @@
<!DOCTYPE html>
<html>
<head>
<title>Caddy</title>
<style>
body {
text-align: center;
font-family: Tahoma, Geneva, Verdana, sans-serif;
}
</style>
</head>
<body>
<h1>Caddy web server.</h1>
<p>If you see PHP info below, Caddy with PHP container works.</p>
<p>More instructions about this image is <a href="//github.com/abiosoft/caddy-docker/blob/master/README.md" target="_blank">here</a>.<p>
<p>More instructions about Caddy is <a href="//caddyserver.com/docs" target="_blank">here</a>.<p>
<?php
phpinfo()
?>
</body>
</html>