ngbs 2 years ago
parent
commit
96a436d6d6

+ 60 - 0
.github/workflows/build-chinadns-ng.yml

@@ -0,0 +1,60 @@
+name: Build chinadns-ng
+
+on:
+  # UTC +8 [https://crontab.guru/]
+  schedule:
+    - cron: "0 20 15,30 * *"
+  workflow_dispatch:
+
+jobs:
+  build-chinadns-ng:
+    runs-on: ubuntu-latest
+    steps:
+      - name: Set Variables
+        run: |
+          echo "CHINADNS_NG_VERSION=$(curl -fsSL https://api.github.com/repos/zfl9/chinadns-ng/releases/latest | grep '"tag_name":' | head -n 1 | awk -F ":" '{print $2}' | sed 's/\"//g;s/v//g;s/,//g;s/ //g')" >> $GITHUB_ENV
+        shell: bash
+
+      - name: Check Out Repo
+        uses: actions/checkout@v3
+
+      - name: Set up Docker Buildx
+        uses: docker/setup-buildx-action@v2
+        id: buildx
+
+      - name: Cache Docker layers
+        uses: actions/cache@v3
+        with:
+          path: /tmp/.buildx-cache
+          key: ${{ runner.os }}-buildx-${{ github.sha }}
+          restore-keys: |
+            ${{ runner.os }}-buildx-
+
+      - name: Login to Docker Hub
+        uses: docker/login-action@v2
+        with:
+          username: ${{ secrets.DOCKER_HUB_USERNAME }}
+          password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
+
+      - name: Build and push Docker images
+        uses: docker/build-push-action@v3
+        id: docker_build_chinadns_ng
+        with:
+          context: ./chinadns-ng
+          file: ./chinadns-ng/Dockerfile
+          push: true
+          tags: |
+            ${{ secrets.DOCKER_HUB_USERNAME }}/chinadns-ng:latest
+            ${{ secrets.DOCKER_HUB_USERNAME }}/chinadns-ng:${{ env.CHINADNS_NG_VERSION }}
+          builder: ${{ steps.buildx.outputs.name }}
+          cache-from: type=local,src=/tmp/.buildx-cache
+          cache-to: type=local,dest=/tmp/.buildx-cache-new
+
+      - name: Move cache
+        run: |
+          rm -rf /tmp/.buildx-cache
+          mv /tmp/.buildx-cache-new /tmp/.buildx-cache
+
+      - name: Image digest
+        run: |
+          echo ${{ steps.docker_build_chinadns_ng.outputs.digest }}

+ 79 - 0
v2board/Dockerfile

