docker
//注意安装libevent时,要选择对应openssl版本的,否则出错
FROM php:7.3.8-fpm
COPY . /usr/src/tmp
WORKDIR /usr/src/tmp
RUN apt-get update \
# 相关依赖必须手动安装
&& apt-get install -y \
libfreetype6-dev \
libjpeg62-turbo-dev \
libmcrypt-dev \
libpng-dev \
openssl \
libssl-dev \
# 安装扩展
# 如果安装的扩展需要自定义配置时
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ --with-png-dir=/usr/libpng \
&& docker-php-ext-install -j$(nproc) gd pcntl sockets pdo_mysql mysqli
RUN curl -L -o /tmp/redis.tar.gz https://github.com/phpredis/phpredis/archive/5.0.0.tar.gz \
&& cd /tmp && tar xfz redis.tar.gz \
&& rm -r /tmp/redis.tar.gz \
&& mkdir -p /usr/src/php/ext \
&& mv /tmp/phpredis-5.0.0 /usr/src/php/ext/redis \
&& docker-php-ext-install redis
RUN curl -L -o /tmp/libevent-2.1.10.gz https://github.com/libevent/libevent/releases/download/release-2.1.10-stable/libevent-2.1.10-stable.tar.gz \
&& cd /tmp && tar xfz libevent-2.1.10.gz \
&& rm -r /tmp/libevent-2.1.10.gz \
&& cd /tmp/libevent-2.1.10-stable \
&& ./configure --prefix=/usr/local/libevent2.1 \
&& make \
&& make install
RUN curl -L -o /tmp/event-2.3.0.gz http://pecl.php.net/get/event-2.3.0.tgz \
&& cd /tmp && tar xfz event-2.3.0.gz \
&& rm -r /tmp/event-2.3.0.gz \
&& cd /tmp/event-2.3.0 \
&& /usr/local/bin/phpize \
&& ./configure --with-event-libevent-dir=/usr/local/libevent2.1 \
&& make \
&& make install \
&& docker-php-ext-enable event
docker-compose
version: "3.6"
services:
php-7.3.8:
image: php-redis
container_name: php-7.3.8
working_dir: /usr/src/tmp
environment:
- PORT=9000
stdin_open: true
networks:
redis-master:
ipv4_address: 172.50.0.33
tty: true
privileged: true
volumes: ["./file://usr/src/tmp/file"]
networks:
redis-master:
external:
name: cluster_redis-master
docker-compose up -d