一、全局配置
代码语言:javascript复制name: lnmp
services:
caddy:
image: caddy:latest
volumes:
- ./www:/var/www/html
- ./caddy/etc:/etc/caddy
- ./caddy/data:/data
- ./caddy/config:/config
ports:
- 80:80
- 443:443/tcp
- 443:443/udp
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: 3
restart: always
redis:
image: redis:latest
volumes:
- ./redis/config:/etc/redis
- ./redis/data:/data
restart: always
command: /etc/redis/redis.conf
mysql:
image: mysql:latest
volumes:
- ./mysql/config:/etc/mysql
- ./mysql/data:/var/lib/mysql
- ./mysql/mysql-files:/var/lib/mysql-files
cap_add:
- SYS_NICE
security_opt:
- seccomp:unconfined
environment:
MYSQL_ROOT_PASSWORD: password
ports:
- 3306:3306
restart: always
php:
build: ./php
volumes:
- ./php/config:/usr/local/etc
- ./php/logs:/var/log/php
- ./www:/var/www/html
depends_on:
- caddy
- mysql
- redis
cap_add:
- SYS_PTRACE
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: 3
restart: always
imaginary:
image: nextcloud/aio-imaginary:latest
restart: always
command: -concurrency 2 -enable-url-source
environment:
- PORT=9000
1. PHP
PHP官方的镜像启用和安装的扩展比较少,直接使用会导致WordPress和Nextcloud的健康检查一堆信息,所以使用Dockerfile来基于官方镜像构建一个专用的镜像,PHP需要的扩展包括:
- gd(png/jpeg/gif/webp/avif)
- imagick
- opcache(考虑性能)
- apcu(Nextcloud的本地缓存)
- zip(影响WordPress插件安装)
- redis(WordPress的对象缓存和Nextcloud的分布式缓存)
- gmp
- intl
FROM php:8.2-fpm-alpine
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories &&
apk add --no-cache --update --virtual .build-deps
$PHPIZE_DEPS
icu
&& apk add --no-cache --virtual .php-deps
imagemagick-dev
imagemagick-svg
libzip-dev
libpng-dev
libavif-dev
icu-dev
gmp-dev
libjpeg-turbo-dev
freetype-dev
&& apk add --no-cache --virtual .tools-deps
git
openssh-client
unzip
&& apk add --no-cache --virtual .runtime-deps
libzip
libpng
libavif
libjpeg-turbo
freetype
&& pecl install https://pecl.php.net/get/imagick-3.7.0.tgz https://pecl.php.net/get/redis-6.0.2.tgz apcu
&& docker-php-ext-configure intl
&& docker-php-ext-configure gd
--with-freetype=/usr/include/
--with-jpeg=/usr/include/
--with-avif=/usr/include/
&& docker-php-ext-install zip gd pdo_mysql pcntl mysqli exif intl gmp bcmath sysvsem && docker-php-ext-enable zip gd pdo_mysql mysqli opcache exif intl gmp bcmath pcntl sysvsem imagick redis apcu