Dockerfile编写php环境

Docker无疑对我们后端开发者来说是一个非常非常吊的里程碑,构建生产环境和开发环境,真正做到解放双手,优雅搭建环境

想用laradock,但是由于墙内的原因,各种问题,我们就是图快,但是这么多问题,想想还是算了
之前写php的Dockerfile 最让人头疼的就是php的扩展的安装了,这简直让人头疼,什么php版本要适配什么版本的xdebug,redis之类的,通常升级一个版本,都要各种踩雷。

有了install-php-extensions 玩意之后,mm再也不用怕采坑了。

一个自由添加各种插件的Dockerfile:

FROM php:7.4-fpm
LABEL maintainer="dev@chialab.io"

# Download script to install PHP extensions and dependencies
ADD https://raw.githubusercontent.com/mlocati/docker-php-extension-installer/master/install-php-extensions /usr/local/bin/

RUN chmod uga+x /usr/local/bin/install-php-extensions && sync

RUN DEBIAN_FRONTEND=noninteractive apt-get update -q \
    && DEBIAN_FRONTEND=noninteractive apt-get install -qq -y \
      curl \
      git \
      zip unzip \
    && install-php-extensions \
      bcmath \
      bz2 \
      calendar \
      exif \
      gd \
      intl \
      ldap \
      memcached \
      mysqli \
      opcache \
      pdo_mysql \
      pdo_pgsql \
      pgsql \
      redis \
      soap \
      xsl \
      zip \
      sockets\
      swoole\
      yaf\
      memcached\
      mongodb\
      mcrypt
# already installed:
#      iconv \
#      mbstring \

# Install Composer.
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \
    && ln -s $(composer config --global home) /root/composer
ENV PATH=$PATH:/root/composer/vendor/bin COMPOSER_ALLOW_SUPERUSER=1

# Install prestissimo (composer plugin). Plugin that downloads packages in parallel to speed up the installation process
# After release of Composer 2.x, remove prestissimo, because parallelism already merged into Composer 2.x branch:
# https://github.com/composer/composer/pull/7904
RUN composer global require hirak/prestissimo

源代码:github

我的镜像:

docker pull liaosp/php:7.4
©️2020 CSDN 皮肤主题: 酷酷鲨 设计师:CSDN官方博客 返回首页