From f2373e9cbf238b2ff2ddc368528598887144931e Mon Sep 17 00:00:00 2001
From: Death-Satan <2771717608@qq.com>
Date: Tue, 23 Jan 2024 16:16:55 +0800
Subject: [PATCH 1/3] =?UTF-8?q?fix:=20dockerfile=20=E6=94=B9=E4=B8=BA?=
 =?UTF-8?q?=E7=94=A8=20hyperf=E5=AE=98=E6=96=B9=E9=95=9C=E5=83=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .github/workflows/build.yml |  12 ++++
 Dockerfile                  | 139 +++++++-----------------------------
 2 files changed, 37 insertions(+), 114 deletions(-)
 create mode 100644 .github/workflows/build.yml

diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
new file mode 100644
index 00000000..0ca82fad
--- /dev/null
+++ b/.github/workflows/build.yml
@@ -0,0 +1,12 @@
+name: Build Docker
+
+on: [push, pull_request]
+
+jobs:
+  build:
+    runs-on: ubuntu-latest
+    steps:
+      - name: Checkout code
+        uses: actions/checkout@v2
+      - name: Build
+        run: cp -rf .github/workflows/Dockerfile . && docker build -t hyperf .
diff --git a/Dockerfile b/Dockerfile
index ff259634..928dd1f6 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,121 +1,42 @@
-# Default Dockerfile
-
-ARG ALPINE_VERSION=3.15
-
-FROM alpine:$ALPINE_VERSION
-
+FROM hyperf/hyperf:8.1-alpine-v3.18-swoole
 LABEL maintainer="MineManage Developers <group@stye.cn>" version="1.0" license="MIT" app.name="MineManage"
 
-ARG ALPINE_VERSION=3.15
-
-# trust this project public key to trust the packages.
-ADD https://php.hernandev.com/key/php-alpine.rsa.pub /etc/apk/keys/php-alpine.rsa.pub
-
 ##
-# ---------- building ----------
+# ---------- env settings ----------
 ##
