From 949d9632368e4b0a67c54115b6604cccfc9b61db Mon Sep 17 00:00:00 2001 From: luorijun Date: Thu, 26 Feb 2026 15:05:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96=E4=BB=93=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.example | 4 ++++ .gitignore | 3 +++ README.md | 15 +++++++++++++ docker-compose.yaml | 41 +++++++++++++++++++++++++++++++++++ nginx/configs/byjd.conf | 19 ++++++++++++++++ nginx/configs/phpmyadmin.conf | 26 ++++++++++++++++++++++ php/Dockerfile | 3 +++ 7 files changed, 111 insertions(+) create mode 100644 .env.example create mode 100644 .gitignore create mode 100644 README.md create mode 100644 docker-compose.yaml create mode 100644 nginx/configs/byjd.conf create mode 100644 nginx/configs/phpmyadmin.conf create mode 100644 php/Dockerfile diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..bf2c690 --- /dev/null +++ b/.env.example @@ -0,0 +1,4 @@ +DB_HOST=mariadb +DB_PORT=3306 +DB_USERNAME=root +DB_PASSWORD=byjdros916... diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1135ada --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.env +mysql/ +byjd/ diff --git a/README.md b/README.md new file mode 100644 index 0000000..e9748bc --- /dev/null +++ b/README.md @@ -0,0 +1,15 @@ +极光节点轮换项目部署脚本 + +## 使用方式 + +1. 拉取本项目 + +2. 拉取或手动下载 byjd 项目到本项目的根目录 + +3. 运行 `docker compose up -d` + +## 注意事项 + +由于 php 官方镜像不包含必需的扩展,启动项目时会自动构建自定义 php 镜像,下载扩展和构建的速度可能非常慢。 + +可以考虑预构建此镜像到代码仓库的注册表,以便以后直接使用。 diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..64c765e --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,41 @@ +services: + + mariadb: + image: mariadb:10.11 + environment: + MYSQL_ROOT_PASSWORD: ${DB_PASSWORD} + MYSQL_DATABASE: ${DB_NAME} + volumes: + - ./mysql/data:/var/lib/mysql + ports: + - "127.0.0.1:3306:3306" + restart: unless-stopped + + phpmyadmin: + image: phpmyadmin:latest + environment: + PMA_HOST: mariadb + PMA_PORT: 3306 + depends_on: + - mariadb + restart: unless-stopped + + php-fpm: + build: + context: ./php + dockerfile: Dockerfile + volumes: + - ./byjd:/var/www/html/byjd + depends_on: + - mariadb + restart: unless-stopped + + nginx: + image: nginx:alpine + volumes: + - ./nginx/configs:/etc/nginx/conf.d:ro + - ./byjd:/var/www/html/byjd:ro + ports: + - "18701:18701" + - "18702:18702" + restart: unless-stopped diff --git a/nginx/configs/byjd.conf b/nginx/configs/byjd.conf new file mode 100644 index 0000000..c9b57c1 --- /dev/null +++ b/nginx/configs/byjd.conf @@ -0,0 +1,19 @@ +server{ + listen 18702; + server_name "127.0.0.1"; + index index.php; + root /var/www/html/byjd; + location ~ \.php(.*)$ { + fastcgi_pass php-fpm:9000; + include fastcgi_params; + fastcgi_param PATH_INFO $1; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + } + location / { + if (!-e $request_filename) { + rewrite ^/index.php(.*)$ /index.php?s=$1 last; + rewrite ^(.*)$ /index.php?s=$1 last; + break; + } + } +} \ No newline at end of file diff --git a/nginx/configs/phpmyadmin.conf b/nginx/configs/phpmyadmin.conf new file mode 100644 index 0000000..5c38b25 --- /dev/null +++ b/nginx/configs/phpmyadmin.conf @@ -0,0 +1,26 @@ +server{ + listen 18701; + server_name "127.0.0.1"; + # index index.php; + # root /var/www/html/phpMyAdmin; + # location ~ \.php(.*)$ { + # fastcgi_pass unix:/var/run/php/php8.3-fpm.sock; + # include fastcgi_params; + # fastcgi_param PATH_INFO $1; + # fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + # } + # location / { + # if (!-e $request_filename) { + # rewrite ^/index.php(.*)$ /index.php?s=$1 last; + # rewrite ^(.*)$ /index.php?s=$1 last; + # break; + # } + # } + + location / { + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_pass http://phpmyadmin:80; + } +} \ No newline at end of file diff --git a/php/Dockerfile b/php/Dockerfile new file mode 100644 index 0000000..9b3db8a --- /dev/null +++ b/php/Dockerfile @@ -0,0 +1,3 @@ +FROM php:8.3-fpm-alpine +RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories +RUN docker-php-ext-install pdo_mysql mysqli \ No newline at end of file