dockerfile/php8.1-swoole-alpine/Dockerfile
2022-10-20 09:14:50 +08:00

98 lines
3.4 KiB
Docker

ARG ALPINE_VERSION=3.16
ARG PHP_VERSION=8.1.11
FROM php:${PHP_VERSION}-fpm-alpine${ALPINE_VERSION}
LABEL maintainer="Tian Ma Wms Develop Group" version="1.0" license="MIT"
ENV PHPIZE_DEPS="autoconf dpkg-dev dpkg file g++ gcc make php8-dev php8-pear pkgconf re2c pcre-dev pcre2-dev automake"
# 中科大镜像
ARG CONTAINER_PACKAGE_URL=mirrors.ustc.edu.cn
RUN if [ $CONTAINER_PACKAGE_URL ] ; then sed -i "s/dl-cdn.alpinelinux.org/${CONTAINER_PACKAGE_URL}/g" /etc/apk/repositories ; fi
ARG TZ=Asia/Shanghai
RUN set -ex \
&& apk --no-cache add tzdata \
&& cp "/usr/share/zoneinfo/$TZ" /etc/localtime \
&& echo "$TZ" > /etc/timezone
# Install composer and change it's cache home
RUN curl -o /usr/bin/composer https://mirrors.aliyun.com/composer/composer.phar \
&& chmod +x /usr/bin/composer \
&& composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
ENV COMPOSER_HOME=/tmp/composer
COPY ./extensions /tmp/extensions
WORKDIR /tmp/extensions
RUN set -ex \
&& apk update \
&& apk add --no-cache libstdc++ openssl bash c-ares-dev libpq-dev libc-dev libaio-dev openssl-dev curl-dev zlib-dev\
&& apk add --no-cache --virtual .build-deps $PHPIZE_DEPS \
&& set -ex \
&& unzip swoole-v5.0.0.zip && cd swoole-v5.0.0 \
&& phpize \
&& ./configure --enable-openssl --enable-swoole-curl --enable-cares --enable-swoole-pgsql \
&& make -s -j$(nproc) && make install \
&& docker-php-ext-enable swoole && cd ../ && rm -rf swoole-v5.0.0 \
#Install redis
&& pecl install igbinary && docker-php-ext-enable igbinary \
&& pecl install redis \
&& docker-php-ext-enable redis \
&& pecl install mongodb && docker-php-ext-enable mongodb \
&& docker-php-ext-install -j$(nproc) pdo_mysql \
&& docker-php-ext-install -j$(nproc) sockets \
&& docker-php-ext-install -j$(nproc) bcmath \
&& docker-php-ext-install -j$(nproc) exif \
&& docker-php-ext-install -j$(nproc) calendar \
#Install pcntl
&& docker-php-ext-install -j$(nproc) pcntl \
# #Install protobuf
&& pecl install protobuf && docker-php-ext-enable protobuf \
#Insatll zip
&& apk add --no-cache libzip-dev \
&& docker-php-ext-install -j$(nproc) zip \
#Install imagick
&& apk add --no-cache imagemagick-dev libtool \
&& pecl install imagick \
&& docker-php-ext-enable imagick \
#Install gd
&& apk add --no-cache \
freetype \
freetype-dev \
libpng \
libpng-dev \
libjpeg-turbo \
libjpeg-turbo-dev \
libwebp-dev \
&& docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp \
&& docker-php-ext-install -j$(nproc) gd \
&& apk del \
freetype-dev \
libpng-dev \
libjpeg-turbo-dev \
#Install event
&& apk add --no-cache libevent-dev \
&& mkdir event && tar -xvf event-3.0.5.tgz && cd event-3.0.5/ \
&& phpize && ./configure && make -j$(nproc) && make install \
&& docker-php-ext-enable event && cd ../ && rm -rf event-3.0.5 \
&& mv /usr/local/etc/php/conf.d/docker-php-ext-event.ini /usr/local/etc/php/conf.d/docker-php-ext-z-event.ini \
#&& apk del .build-deps \
&& rm -rf /var/cache/apk/* /tmp/*
#RUN apk --no-cache add shadow && usermod -u 1000 www-data && groupmod -g 1000 www-data
COPY ./php.ini /usr/local/etc/php/php.ini
# ---------- clear ----------
RUN set -x \
&& rm -rf /var/cache/apk/* /tmp/*
WORKDIR /www