fix php7.4 issue , and add docker

This commit is contained in:
Millyn 2020-03-06 14:52:48 +08:00
parent cf5d569f27
commit 1dd6315073
4 changed files with 107 additions and 1 deletions

View File

@ -87,7 +87,7 @@ function setCurrentOrganization($data)
function p($data, $force = false, $file = null)
{
is_null($file) && $file = env('runtime_path') . date('Ymd') . '.txt';
$str = (is_string($data) ? $data : (is_array($data) || is_object($data)) ? print_r($data, true) : var_export($data, true)) . PHP_EOL;
$str = (is_string($data) ? $data : ((is_array($data) || is_object($data)) ? print_r($data, true) : var_export($data, true))) . PHP_EOL;
$force ? file_put_contents($file, $str) : file_put_contents($file, $str, FILE_APPEND);
}

23
docker/README.md Normal file
View File

@ -0,0 +1,23 @@
# How to use ?
You need build PearProject docker image.
choise php version , and `cd` to dir.
```
# build
docker build -t pear-docker:1.0.0 .
# cd to root path
cd ../..
# attach container install composer vendor
docker run --rm -it --mount type=bind,source="$(pwd)",target=/app pear-docker:1.0.0 /bin/bash
composer install
exit
# run your docker
docker run --mount type=bind,source="$(pwd)",target=/app -p 1234:8081 pear-docker:1.0.0
```
Right , now visit http://127.0.0.1:1234

41
docker/php72/Dockerfile Normal file
View File

@ -0,0 +1,41 @@
FROM php:7.2-cli
# change package source for aliyun
run cp /etc/apt/sources.list /etc/apt/sources.list.bak \
&& echo "deb http://mirrors.aliyun.com/debian buster main" > /etc/apt/sources.list \
&& echo "deb http://mirrors.aliyun.com/debian buster-updates main" >> /etc/apt/sources.list \
&& apt clean;
# update package
RUN apt-get update;
# install php ext
RUN apt-get install -y libzip-dev libzip4 \
&& pecl install redis-5.2.0 \
&& pecl install igbinary-3.1.2 \
&& pecl install zip-1.17.2 \
&& docker-php-ext-enable redis igbinary zip
# install php ext PDO
RUN docker-php-ext-install pdo pdo_mysql
# install php gd ext
RUN apt-get install -y libwebp-dev libjpeg-dev libpng-dev libfreetype6-dev libjpeg62-turbo-dev \
&& docker-php-ext-configure gd --with-gd --with-webp-dir --with-jpeg-dir --with-png-dir --with-zlib-dir --with-freetype-dir \
&& docker-php-ext-install -j$(nproc) gd
# install wget
RUN apt-get install wget -y
# install composer
RUN cd /tmp \
&& wget https://mirrors.aliyun.com/composer/composer.phar \
&& mv composer.phar /usr/local/bin/composer \
&& chmod +x /usr/local/bin/composer \
&& composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/ \
&& composer self-update \
&& composer clear
WORKDIR /app
CMD ["php", "-S", "0.0.0.0:8081"]

42
docker/php74/Dockerfile Normal file
View File

@ -0,0 +1,42 @@
FROM php:7.4-cli
# change package source for aliyun
run cp /etc/apt/sources.list /etc/apt/sources.list.bak \
&& echo "deb http://mirrors.aliyun.com/debian buster main" > /etc/apt/sources.list \
&& echo "deb http://mirrors.aliyun.com/debian buster-updates main" >> /etc/apt/sources.list \
&& apt clean;
# update package
RUN apt-get update;
# install php gd ext
RUN apt-get install -y libwebp-dev libjpeg-dev libpng-dev libfreetype6-dev libjpeg62-turbo-dev\
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install -j$(nproc) gd
# install php ext
RUN apt-get install -y libzip-dev libzip4 \
&& pecl install redis-5.2.0 \
&& pecl install igbinary-3.1.2 \
&& pecl install zip-1.17.2 \
&& docker-php-ext-enable redis igbinary zip
# install php ext PDO
RUN docker-php-ext-install pdo pdo_mysql
# install wget
RUN apt-get install wget -y
# install composer
RUN cd /tmp \
&& wget https://mirrors.aliyun.com/composer/composer.phar \
&& mv composer.phar /usr/local/bin/composer \
&& chmod +x /usr/local/bin/composer \
&& composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/ \
&& composer self-update \
&& composer clear
WORKDIR /app
CMD ["php", "-S", "0.0.0.0:8081"]