-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
628 additions
and
429 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
FROM ghcr.io/mokeyjay/pixiv-widget-image:main | ||
|
||
COPY . /var/www/html | ||
COPY .docker/config.php /var/www/html/config.php | ||
COPY .docker/nginx-site.conf /etc/nginx/conf.d/default.conf | ||
COPY .docker/start.sh /root/start.sh | ||
|
||
COPY .docker/crontab /etc/cron.d/pixiv-cron-job | ||
RUN chmod 0644 /etc/cron.d/pixiv-cron-job && \ | ||
crontab /etc/cron.d/pixiv-cron-job | ||
|
||
ENV TZ=Asia/Shanghai | ||
|
||
LABEL Author="mokeyjay<[email protected]>" | ||
LABEL Version="2023.11.20" | ||
LABEL Description="Pixiv 每日排行榜小挂件" | ||
|
||
CMD cron && \ | ||
chmod +x /root/start.sh && \ | ||
/root/start.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
*/30 * * * * cd /var/www/html/ && /usr/local/bin/php index.php -j=refresh | ||
30 1 * * * cd /var/www/html/ && /usr/local/bin/php index.php -j=clear-log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
server { | ||
listen 80; | ||
listen [::]:80; | ||
server_name _; | ||
root /var/www/html; | ||
index index.php; | ||
|
||
error_page 500 502 503 504 /50x.html; | ||
location = /50x.html { | ||
root /usr/share/nginx/html; | ||
} | ||
|
||
location ~ /\. { | ||
deny all; | ||
} | ||
|
||
location / { | ||
try_files $uri $uri/ /index.php?$query_string; | ||
} | ||
|
||
location ~ \.php$ { | ||
fastcgi_pass 127.0.0.1:9000; | ||
fastcgi_index index.php; | ||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | ||
fastcgi_param PATH_INFO $fastcgi_path_info; | ||
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; | ||
include fastcgi_params; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/bin/bash | ||
|
||
echo '' > /etc/nginx/sites-enabled/default | ||
|
||
cd /var/www/html | ||
# 将环境变量保存起来,免得 crontab 读不到 | ||
env=("URL" "BACKGROUND_COLOR" "LIMIT" "SERVICE" "LOG_LEVEL" "PROXY" "CLEAR_OVERDUE" "COMPRESS" "IMAGE_HOSTING" "IMAGE_HOSTING_EXTEND_TIETUKU_TOKEN" "IMAGE_HOSTING_EXTEND_SMMS_TOKEN" "IMAGE_HOSTING_EXTEND_RIYUGO_URL" "IMAGE_HOSTING_EXTEND_RIYUGO_UPLOAD_PATH" "IMAGE_HOSTING_EXTEND_RIYUGO_UNIQUE_ID" "IMAGE_HOSTING_EXTEND_RIYUGO_TOKEN" "DISABLE_WEB_JOB" "HEADER_SCRIPT" "RANKING_TYPE") | ||
file=".env" | ||
> $file | ||
for var in "${env[@]}" | ||
do | ||
# 部分环境变量值含有空格、换行,得用双引号包起来,不然 source 时会报错 | ||
value="${!var}" | ||
value="${value//\"/\\\"}" | ||
echo "$var=\"$value\"" >> $file | ||
done | ||
|
||
chown -R www-data:www-data /var/www/html | ||
|
||
php-fpm -D | ||
nginx -g 'daemon off;' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
name: 推送开发用的 docker 镜像 | ||
on: | ||
push: | ||
branches: | ||
- 'develop' | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
IMAGE_NAME: ${{ github.repository }} | ||
|
||
jobs: | ||
push_to_registry: | ||
name: 构建并推送 | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
steps: | ||
# https://github.com/actions/checkout | ||
- name: 拉取代码 | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: develop | ||
|
||
# https://github.com/docker/login-action | ||
- name: 登录到 ghcr | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
# https://github.com/docker/metadata-action | ||
- name: 提取事件元数据 | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
|
||
# https://github.com/docker/setup-buildx-action | ||
- name: 使用 buildx 作为构建器 | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
# https://github.com/docker/build-push-action | ||
- name: 构建并推送 | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
file: .docker/Dockerfile | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
platforms: linux/amd64,linux/arm64 | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
use app\Libs\Config; | ||
use app\ImageHosting\ImageHosting; | ||
|
||
define("BASE_PATH", dirname(__FILE__, 2) . DIRECTORY_SEPARATOR); | ||
const APP_PATH = BASE_PATH . 'app' . DIRECTORY_SEPARATOR; | ||
const STORAGE_PATH = BASE_PATH . 'storage' . DIRECTORY_SEPARATOR; | ||
const IS_CLI = PHP_SAPI === 'cli'; | ||
const TEST_PATH = BASE_PATH . '.test' . DIRECTORY_SEPARATOR; | ||
|
||
require APP_PATH . 'autoload.php'; | ||
|
||
Config::init(); | ||
|
||
$skip = ['Riyugo', 'Smms', 'Tietuku', 'ImageHosting', 'Local', '.', '..']; | ||
foreach (scandir(APP_PATH . 'ImageHosting') as $fileName) { | ||
|
||
$className = pathinfo($fileName, PATHINFO_FILENAME); | ||
if (in_array($className, $skip) || empty($className)) { | ||
continue; | ||
} | ||
|
||
$imageHosting = ImageHosting::make($className); | ||
if ($url = $imageHosting->upload(TEST_PATH . 'pic.jpg')) { | ||
var_dump($className . '成功: ' . $url); | ||
} else { | ||
var_dump($className . '失败: ' . $url); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.