php8 docker file

FROM php:8.1.7-fpm-alpine


USER root

# 更改镜像源为阿里云
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/' /etc/apk/repositories \
    && apk update \
    && apk upgrade \
    && apk add --no-cache bash

# 安装相关的依耐包
RUN apk --update add wget \
  curl \
  curl-dev \
  git \
  build-base \
  libmemcached-dev \
  libmcrypt-dev \
  libxml2-dev \
  pcre-dev \
  zlib-dev \
  autoconf \
  cyrus-sasl-dev \
  libgsasl-dev \
  oniguruma-dev \
  openssl \
  openssl-dev \
  g++ \
  libtool \
  make \
  linux-headers 

# 安装 mysqli mbstring pdo pdo_mysql xml pcntl
RUN docker-php-ext-install pdo pdo_mysql mysqli mbstring bcmath

# 安装GD库 7.4 安装参数发生变化 @https://www.php.net/manual/zh/migration74.other-changes.php#migration74.other-changes.pkg-config
RUN apk add --update --no-cache freetype-dev libjpeg-turbo-dev jpeg-dev libpng-dev; \
        docker-php-ext-configure gd --with-freetype=/usr/lib/ --with-jpeg=/usr/lib/ && \
        docker-php-ext-install gd; 


# 安装ZipArchive
RUN apk --update add libzip-dev && \
    docker-php-ext-configure zip && \
    docker-php-ext-install zip;

# 安装redis扩展
RUN pecl install -o -f redis \
    &&  rm -rf /tmp/pear \
    &&  docker-php-ext-enable redis

# 安装composer
# ADD ./composer /usr/local/bin/composer

# Composer install
RUN curl -sS http://getcomposer.org/installer | php \
   && mv composer.phar /usr/local/bin/composer \
   && chmod u+x /usr/local/bin/composer \
   && composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/


# Swoole install
RUN docker-php-ext-install -j 2 sockets \
    && pecl install -D 'enable-sockets="yes" enable-openssl="yes" enable-http2="yes" enable-mysqlnd="yes" enable-swoole-json="yes" enable-swoole-curl="yes" enable-cares="yes"' swoole \
    && docker-php-ext-enable swoole

# 安装 memcached、mongodb
RUN pecl install memcached mongodb && \
    docker-php-ext-enable memcached mongodb

# Clean up
RUN rm /var/cache/apk/* \
    && mkdir -p /var/www \
    && rm -rf /usr/src/php


CMD ["php-fpm"]

EXPOSE 9000
此条目发表在docker, 基础分类目录,贴了, , , , 标签。将固定链接加入收藏夹。