@@ -0,0 +1,79 @@
+# syntax=docker/dockerfile:1
+
+# ADD file:5d673d25da3a14ce1f6cf66e4c7fd4f4b85a3759a9d93efb3fd9ff852b5b56e4 in /
+# CMD ["/bin/sh"]
+# RUN /bin/sh -c apk update # buildkit
+# RUN /bin/sh -c apk add --no-cache bash php7 curl supervisor redis     php7-zlib php7-xml php7-phar php7-intl php7-dom php7-xmlreader php7-ctype php7-session     php7-mbstring php7-tokenizer php7-gd php7-redis php7-bcmath     php7-iconv php7-pdo php7-posix php7-gettext php7-simplexml php7-sodium php7-sysvsem     php7-fpm php7-mysqli php7-json php7-openssl php7-curl php7-sockets php7-zip php7-pdo_mysql     php7-xmlwriter php7-opcache php7-gmp php7-pdo_sqlite php7-sqlite3 php7-pcntl php7-fileinfo     git mailcap # buildkit
+# RUN /bin/sh -c mkdir /www # buildkit
+# RUN /bin/sh -c mkdir /wwwlogs # buildkit
+# RUN /bin/sh -c mkdir /rdb # buildkit
+# RUN /bin/sh -c mkdir -p /run/php # buildkit
+# RUN /bin/sh -c mkdir -p /run/caddy # buildkit
+# RUN /bin/sh -c mkdir -p /run/supervisor # buildkit
+# COPY config/php-fpm.conf /etc/php7/php-fpm.d/www.conf # buildkit
+# COPY config/supervisord.conf /etc/supervisor/conf.d/supervisord.conf # buildkit
+# COPY bin/caddy /usr/local/bin/caddy # buildkit
+# WORKDIR /www
+# EXPOSE map[443/tcp:{} 80/tcp:{}]
+# CMD ["/usr/bin/supervisord" "-c" "/etc/supervisor/conf.d/supervisord.conf"]
+FROM alpine
+
+RUN apk update && \
+    apk add --no-cache \
+    bash \
+    php7 \
+    curl \
+    supervisor \
+    redis \
+    php7-zlib \
+    php7-xml \
+    php7-phar \
+    php7-intl \
+    php7-dom \
+    php7-xmlreader \
+    php7-ctype \
+    php7-session \
+    php7-mbstring \
+    php7-tokenizer \
+    php7-gd php7-redis \
+    php7-bcmath \
+    php7-iconv \
+    php7-pdo \
+    php7-posix \
+    php7-gettext \
+    php7-simplexml \
+    php7-sodium \
+    php7-sysvsem \
+    php7-fpm \
+    php7-mysqli \
+    php7-json \
+    php7-openssl \
+    php7-curl \
+    php7-sockets \
+    php7-zip \
+    php7-pdo_mysql \
+    php7-xmlwriter \
+    php7-opcache \
+    php7-gmp \
+    php7-pdo_sqlite \
+    php7-sqlite3 \
+    php7-pcntl \
+    php7-fileinfo \
+    git \
+    mailcap && \
+    mkdir /www && \
+    mkdir /wwwlogs && \
+    mkdir /rdb && \
+    mkdir -p /run/php && \
+    mkdir -p /run/caddy && \
+    mkdir -p /run/supervisor
+
+COPY config/php-fpm.conf /etc/php7/php-fpm.d/www.conf
+COPY config/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
+COPY bin/caddy /usr/local/bin/caddy
+
+WORKDIR /www
+
+EXPOSE map[443/tcp:{} 80/tcp:{}]
+
+CMD ["/usr/bin/supervisord" "-c" "/etc/supervisor/conf.d/supervisord.conf"]

+ 0 - 0
v2board/bin/caddy


+ 19 - 0
v2board/config/php-fpm.conf

@@ -0,0 +1,19 @@
+[global]
+pid = /tmp/php-fpm.pid
+error_log = /wwwlogs/php-fpm.log
+log_level = notice
+
+[www]
+listen = /tmp/php-cgi.sock
+listen.backlog = -1
+user = root
+group = root
+pm = dynamic
+pm.status_path = /phpfpm_status
+pm.max_children = 300
+pm.start_servers = 20
+pm.min_spare_servers = 20
+pm.max_spare_servers = 300
+request_terminate_timeout = 100
+request_slowlog_timeout = 30
+slowlog = /wwwlogs/php-slow.log

+ 50 - 0
v2board/config/supervisord.conf

@@ -0,0 +1,50 @@
+[supervisord]
+nodaemon=true
+logfile=/dev/null
+logfile_maxbytes=0
+pidfile=/run/supervisord.pid
+minfds=50000
+minprocs=50000
+
+[program:php-fpm]
+command=php-fpm7 -RF
+stdout_logfile=/dev/stdout
+stdout_logfile_maxbytes=0
+stderr_logfile=/dev/stderr
+stderr_logfile_maxbytes=0
+autostart=true
+autorestart=true
+startretries=10
+
+[program:caddy]
+command=caddy -conf /run/caddy/caddy.conf -agree=true -log-timestamps=false
+stdout_logfile=/dev/stdout
+stdout_logfile_maxbytes=0
+stderr_logfile=/dev/stderr
+stderr_logfile_maxbytes=0
+autostart=true
+autorestart=true
+startretries=10
+
+[program:redis]
+command=redis-server --save "" --appendonly no
+stdout_logfile=/dev/stdout
+stdout_logfile_maxbytes=0
+stderr_logfile=/dev/stderr
+stderr_logfile_maxbytes=0
+autostart=true
+autorestart=true
+startretries=10
+
+[program:cron]
+command=crond -f -l 8
+stdout_logfile=/dev/stdout
+stdout_logfile_maxbytes=0
+stderr_logfile=/dev/stderr
+stderr_logfile_maxbytes=0
+autostart=true
+autorestart=true
+startretries=10
+
+[include]
+files = /run/supervisor/supervisord.conf