Sign inSign up

skiychan/caddy-php

By skiychan

•Updated almost 5 years ago

caddy-php for docker

Image
0

2.0K

skiychan/caddy-php repository overview

Source Repository: https://github.com/flydo/docker-caddy-php⁠

⁠Caddy PHP In Docker


⁠Build

git clone https://github.com/flydo/docker-caddy-php.git
cd docker-caddy-php
# like: docker build -f 8.1/Dockerfile -t caddy-php8.1 .
docker build -f {php_version}/Dockerfile -t caddy-php .
docker run -d -p 80:80 caddy-php

⁠Installation

Pull the image from the docker index rather than downloading the git repo. This prevents you having to build the image on every docker host.

docker pull skiychan/caddy-php:8.1

⁠docker-compose

version: '3'
services:
  web:
    image: skiychan/caddy-php:8.1
    restart: always
    container_name: site-default
    volumes:
      - ./www:/var/www/html
      - ./conf:/etc/caddy
    ports:
      - "80:80"

⁠Running

To simply run the container:

docker run --name caddy-php -p 8080:80 -d caddy-php:8.1

You can then browse to http://\<docker_host\>:8080 to view the default install files.

⁠Volumes

If you want to link to your web site directory on the docker host to the container run:

docker run --name caddy-php -p 8080:80 -v /your_code_directory:/var/www/html -v ./caddyfile_conf_directory:/etc/caddy -d caddy-php:8.1

⁠Dockerfile

FROM caddy:builder-alpine AS builder
RUN xcaddy build 


FROM php:8.1.0beta1-fpm-alpine
LABEL maintainer="Skiy Chan <[email protected]>"
COPY --from=builder /usr/bin/caddy /usr/bin/caddy

RUN set -eux ;\
    apk update && \
    apk add --no-cache --virtual \
        ca-certificates \
        mailcap \
        supervisor \
        gd-dev \
        freetype-dev \
        icu-dev \
        libmemcached-dev \
        oniguruma-dev \
        libxml2-dev \
        autoconf \
        gcc \
        g++ \
        make \
        ;\
    rm /var/cache/apk/* \
        ;\
    (printf "no" | pecl install redis) \
        ;\
    pecl install igbinary \
        redis \
        memcached

RUN docker-php-ext-install pdo_mysql \
        mysqli \
        exif \
        opcache \
        intl \
        shmop \
        sysvsem \
        mbstring \
        soap \
        bcmath \
        ;\
    docker-php-ext-enable redis \
        igbinary \
        memcached \
        shmop \
        sysvsem \
        ;\   
    docker-php-ext-configure gd \
        --enable-gd \
        --with-freetype \
        --with-jpeg \
        ;\
    NUMPROC=$(grep -c ^processor /proc/cpuinfo 2>/dev/null || 1) \
        ;\
    docker-php-ext-install -j${NUMPROC} gd ;\
    docker-php-source delete ;\
    apk del m4 \
        autoconf \
        binutils \
        libgomp \
        libatomic \
        libgphobos \
        gmp \
        isl22 \
        mpfr4 \
        mpc1 \
        gcc \
        musl-dev \
        libc-dev \
        g++ \
        make
        
RUN [ ! -e /etc/nsswitch.conf ] && echo 'hosts: files dns' > /etc/nsswitch.conf

WORKDIR /app/

VOLUME ["/etc/caddy", "/var/www/html"]

COPY ./files/Caddyfile /etc/caddy/
COPY ./files/index.php /var/www/html/
COPY ./files/supervisord.conf /etc/
COPY ./supervisord /etc/supervisord/
COPY ./scripts/entrypoint.sh /app/
RUN chmod +x /app/entrypoint.sh

EXPOSE 80 443

ENTRYPOINT ["sh", "/app/entrypoint.sh"]

⁠License

This project is licensed under the MIT license⁠.

Tag summary

Content type

Image

Digest

Size

151.9 MB

Last updated

almost 5 years ago

docker pull skiychan/caddy-php