---
**NGINX**
```
docker pull nginx:1.19
```
**MariaDB**
```
docker pull mariadb:10.5
```
**Redis**
```
docker pull redis:6.0
```
**docker-compose.yml**
```
version: '3'
services:
nginx:
image: nginx:1.19
restart: always
ports:
- 8000:80
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf
- ./nginx/conf.d:/etc/nginx/conf.d
- ./nginx/logs:/var/log/nginx
- ./src:/usr/share/nginx/html
php:
build: ./php
volumes:
- ./src:/var/www
- ./php/php.ini:/usr/local/etc/php/php.ini
- ./php/php-fpm.conf:/usr/local/etc/php-fpm.d/www.conf
mariadb:
image: mariadb:10.5
volumes:
- /etc/localtime:/etc/localtime
- ./mariadb/data:/var/lib/mysql
- ./mariadb/conf.d:/etc/mysql/conf.d
- ./mariadb/logs:/var/log
ports:
- 3306:3306
environment:
TIME_ZONE: "Asia/Shanghai"
MYSQL_ROOT_PASSWORD: "2LCqvSOJ6m0Ut6ui"
redis:
image: redis:6.0
hostname: redis
restart: always
volumes:
- ./redis/data:/data
- ./redis/redis.cnf:/usr/local/etc/redis/redis.conf
- ./redis/logs:/logs
command:
redis-server /usr/local/etc/redis/redis.conf --appendonly yes
ports:
- 6379:6379
```
**Dockerfile**
```
FROM php:7.4-fpm-alpine
MAINTAINER "maXcon <409985270@qq.com>"
LABEL version="1.0.1" description="PHP add fpm,redis,swoole"
ENV MXC_TIME_ZONE "Asia/Shanghai"
ENV MXC_SW_VER 4.5.3
ENV MXC_RS_VER 5.3.1
VOLUME /tmp /mnt /var/www
COPY ./ext/composer.phar /tmp/composer.phar
ADD ./ext/swoole-${MXC_SW_VER}.tgz /tmp
ADD ./ext/redis-${MXC_RS_VER}.tgz /tmp
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories && \
ln -sf /usr/share/zoneinfo/${MXC_TIME_ZONE} /etc/localtime && \
echo "${MXC_TIME_ZONE}" > /etc/timezone && \
apk update && apk upgrade && \
apk add --no-cache m4 autoconf make gcc g++ linux-headers && \
cd /tmp/swoole-${MXC_SW_VER} && \
(phpize && ./configure && make && make install) && \
cd /tmp/redis-${MXC_RS_VER} && \
(phpize && ./configure && make && make install) && \
docker-php-ext-enable swoole redis && \
docker-php-ext-install bcmath && \
chmod u+x /tmp/composer.phar && \
mv /tmp/composer.phar /usr/local/bin/composer && \
composer config -g repo.packagist composer https://mirrors.aliyun.com/composer && \
apk del m4 autoconf make g++ linux-headers && \
rm -rf /var/cache/apk/* /tmp/*
WORKDIR /var/www
CMD php-fpm
```