-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
91 changed files
with
29,043 additions
and
47 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
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,29 @@ | ||
FROM php:8.1.9-fpm-alpine3.16 | ||
|
||
LABEL author="mybsdc <mybsdc@gmail.com>" \ | ||
maintainer="luolongfei <luolongf@gmail.com>" | ||
|
||
ENV TZ Asia/Shanghai | ||
ENV IS_KOYEB 1 | ||
|
||
WORKDIR /app | ||
|
||
COPY . ./ | ||
|
||
COPY ./koyeb/nginx.template.conf ./ | ||
COPY ./koyeb/web ./web/ | ||
|
||
RUN set -eux \ | ||
&& apk update \ | ||
&& apk add --no-cache tzdata bash nginx gettext \ | ||
&& mkdir -p /app/logs \ | ||
&& chmod -Rf 666 /app/logs | ||
|
||
COPY ./koyeb/startup.sh / | ||
RUN chmod +x /startup.sh | ||
|
||
EXPOSE 80 443 2019 | ||
|
||
# https://www.koyeb.com/docs/deploy-to-koyeb-button | ||
# https://www.koyeb.com/docs/quickstart/deploy-a-docker-application | ||
CMD ["/bin/bash", "-c", "/startup.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 |
---|---|---|
|
@@ -19,7 +19,7 @@ | |
|
||
class FreeNom extends Base | ||
{ | ||
const VERSION = 'v0.5'; | ||
const VERSION = 'v0.5.1'; | ||
|
||
const TIMEOUT = 33; | ||
|
||
|
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
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
Binary file not shown.
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,34 @@ | ||
worker_processes auto; | ||
|
||
error_log stderr; | ||
pid /var/run/nginx.pid; | ||
|
||
events { | ||
worker_connections 1024; | ||
} | ||
|
||
http { | ||
include /etc/nginx/mime.types; | ||
access_log /dev/stdout; | ||
server_tokens off; | ||
|
||
server { | ||
listen 80; | ||
|
||
root /app/web; | ||
|
||
location / { | ||
index index.php index.html index.htm; | ||
} | ||
|
||
location ~ \.php$ { | ||
try_files $uri =404; | ||
fastcgi_split_path_info ^(.+?\.php)(/.*)$; | ||
fastcgi_pass 127.0.0.1:9000; | ||
fastcgi_index index.php; | ||
include /etc/nginx/fastcgi_params; | ||
fastcgi_param SCRIPT_FILENAME /app/web/$fastcgi_script_name; | ||
fastcgi_param PATH_INFO $fastcgi_path_info; | ||
} | ||
} | ||
} |
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,57 @@ | ||
#!/usr/bin/env bash | ||
|
||
#===================================================================# | ||
# Author: luolongfei <luolongf@gmail.com> # | ||
# Intro: https://github.com/luolongfei/freenom # | ||
#===================================================================# | ||
|
||
set -e | ||
|
||
# 自定义颜色变量 | ||
red='\033[0;31m' | ||
green='\033[0;32m' | ||
yellow='\033[0;33m' | ||
plain='\033[0m' | ||
|
||
echo -e "[${green}Info${plain}] 项目地址:https://github.com/luolongfei/freenom" | ||
echo -e "[${green}Info${plain}] 洛阳亲友如相问,一片冰心在玉壶。 by luolongfei" | ||
|
||
# PHP 命令 | ||
PHP_COMMAND='/usr/local/bin/php /app/run > /app/logs/freenom_cron.log 2>&1' | ||
|
||
# 指定脚本执行时间 | ||
if [ -z "${RUN_AT}" ]; then | ||
minute=$( shuf -i 0-59 -n 1 ) | ||
hour=$( shuf -i 6-23 -n 1 ) | ||
CRON_COMMAND="${minute} ${hour} * * * ${PHP_COMMAND}" | ||
echo -e "[${green}Info${plain}] 已自动指定执行时间,续期任务将在北京时间每天 「${hour}:${minute}」 执行" | ||
echo -e "[${green}Info${plain}] 在没有手动指定 RUN_AT 环境变量的情况下,每次重建容器,程序都会重新在 06 ~ 23 点全时段中自动随机指定一个执行时间,目的是防止很多人在同一个时间点执行任务导致 Freenom 无法稳定提供服务" | ||
else | ||
if [[ "${RUN_AT}" =~ ^([01][0-9]|2[0-3]|[0-9]):([0-5][0-9]|[0-9])$ ]]; then | ||
minute=$( echo ${RUN_AT} | egrep -o '([0-5][0-9]|[0-9])$' ) | ||
hour=$( echo ${RUN_AT} | egrep -o '^([01][0-9]|2[0-3]|[0-9])' ) | ||
CRON_COMMAND="${minute} ${hour} * * * ${PHP_COMMAND}" | ||
echo -e "[${green}Info${plain}] 你已指定执行时间,续期任务将在北京时间每天 「${hour}:${minute}」 执行" | ||
elif [ "$(php /app/run -c=Cron -m=verify --cron_exp="${RUN_AT}")" -eq 1 ]; then | ||
CRON_COMMAND="${RUN_AT} ${PHP_COMMAND}" | ||
echo -e "[${green}Info${plain}] 你自定义的 Cron 表达式为「${RUN_AT}」,已通过正则验证" | ||
else | ||
echo -e "[${red}Error${plain}] RUN_AT 的值无效" | ||
echo -e "${yellow}请输入一个有效的时间指令,其值可以为时分格式,如:11:24,也可以为 Cron 表达式,如:'24 11 * * *',甚至可以不输入,让程序自动生成,推荐采用自动生成的方式,不建议手动指定此环境变量" | ||
exit 1 | ||
fi | ||
fi | ||
|
||
# 添加计划任务 | ||
sed -i '/freenom_cron/'d /etc/crontabs/root | ||
echo -e "${CRON_COMMAND}" >> /etc/crontabs/root | ||
echo -e "[${green}Info${plain}] 计划任务:${CRON_COMMAND}" | ||
|
||
# 启动 Cron | ||
/usr/sbin/crond | ||
|
||
# nginx 配置 | ||
cp /app/nginx.template.conf /app/nginx.conf | ||
|
||
# 启动 php-fpm 与 nginx | ||
php-fpm -D -R; nginx -c /app/nginx.conf -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,5 @@ | ||
{ | ||
"require": { | ||
"sensiolabs/ansi-to-html": "^1.2" | ||
} | ||
} |
Oops, something went wrong.