Docker無疑對我們後端開發者來說是一個非常非常重要的里程碑,構建生產環境和開發環境,真正做到解放雙手,優雅搭建環境
laradock,是一個不錯的選擇,但是由於牆內的原因,各種問題,我們就是他圖快,但是這麼多問題,想想還是算了
之前寫php的Dockerfile 最讓人頭疼的就是php的擴充套件的安裝了,什麼php版本要適配什麼版本的xdebug,redis,先下載pecl之類的,通常升級一個版本,都要各種踩雷。
有了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
我的映象:
docker pull liaosp/php:7.4
本站:docker入門
原始碼:github
我的 github
本作品採用《CC 協議》,轉載必須註明作者和本文連結