dockerfile-php82
镜像采用官方 8.2 版本
FROM php:8.2-fpm
定义环境变量,方便引用
很多国外软件下载比较慢,为了减少构建时间,统一先下载,放置在 tool 文件夹内,构建时 COPY 使用
ENV TOOL_PATH=./tool
配置时区
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
更新apt-get
, 安装系统工具
COPY $TOOL_PATH/apt/sources.list /etc/apt
RUN apt-get update --fix-missing \
&& apt-get install -y wget unzip libaio1
安装oracleclient
预先下载安装包,放置于/tool/oci8
, 解压缩,创建软连接,配置so
,安装php
扩展
WORKDIR /opt/oracle
COPY $TOOL_PATH/oci8 ./
RUN unzip instantclient-basic-linux.x64-11.2.0.4.0.zip \
&& rm -rf instantclient-basic-linux.x64-11.2.0.4.0.zip \
&& unzip instantclient-sdk-linux.x64-11.2.0.4.0.zip \
&& rm -rf instantclient-sdk-linux.x64-11.2.0.4.0.zip \
&& ln -s /opt/oracle/instantclient_11_2/libclntsh.so.11.1 /opt/oracle/instantclient_11_2/libclntsh.so \
&& ln -s /opt/oracle/instantclient_11_2/libocci.so.11.1 /opt/oracle/instantclient_11_2/libocci.so \
&& echo "/opt/oracle/instantclient_11_2" > /etc/ld.so.conf.d/oracle-instantclient.conf \
&& ldconfig \
&& echo 'instantclient,/opt/oracle/instantclient_11_2' | pecl install oci8 \
&& docker-php-ext-enable oci8
安装 composer
利用WORKDIR
命令创建临时工作目录
WORKDIR /working
COPY $TOOL_PATH/composer/composer-setup.php ./
RUN php composer-setup.php \
&& php -r "unlink('composer-setup.php');" \
&& mv composer.phar /usr/local/bin/composer \
&& composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
安装 php 扩展
RUN docker-php-ext-install pdo_mysql mysqli bcmath
安装 imagick
预先下载安装包,放置于/tool/imagick
COPY $TOOL_PATH/imagick/imagick-3.7.0.tgz ./
RUN apt-get install -y libmagick++-dev \
&& pecl install -D 'with-imagick="autodetect"' ./imagick-3.7.0.tgz \
&& docker-php-ext-enable imagick && php --ri imagick \
&& rm -rf imagick-3.7.0.tgz
–安装 soap
RUN apt-get install -y libxml2-dev
&& docker-php-ext-install soap && php --ri soap
–安装 zip
RUN apt-get install -y libzip-dev
&& docker-php-ext-install zip && php --ri zip
clear
RUN rm -rf /var/cache/apt/* \
&& rm -rf /var/lib/apt/lists/*
RUN mkdir /var/lib/sessions \
&& chmod o=rwx -R /var/lib/sessions
推荐文章: