Dockerfile
FROM php:7.3.33-fpm
#WORKDIR /code
#插件版本更新
#sed -i 's|security.debian.org/debian-security|mirrors.ustc.edu.cn/debian-security|g' /etc/apt/sources.list
#sed -i "s@http://deb.debian.org@http://mirrors.ustc.edu.cn@g" /etc/apt/sources.list
RUN sed -i "s@http://deb.debian.org@http://mirrors.aliyun.com@g" /etc/apt/sources.list \
&& sed -i "s@http://security.debian.org@http://mirrors.aliyun.com@g" /etc/apt/sources.list \
&& apt-get clean && apt-get update \
&& mv /etc/localtime /etc/localtime_bak \
&& cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
&& echo "Asia/Shanghai" > /etc/timezone
#安装mysql
RUN docker-php-ext-install pdo pdo_mysql mysqli opcache bcmath pcntl
#安装插件 gd2+jpeg
RUN apt-get install -y libwebp-dev libjpeg-dev libpng-dev libfreetype6-dev libmcrypt-dev libjpeg62-turbo-dev --no-install-recommends \
&& docker-php-source extract \
&& cd /usr/src/php/ext/gd \
&& docker-php-ext-configure gd --with-webp-dir=/usr/include/webp --with-jpeg-dir=/usr/include --with-png-dir=/usr/include --with-freetype-dir=/usr/include/freetype2 \
&& docker-php-ext-install gd
#安装soap
RUN apt-get install libxml2-dev -y --no-install-recommends \
&& docker-php-ext-install soap
#RUN echo "安装zip"
RUN apt-get install -y zlib1g-dev libzip-dev --no-install-recommends \
&& docker-php-ext-install zip
RUN curl -L -o /tmp/redis.tar https://pecl.php.net/get/redis-5.3.7.tgz \
&& tar -zxvf /tmp/redis.tar \
&& mkdir -p /usr/src/php/ext \
&& cp -r ./redis-5.3.7 /usr/src/php/ext/redis \
&& rm -rf ./redis-5.3.7 \
&& cd /usr/src/php/ext/redis \
&& docker-php-ext-install redis \
&& rm -Rf /tmp/*
# && rm -Rf /var/lib/apt/lists/*
RUN apt-get install librabbitmq-dev -y --no-install-recommends \
&& curl -L -o /tmp/amqp.tar https://pecl.php.net/get/amqp-1.11.0.tgz \
&& tar -zxvf /tmp/amqp.tar \
&& cp -r ./amqp-1.11.0 /usr/src/php/ext/amqp \
&& rm -rf ./amqp-1.11.0 \
&& cd /usr/src/php/ext/amqp \
&& docker-php-ext-install amqp \
&& rm -Rf /tmp/*
#安装mongodb
RUN curl -L -o /tmp/mongodb.tar https://pecl.php.net/get/mongodb-1.15.3.tgz \
&& tar -zxvf /tmp/mongodb.tar \
&& cp -r ./mongodb-1.15.3 /usr/src/php/ext/mongodb \
&& rm -rf ./mongodb-1.15.3 \
&& cd /usr/src/php/ext/mongodb \
&& docker-php-ext-install mongodb \
&& rm -Rf /tmp/*
#安装dbase
RUN curl -L -o /tmp/dbase.tgz https://pecl.php.net/get/dbase-7.1.1.tgz \
&& tar -zxf /tmp/dbase.tgz \
&& mv ./dbase-7.1.1 /usr/src/php/ext/dbase \
&& cd /usr/src/php/ext/dbase \
&& docker-php-ext-install dbase
#清理安装临时文件
RUN rm -Rf /tmp/* && rm -Rf /var/lib/apt/lists/*
docker-compose.yaml
version: "3.9"
services:
php:
build:
context: ./
dockerfile: Dockerfile
container_name: php
restart: always
ports:
- "9000:9000"
#expose:
# - 9000
#volumes:
# - ./php.ini:/usr/local/etc/php/php.ini
# - ./php-fpm.d:/usr/local/etc/php-fpm.d
# - ./logs:/var/log
environment:
- TZ=Asia/Shanghai
build命令
docker build -t php-fpm:7.3.33.xx .