-
-
Save mybigman/cb9a36c07d9cef6d2404badf43693932 to your computer and use it in GitHub Desktop.
Single PHP FPM container with Caddy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/vendor | |
/docker | |
/Dockerfile |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0.0.0.0:{$PORT} | |
root /usr/src/app/public | |
fastcgi / /var/run/php-fpm.sock php | |
rewrite { | |
to {path} /index.php?{query} | |
} | |
supervisor { | |
command php-fpm | |
restart_policy always | |
redirect_stdout stdout | |
redirect_stderr stderr | |
} | |
errors stdout |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM php:7.4-fpm-alpine | |
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer | |
COPY --from=wizbii/caddy /caddy /usr/local/bin/caddy | |
RUN apk add --no-cache autoconf openssl-dev g++ make pcre-dev icu-dev zlib-dev libzip-dev && \ | |
docker-php-ext-install bcmath intl opcache zip sockets && \ | |
apk del --purge autoconf g++ make && \ | |
mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" | |
WORKDIR /usr/src/app | |
COPY composer.json composer.lock ./ | |
RUN composer install --no-dev --optimize-autoloader --no-scripts --no-plugins --prefer-dist --no-progress --no-interaction | |
COPY . . | |
ENV APP_ENV=prod | |
ENV PORT=80 | |
RUN caddy -validate -conf=docker/Caddyfile && \ | |
cp docker/php-fpm.conf /usr/local/etc/php-fpm.d/zz-docker.conf && \ | |
php bin/console cache:warmup && \ | |
chmod -R 777 var/cache var/log | |
EXPOSE 80 | |
CMD ["caddy", "--conf", "docker/Caddyfile", "--log", "stdout"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[global] | |
daemonize = no | |
[www] | |
listen = /var/run/php-fpm.sock |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment