commit 4feed69c3d8b1008f4b6e1aaaadeeca4253d8bcd Author: kriss <462679766@qq.com> Date: Wed May 25 18:01:03 2022 +0800 feature: base Dockerfile diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b915ba0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.idea +workspace \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0b6c800 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,51 @@ +ARG PHP_CLI_VERSION=7.4.29-cli-alpine +ARG PHP_EXTENSION_INSTALL_VERSION=1.5.17 +ARG COMPOSER_VERSION=2.3.5 + +FROM mlocati/php-extension-installer:$PHP_EXTENSION_INSTALL_VERSION AS php-extension-installer + +# https://hub.docker.com/_/php +FROM php:$PHP_CLI_VERSION + +# 系统依赖安装 +RUN apk add --no-cache supervisor + +# PHP 扩展安装 +# install-php-extensions https://github.com/mlocati/docker-php-extension-installer +COPY --from=php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/ +# https://github.com/mlocati/docker-php-extension-installer#supported-php-extensions +RUN install-php-extensions \ + bcmath \ + event \ + gd \ + mysqli \ + pdo_mysql \ + opcache \ + pcntl \ + redis \ + sockets \ + zip \ + @composer-$COMPOSER_VERSION + +# 展示各组件 +RUN php -v +RUN php -m +RUN composer +RUN install-php-extensions + +# 设置配置文件 +# php +RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" +COPY config/php.ini "$PHP_INI_DIR/conf.d/app.ini" +# supervisor +COPY config/supervisord.conf /etc/supervisor/conf.d/supervisord.conf + +# 设置项目目录 +RUN mkdir -p /app +WORKDIR /app + +# 暴露端口 +EXPOSE 8787 + +# 启动脚本 +CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"] diff --git a/config/php.ini b/config/php.ini new file mode 100644 index 0000000..a8ba23a --- /dev/null +++ b/config/php.ini @@ -0,0 +1,3 @@ +[opcache] +opcache.enable=1 +opcache.enable_cli=1 diff --git a/config/supervisord.conf b/config/supervisord.conf new file mode 100644 index 0000000..9ac3095 --- /dev/null +++ b/config/supervisord.conf @@ -0,0 +1,12 @@ +[supervisord] +nodaemon=true +user=root + +[program:webman] +command=php /app/start.php start +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 +autorestart=true +startretries=10