feature: base Dockerfile

This commit is contained in:
kriss 2022-05-25 18:01:03 +08:00
commit 4feed69c3d
4 changed files with 68 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
.idea
workspace

51
Dockerfile Normal file
View File

@ -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"]

3
config/php.ini Normal file
View File

@ -0,0 +1,3 @@
[opcache]
opcache.enable=1
opcache.enable_cli=1

12
config/supervisord.conf Normal file
View File

@ -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