mirror of
https://github.com/whyour/qinglong.git
synced 2025-07-27 14:46:06 +08:00
增加 debian-slim 基础镜像
This commit is contained in:
parent
e5d231ba3f
commit
07ea7baf9e
7
.github/workflows/build_docker_image.yml
vendored
7
.github/workflows/build_docker_image.yml
vendored
|
@ -5,6 +5,7 @@ on:
|
||||||
branches:
|
branches:
|
||||||
- 'master'
|
- 'master'
|
||||||
- 'develop'
|
- 'develop'
|
||||||
|
- 'debian'
|
||||||
tags:
|
tags:
|
||||||
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
|
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
|
||||||
schedule:
|
schedule:
|
||||||
|
@ -157,14 +158,14 @@ jobs:
|
||||||
QL_BRANCH=${{ github.ref_name }}
|
QL_BRANCH=${{ github.ref_name }}
|
||||||
SOURCE_COMMIT=${{ github.sha }}
|
SOURCE_COMMIT=${{ github.sha }}
|
||||||
network: host
|
network: host
|
||||||
platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x,linux/386
|
platforms: linux/amd64,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x
|
||||||
context: .
|
context: .
|
||||||
file: ./docker/Dockerfile
|
file: ./docker/Dockerfile
|
||||||
push: true
|
push: true
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
cache-from: type=registry,ref=whyour/qinglong:cache
|
cache-from: type=registry,ref=whyour/qinglong:cache-debian
|
||||||
cache-to: type=registry,ref=whyour/qinglong:cache,mode=max
|
cache-to: type=registry,ref=whyour/qinglong:cache-debian,mode=max
|
||||||
|
|
||||||
- name: Image digest
|
- name: Image digest
|
||||||
run: echo ${{ steps.docker_build.outputs.digest }}
|
run: echo ${{ steps.docker_build.outputs.digest }}
|
||||||
|
|
|
@ -43,7 +43,7 @@ export enum DependenceTypes {
|
||||||
export enum InstallDependenceCommandTypes {
|
export enum InstallDependenceCommandTypes {
|
||||||
'pnpm add -g',
|
'pnpm add -g',
|
||||||
'pip3 install --disable-pip-version-check --root-user-action=ignore',
|
'pip3 install --disable-pip-version-check --root-user-action=ignore',
|
||||||
'apk add --no-check-certificate',
|
'apt install -y',
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum GetDependenceCommandTypes {
|
export enum GetDependenceCommandTypes {
|
||||||
|
@ -61,7 +61,7 @@ export enum versionDependenceCommandTypes {
|
||||||
export enum unInstallDependenceCommandTypes {
|
export enum unInstallDependenceCommandTypes {
|
||||||
'pnpm remove -g',
|
'pnpm remove -g',
|
||||||
'pip3 uninstall --disable-pip-version-check --root-user-action=ignore -y',
|
'pip3 uninstall --disable-pip-version-check --root-user-action=ignore -y',
|
||||||
'apk del',
|
'apt remove',
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DependenceInstance
|
export interface DependenceInstance
|
||||||
|
|
|
@ -30,11 +30,9 @@ export default class CronService {
|
||||||
const tab = new Crontab(payload);
|
const tab = new Crontab(payload);
|
||||||
tab.saved = false;
|
tab.saved = false;
|
||||||
const doc = await this.insert(tab);
|
const doc = await this.insert(tab);
|
||||||
if (this.isSixCron(doc)) {
|
await cronClient.addCron([
|
||||||
await cronClient.addCron([
|
{ id: String(doc.id), schedule: doc.schedule!, command: doc.command },
|
||||||
{ id: String(doc.id), schedule: doc.schedule!, command: doc.command },
|
]);
|
||||||
]);
|
|
||||||
}
|
|
||||||
await this.set_crontab();
|
await this.set_crontab();
|
||||||
return doc;
|
return doc;
|
||||||
}
|
}
|
||||||
|
@ -51,18 +49,15 @@ export default class CronService {
|
||||||
if (doc.isDisabled === 1) {
|
if (doc.isDisabled === 1) {
|
||||||
return newDoc;
|
return newDoc;
|
||||||
}
|
}
|
||||||
if (this.isSixCron(doc)) {
|
|
||||||
await cronClient.delCron([String(newDoc.id)]);
|
await cronClient.delCron([String(newDoc.id)]);
|
||||||
}
|
await cronClient.addCron([
|
||||||
if (this.isSixCron(newDoc)) {
|
{
|
||||||
await cronClient.addCron([
|
id: String(newDoc.id),
|
||||||
{
|
schedule: newDoc.schedule!,
|
||||||
id: String(newDoc.id),
|
command: newDoc.command,
|
||||||
schedule: newDoc.schedule!,
|
},
|
||||||
command: newDoc.command,
|
]);
|
||||||
},
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
await this.set_crontab();
|
await this.set_crontab();
|
||||||
return newDoc;
|
return newDoc;
|
||||||
}
|
}
|
||||||
|
@ -454,14 +449,12 @@ export default class CronService {
|
||||||
public async enabled(ids: number[]) {
|
public async enabled(ids: number[]) {
|
||||||
await CrontabModel.update({ isDisabled: 0 }, { where: { id: ids } });
|
await CrontabModel.update({ isDisabled: 0 }, { where: { id: ids } });
|
||||||
const docs = await CrontabModel.findAll({ where: { id: ids } });
|
const docs = await CrontabModel.findAll({ where: { id: ids } });
|
||||||
const sixCron = docs
|
const crons = docs.map((doc) => ({
|
||||||
.filter((x) => this.isSixCron(x))
|
id: String(doc.id),
|
||||||
.map((doc) => ({
|
schedule: doc.schedule!,
|
||||||
id: String(doc.id),
|
command: doc.command,
|
||||||
schedule: doc.schedule!,
|
}));
|
||||||
command: doc.command,
|
await cronClient.addCron(crons);
|
||||||
}));
|
|
||||||
await cronClient.addCron(sixCron);
|
|
||||||
await this.set_crontab();
|
await this.set_crontab();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -533,7 +526,6 @@ export default class CronService {
|
||||||
this.logger.silly(crontab_string);
|
this.logger.silly(crontab_string);
|
||||||
fs.writeFileSync(config.crontabFile, crontab_string);
|
fs.writeFileSync(config.crontabFile, crontab_string);
|
||||||
|
|
||||||
execSync(`crontab ${config.crontabFile}`);
|
|
||||||
await CrontabModel.update({ saved: true }, { where: {} });
|
await CrontabModel.update({ saved: true }, { where: {} });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -576,7 +568,7 @@ export default class CronService {
|
||||||
this.set_crontab(tabs);
|
this.set_crontab(tabs);
|
||||||
|
|
||||||
const sixCron = tabs.data
|
const sixCron = tabs.data
|
||||||
.filter((x) => this.isSixCron(x) && x.isDisabled !== 1)
|
.filter((x) => x.isDisabled !== 1)
|
||||||
.map((doc) => ({
|
.map((doc) => ({
|
||||||
id: String(doc.id),
|
id: String(doc.id),
|
||||||
schedule: doc.schedule!,
|
schedule: doc.schedule!,
|
||||||
|
|
|
@ -1,13 +1,18 @@
|
||||||
FROM python:3.10-alpine as builder
|
FROM node:18-slim as nodebuilder
|
||||||
COPY package.json .npmrc pnpm-lock.yaml /tmp/build/
|
|
||||||
RUN set -x \
|
|
||||||
&& apk update \
|
|
||||||
&& apk add nodejs npm git \
|
|
||||||
&& npm i -g pnpm@8.3.1 \
|
|
||||||
&& cd /tmp/build \
|
|
||||||
&& pnpm --registry https://registry.npmmirror.com install --prod
|
|
||||||
|
|
||||||
FROM python:3.10-alpine
|
FROM python:3.10-slim as builder
|
||||||
|
COPY package.json .npmrc pnpm-lock.yaml /tmp/build/
|
||||||
|
COPY --from=nodebuilder /usr/local/bin/node /usr/local/bin/
|
||||||
|
COPY --from=nodebuilder /usr/local/lib/node_modules/. /usr/local/lib/node_modules/
|
||||||
|
RUN set -x && \
|
||||||
|
ln -s /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm && \
|
||||||
|
apt update && \
|
||||||
|
apt install --no-install-recommends -y libatomic1 && \
|
||||||
|
npm i -g pnpm@8.3.1 && \
|
||||||
|
cd /tmp/build && \
|
||||||
|
pnpm --registry https://registry.npmmirror.com install --prod
|
||||||
|
|
||||||
|
FROM python:3.10-slim
|
||||||
|
|
||||||
ARG QL_MAINTAINER="whyour"
|
ARG QL_MAINTAINER="whyour"
|
||||||
LABEL maintainer="${QL_MAINTAINER}"
|
LABEL maintainer="${QL_MAINTAINER}"
|
||||||
|
@ -23,49 +28,45 @@ ENV PNPM_HOME=/root/.local/share/pnpm \
|
||||||
QL_DIR=/ql \
|
QL_DIR=/ql \
|
||||||
QL_BRANCH=${QL_BRANCH}
|
QL_BRANCH=${QL_BRANCH}
|
||||||
|
|
||||||
RUN set -x \
|
COPY --from=nodebuilder /usr/local/bin/node /usr/local/bin/
|
||||||
&& apk update -f \
|
COPY --from=nodebuilder /usr/local/lib/node_modules/. /usr/local/lib/node_modules/
|
||||||
&& apk upgrade \
|
|
||||||
&& apk --no-cache add -f bash \
|
RUN set -x && \
|
||||||
coreutils \
|
ln -s /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm && \
|
||||||
git \
|
apt update && \
|
||||||
|
apt upgrade -y && \
|
||||||
|
apt install --no-install-recommends -y git \
|
||||||
curl \
|
curl \
|
||||||
wget \
|
wget \
|
||||||
tzdata \
|
|
||||||
perl \
|
|
||||||
openssl \
|
|
||||||
nginx \
|
nginx \
|
||||||
nodejs \
|
|
||||||
jq \
|
jq \
|
||||||
openssh \
|
|
||||||
procps \
|
procps \
|
||||||
netcat-openbsd \
|
netcat \
|
||||||
npm \
|
libatomic1 && \
|
||||||
&& rm -rf /var/cache/apk/* \
|
apt clean && \
|
||||||
&& apk update \
|
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
|
||||||
&& ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
|
echo "Asia/Shanghai" >/etc/timezone && \
|
||||||
&& echo "Asia/Shanghai" > /etc/timezone \
|
git config --global user.email "qinglong@@users.noreply.github.com" && \
|
||||||
&& git config --global user.email "qinglong@@users.noreply.github.com" \
|
git config --global user.name "qinglong" && \
|
||||||
&& git config --global user.name "qinglong" \
|
git config --global http.postBuffer 524288000 && \
|
||||||
&& git config --global http.postBuffer 524288000 \
|
npm install -g pnpm@8.3.1 && \
|
||||||
&& npm install -g pnpm@8.3.1 \
|
cd && pnpm config set registry https://registry.npmmirror.com && \
|
||||||
&& cd && pnpm config set registry https://registry.npmmirror.com \
|
pnpm add -g pm2 tsx && \
|
||||||
&& pnpm add -g pm2 tsx \
|
rm -rf /root/.pnpm-store && \
|
||||||
&& rm -rf /root/.pnpm-store \
|
rm -rf /root/.local/share/pnpm/store && \
|
||||||
&& rm -rf /root/.local/share/pnpm/store \
|
rm -rf /root/.cache && \
|
||||||
&& rm -rf /root/.cache \
|
rm -rf /root/.npm
|
||||||
&& rm -rf /root/.npm
|
|
||||||
|
|
||||||
ARG SOURCE_COMMIT
|
ARG SOURCE_COMMIT
|
||||||
RUN git clone --depth=1 -b ${QL_BRANCH} ${QL_URL} ${QL_DIR} \
|
RUN git clone --depth=1 -b ${QL_BRANCH} ${QL_URL} ${QL_DIR} && \
|
||||||
&& cd ${QL_DIR} \
|
cd ${QL_DIR} && \
|
||||||
&& cp -f .env.example .env \
|
cp -f .env.example .env && \
|
||||||
&& chmod 777 ${QL_DIR}/shell/*.sh \
|
chmod 777 ${QL_DIR}/shell/*.sh && \
|
||||||
&& chmod 777 ${QL_DIR}/docker/*.sh \
|
chmod 777 ${QL_DIR}/docker/*.sh && \
|
||||||
&& git clone --depth=1 -b ${QL_BRANCH} https://github.com/${QL_MAINTAINER}/qinglong-static.git /static \
|
git clone --depth=1 -b ${QL_BRANCH} https://github.com/${QL_MAINTAINER}/qinglong-static.git /static && \
|
||||||
&& mkdir -p ${QL_DIR}/static \
|
mkdir -p ${QL_DIR}/static && \
|
||||||
&& cp -rf /static/* ${QL_DIR}/static \
|
cp -rf /static/* ${QL_DIR}/static && \
|
||||||
&& rm -rf /static
|
rm -rf /static
|
||||||
|
|
||||||
COPY --from=builder /tmp/build/node_modules/. /ql/node_modules/
|
COPY --from=builder /tmp/build/node_modules/. /ql/node_modules/
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,6 @@ echo -e "############################################################\n"
|
||||||
echo -e "容器启动成功..."
|
echo -e "容器启动成功..."
|
||||||
echo -e "############################################################\n"
|
echo -e "############################################################\n"
|
||||||
|
|
||||||
crond -f >/dev/null
|
tail -f /dev/null
|
||||||
|
|
||||||
exec "$@"
|
exec "$@"
|
||||||
|
|
|
@ -9,7 +9,7 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo -e "\n1、安装bot依赖...\n"
|
echo -e "\n1、安装bot依赖...\n"
|
||||||
apk --no-cache add -f zlib-dev gcc jpeg-dev python3-dev musl-dev freetype-dev
|
apt install -y gcc python3-dev musl-dev
|
||||||
echo -e "\nbot依赖安装成功...\n"
|
echo -e "\nbot依赖安装成功...\n"
|
||||||
|
|
||||||
echo -e "2、下载bot所需文件...\n"
|
echo -e "2、下载bot所需文件...\n"
|
||||||
|
|
|
@ -69,22 +69,6 @@ run_nohup() {
|
||||||
nohup node $file_name &>$log_path &
|
nohup node $file_name &>$log_path &
|
||||||
}
|
}
|
||||||
|
|
||||||
check_server() {
|
|
||||||
if [[ $cpu_warn ]] && [[ $mem_warn ]] && [[ $disk_warn ]]; then
|
|
||||||
local top_result=$(top -b -n 1)
|
|
||||||
cpu_use=$(echo "$top_result" | grep CPU | grep -v -E 'grep|PID' | awk '{print $2}' | cut -f 1 -d "%" | head -n 1)
|
|
||||||
|
|
||||||
mem_free=$(free -m | grep "Mem" | awk '{print $3}' | head -n 1)
|
|
||||||
mem_total=$(free -m | grep "Mem" | awk '{print $2}' | head -n 1)
|
|
||||||
mem_use=$(printf "%d%%" $((mem_free * 100 / mem_total)) | cut -f 1 -d "%" | head -n 1)
|
|
||||||
|
|
||||||
disk_use=$(df -P | grep /dev | grep -v -E '(tmp|boot|shm)' | awk '{print $5}' | cut -f 1 -d "%" | head -n 1)
|
|
||||||
if [[ $cpu_use -gt $cpu_warn ]] && [[ $cpu_warn ]] || [[ $mem_free -lt $mem_warn ]] || [[ $disk_use -gt $disk_warn ]]; then
|
|
||||||
local resource=$(echo "$top_result" | grep -v -E 'grep|Mem|idle|Load|tr' | awk '{$2="";$3="";$4="";$5="";$7="";print $0}' | head -n 10 | tr '\n' '|' | sed s/\|/\\\\n/g)
|
|
||||||
notify_api "服务器资源异常警告" "当前CPU占用 $cpu_use% 内存占用 $mem_use% 磁盘占用 $disk_use% \n资源占用详情 \n\n $resource"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
## 正常运行单个脚本,$1:传入参数
|
## 正常运行单个脚本,$1:传入参数
|
||||||
run_normal() {
|
run_normal() {
|
||||||
|
|
|
@ -429,8 +429,6 @@ handle_task_before() {
|
||||||
|
|
||||||
echo -e "## 开始执行... $begin_time\n"
|
echo -e "## 开始执行... $begin_time\n"
|
||||||
|
|
||||||
[[ $is_macos -eq 0 ]] && check_server
|
|
||||||
|
|
||||||
. $file_task_before "$@"
|
. $file_task_before "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user