-RUN set -ex \
-    # change apk source repo
-    && echo "https://php.hernandev.com/v$ALPINE_VERSION/php-8.1" >> /etc/apk/repositories \
-    && echo "@php https://php.hernandev.com/v$ALPINE_VERSION/php-8.1" >> /etc/apk/repositories \
-    && apk update \
-    && apk add --no-cache \
-    # Install base packages ('ca-certificates' will install 'nghttp2-libs')
-    ca-certificates \
-    curl \
-    wget \
-    tar \
-    xz \
-    libressl \
-    tzdata \
-    pcre \
-    php8 \
-    php8-bcmath \
-    php8-curl \
-    php8-ctype \
-    php8-dom \
-    php8-gd \
-    php8-iconv \
-    php8-mbstring \
-    php8-mysqlnd \
-    php8-openssl \
-    php8-pdo \
-    php8-pdo_mysql \
-    php8-pdo_sqlite \
-    php8-phar \
-    php8-posix \
-    php8-redis \
-    php8-sockets \
-    php8-sodium \
-    php8-sysvshm \
-    php8-sysvmsg \
-    php8-sysvsem \
-    php8-zip \
-    php8-zlib \
-    php8-xml \
-    php8-xmlreader \
-    php8-pcntl \
-    php8-opcache \
-    && ln -sf /usr/bin/php8 /usr/bin/php \
-    && apk del --purge *-dev \
-    && rm -rf /var/cache/apk/* /tmp/* /usr/share/man /usr/share/php8 \
-    && php -v \
-    && php -m \
-    && echo -e "\033[42;37m Build Completed :).\033[0m\n"
+# --build-arg timezone=Asia/Shanghai
+ARG timezone
 
-ARG COMPOSER_VERSION=2.3.10
+ENV TIMEZONE=${timezone:-"Asia/Shanghai"} \
+    APP_ENV=prod \
+    SCAN_CACHEABLE=(true)
 
 # update
 RUN set -ex \
-    && apk update \
-    # for extension libaio linux-headers
-    && apk add --no-cache libstdc++ openssl git bash  php8-pear php8-dev autoconf pcre2-dev c-ares-dev zlib-dev re2c gcc g++ make \
-    && apk add --no-cache --virtual .build-deps $PHPIZE_DEPS libaio-dev openssl-dev curl-dev  \
-    # php extension:swoole
-    && ln -s /usr/bin/pecl8 /usr/local/bin/pecl \
-    && pecl channel-update pecl.php.net \
-    && pecl install --configureoptions 'enable-sockets="no" enable-openssl="yes" enable-http2="yes" enable-mysqlnd="no" enable-swoole-json="yes" enable-swoole-curl="yes" enable-cares="no"' swoole \
-    && {\
-    echo "memory_limit=1G"; \
-    echo "upload_max_filesize=128M"; \
-    echo "post_max_size=128M"; \
-    echo "memory_limit=1G"; \
-    echo "date.timezone=Asia/Shanghai"; \
-    } | tee /etc/php8/conf.d/00_default.ini \
-    && echo "opcache.enable_cli = 'On'" >> /etc/php8/conf.d/00_opcache.ini \
-    &&{ \
-    echo "extension=swoole.so";\
-    echo "swoole.use_shortname = 'Off'";\
-    } | tee  /etc/php8/conf.d/50_swoole.ini \
-    # install composer
-    && wget -nv -O /usr/local/bin/composer https://github.com/composer/composer/releases/download/${COMPOSER_VERSION}/composer.phar \
-    && chmod u+x /usr/local/bin/composer \
-    # php info
+    # show php version and extensions
     && php -v \
     && php -m \
     && php --ri swoole \
-    && php --ri Zend\ OPcache \
-    && composer --version \
+    #  ---------- some config ----------
+    && cd /etc/php* \
+    # - config PHP
+    && { \
+        echo "upload_max_filesize=128M"; \
+        echo "post_max_size=128M"; \
+        echo "memory_limit=1G"; \
+        echo "date.timezone=${TIMEZONE}"; \
+    } | tee conf.d/99_overrides.ini \
+    # - config timezone
+    && ln -sf /usr/share/zoneinfo/${TIMEZONE} /etc/localtime \
+    && echo "${TIMEZONE}" > /etc/timezone \
     # ---------- clear works ----------
-    && apk del .build-deps \
-    && rm -rf /var/cache/apk/* /tmp/* /usr/share/man /usr/local/bin/php* \
+    && rm -rf /var/cache/apk/* /tmp/* /usr/share/man \
     && echo -e "\033[42;37m Build Completed :).\033[0m\n"
 
-##
-# ---------- env settings ----------
-##
-# --build-arg timezone=Asia/Shanghai
-ARG timezone
-
-ENV TIMEZONE=${timezone:-"Asia/Shanghai"} \
-    #    APP_ENV=dev \
-    APP_SYSTEM_ENV=docker \
-    SCAN_CACHEABLE=(true)
-
 # update
 RUN set -ex \
     #  ---------- some config ----------
-    && cd /etc/php8 \
+    && cd /etc/php81 \
     # - config timezone
     && ln -sf /usr/share/zoneinfo/${TIMEZONE} /etc/localtime \
     && echo "${TIMEZONE}" > /etc/timezone \
@@ -123,13 +44,11 @@ RUN set -ex \
 
 RUN set -ex apk update \
     && apk add --no-cache libstdc++ openssl git bash autoconf pcre2-dev zlib-dev re2c gcc g++ make \
-    php8-pear php8-dev php8-tokenizer php8-fileinfo php8-simplexml php8-xmlwriter \
+    php81-pear php81-dev php81-tokenizer php81-fileinfo php81-simplexml php81-xmlwriter \
     && apk add --no-cache --virtual .build-deps $PHPIZE_DEPS zlib-dev libaio-dev openssl-dev curl-dev  c-ares-dev \
     && pecl channel-update pecl.php.net \
-    && ln -s /usr/bin/phpize8 /usr/local/bin/phpize \
-    && ln -s /usr/bin/php-config8 /usr/local/bin/php-config \
     && pecl install --configureoptions 'enable-reader="yes"' xlswriter \
-    &&  echo "extension=xlswriter.so" >> /etc/php8/conf.d/60-xlswriter.ini \
+    &&  echo "extension=xlswriter.so" >> /etc/php81/conf.d/60-xlswriter.ini \
     && php -m \
     && php -v \
     && php --ri swoole \
@@ -139,16 +58,8 @@ RUN set -ex apk update \
     && rm -rf /var/cache/apk/* /tmp/* /usr/share/man /usr/local/bin/php* \
     && echo -e "\033[42;37m Build Completed :).\033[0m\n"
 
-# fix aliyun oss wrong charset: https://github.com/aliyun/aliyun-oss-php-sdk/issues/101
-# https://github.com/docker-library/php/issues/240#issuecomment-762438977
-
-RUN apk --no-cache --allow-untrusted --repository http://dl-cdn.alpinelinux.org/alpine/edge/community/ add gnu-libiconv gnu-libiconv-dev \
-    # ---------- clear works ----------
-    && rm -rf /var/cache/apk/* /tmp/* /usr/share/man /usr/local/bin/php* \
-    && echo -e "\033[42;37m Build Completed :).\033[0m\n"
-
 ENV LD_PRELOAD /usr/lib/preloadable_libiconv.so
 
-WORKDIR /app-src
+WORKDIR /opt/www
 
 EXPOSE 9501 9502 9503

From d429f3e728e1ce41bd45765fee9ee8ef40821333 Mon Sep 17 00:00:00 2001
From: Death-Satan <2771717608@qq.com>
Date: Tue, 23 Jan 2024 16:24:42 +0800
Subject: [PATCH 2/3] fixed dockerfile

---
 Dockerfile | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/Dockerfile b/Dockerfile
index 928dd1f6..a51f5f2d 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -42,13 +42,14 @@ RUN set -ex \
     && echo "${TIMEZONE}" > /etc/timezone \
     && echo -e "\033[42;37m Build Completed :).\033[0m\n"
 
-RUN set -ex apk update \
+RUN set -ex && \
+    apk update \
     && apk add --no-cache libstdc++ openssl git bash autoconf pcre2-dev zlib-dev re2c gcc g++ make \
     php81-pear php81-dev php81-tokenizer php81-fileinfo php81-simplexml php81-xmlwriter \
     && apk add --no-cache --virtual .build-deps $PHPIZE_DEPS zlib-dev libaio-dev openssl-dev curl-dev  c-ares-dev \
     && pecl channel-update pecl.php.net \
     && pecl install --configureoptions 'enable-reader="yes"' xlswriter \
-    &&  echo "extension=xlswriter.so" >> /etc/php81/conf.d/60-xlswriter.ini \
+    && echo "extension=xlswriter.so" >> /etc/php81/conf.d/60-xlswriter.ini \
     && php -m \
     && php -v \
     && php --ri swoole \

From 3486e82f9e5f0fc40d81eb76a10c0fa23251e56b Mon Sep 17 00:00:00 2001
From: Death-Satan <2771717608@qq.com>
Date: Tue, 23 Jan 2024 16:26:41 +0800
Subject: [PATCH 3/3] feature workflows dockerfile

---
 .github/workflows/Dockerfile | 66 ++++++++++++++++++++++++++++++++++++
 1 file changed, 66 insertions(+)
 create mode 100644 .github/workflows/Dockerfile

diff --git a/.github/workflows/Dockerfile b/.github/workflows/Dockerfile
new file mode 100644
index 00000000..a51f5f2d
--- /dev/null
+++ b/.github/workflows/Dockerfile
@@ -0,0 +1,66 @@
+FROM hyperf/hyperf:8.1-alpine-v3.18-swoole
+LABEL maintainer="MineManage Developers <group@stye.cn>" version="1.0" license="MIT" app.name="MineManage"
+
+##
+# ---------- env settings ----------
+##
+# --build-arg timezone=Asia/Shanghai
+ARG timezone
+
+ENV TIMEZONE=${timezone:-"Asia/Shanghai"} \
+    APP_ENV=prod \
+    SCAN_CACHEABLE=(true)
+
+# update
+RUN set -ex \
+    # show php version and extensions
+    && php -v \
+    && php -m \
+    && php --ri swoole \
+    #  ---------- some config ----------
+    && cd /etc/php* \
+    # - config PHP
+    && { \
+        echo "upload_max_filesize=128M"; \
+        echo "post_max_size=128M"; \
+        echo "memory_limit=1G"; \
+        echo "date.timezone=${TIMEZONE}"; \
+    } | tee conf.d/99_overrides.ini \
+    # - config timezone
+    && ln -sf /usr/share/zoneinfo/${TIMEZONE} /etc/localtime \
+    && echo "${TIMEZONE}" > /etc/timezone \
+    # ---------- clear works ----------
+    && rm -rf /var/cache/apk/* /tmp/* /usr/share/man \
+    && echo -e "\033[42;37m Build Completed :).\033[0m\n"
+
+# update
+RUN set -ex \
+    #  ---------- some config ----------
+    && cd /etc/php81 \
+    # - config timezone
+    && ln -sf /usr/share/zoneinfo/${TIMEZONE} /etc/localtime \
+    && echo "${TIMEZONE}" > /etc/timezone \
+    && echo -e "\033[42;37m Build Completed :).\033[0m\n"
+
+RUN set -ex && \
+    apk update \
+    && apk add --no-cache libstdc++ openssl git bash autoconf pcre2-dev zlib-dev re2c gcc g++ make \
+    php81-pear php81-dev php81-tokenizer php81-fileinfo php81-simplexml php81-xmlwriter \
+    && apk add --no-cache --virtual .build-deps $PHPIZE_DEPS zlib-dev libaio-dev openssl-dev curl-dev  c-ares-dev \
+    && pecl channel-update pecl.php.net \
+    && pecl install --configureoptions 'enable-reader="yes"' xlswriter \
+    && echo "extension=xlswriter.so" >> /etc/php81/conf.d/60-xlswriter.ini \
+    && php -m \
+    && php -v \
+    && php --ri swoole \
+    && mkdir -p /app-src \
+    # ---------- clear works ----------
+    && apk del .build-deps \
+    && rm -rf /var/cache/apk/* /tmp/* /usr/share/man /usr/local/bin/php* \
+    && echo -e "\033[42;37m Build Completed :).\033[0m\n"
+
+ENV LD_PRELOAD /usr/lib/preloadable_libiconv.so
+
+WORKDIR /opt/www
+
+EXPOSE 9501 9502 9503