mirror of
https://github.com/whyour/qinglong.git
synced 2026-08-08 18:04:32 +08:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 09a5652556 | |||
| 9c47a3c5d2 | |||
| 7b8ad601f8 | |||
| ac90b24607 |
@@ -1,3 +1,4 @@
|
|||||||
|
UPDATE_PORT=5300
|
||||||
PUBLIC_PORT=5400
|
PUBLIC_PORT=5400
|
||||||
CRON_PORT=5500
|
CRON_PORT=5500
|
||||||
BACK_PORT=5600
|
BACK_PORT=5600
|
||||||
|
|||||||
@@ -2,15 +2,8 @@ name: Build And Push Docker Image
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
paths-ignore:
|
|
||||||
- "*.md"
|
|
||||||
branches:
|
branches:
|
||||||
- "master"
|
- "npm-debug"
|
||||||
- "develop"
|
|
||||||
tags:
|
|
||||||
- "v*"
|
|
||||||
schedule:
|
|
||||||
- cron: "00 20 * * *"
|
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
@@ -163,73 +156,8 @@ jobs:
|
|||||||
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-to: type=registry,ref=whyour/qinglong:cache,mode=max
|
|
||||||
|
|
||||||
- name: Image digest
|
- name: Image digest
|
||||||
run: |
|
run: |
|
||||||
echo ${{ steps.docker_build.outputs.digest }}
|
echo ${{ steps.docker_build.outputs.digest }}
|
||||||
|
|
||||||
build310:
|
|
||||||
if: ${{ github.ref_name == 'master' }}
|
|
||||||
needs: build-static
|
|
||||||
|
|
||||||
runs-on: ubuntu-20.04
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
packages: write
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- uses: pnpm/action-setup@v3
|
|
||||||
with:
|
|
||||||
version: "8.3.1"
|
|
||||||
- uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
cache: "pnpm"
|
|
||||||
|
|
||||||
- name: Setup timezone
|
|
||||||
uses: szenius/set-timezone@v1.2
|
|
||||||
with:
|
|
||||||
timezoneLinux: Asia/Shanghai
|
|
||||||
|
|
||||||
- name: Login to DockerHub
|
|
||||||
uses: docker/login-action@v3
|
|
||||||
with:
|
|
||||||
username: ${{ secrets.DOCKER_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
||||||
|
|
||||||
- name: Login to GHCR
|
|
||||||
uses: docker/login-action@v3
|
|
||||||
with:
|
|
||||||
registry: ghcr.io
|
|
||||||
username: ${{ github.repository_owner }}
|
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: Set up QEMU
|
|
||||||
uses: docker/setup-qemu-action@v3
|
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v3
|
|
||||||
|
|
||||||
- name: Build and push python3.10
|
|
||||||
id: docker_build_310
|
|
||||||
uses: docker/build-push-action@v5
|
|
||||||
with:
|
|
||||||
build-args: |
|
|
||||||
MAINTAINER=${{ github.repository_owner }}
|
|
||||||
QL_BRANCH=${{ github.ref_name }}
|
|
||||||
SOURCE_COMMIT=${{ github.sha }}
|
|
||||||
network: host
|
|
||||||
platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x,linux/386
|
|
||||||
context: .
|
|
||||||
file: ./docker/310.Dockerfile
|
|
||||||
push: true
|
|
||||||
tags: whyour/qinglong:python3.10
|
|
||||||
cache-from: type=registry,ref=whyour/qinglong:cache-python3.10
|
|
||||||
cache-to: type=registry,ref=whyour/qinglong:cache-python3.10,mode=max
|
|
||||||
|
|
||||||
- name: Image digest
|
|
||||||
run: |
|
|
||||||
echo ${{ steps.docker_build_310.outputs.digest }}
|
|
||||||
@@ -16,6 +16,11 @@ export default defineConfig({
|
|||||||
favicons: [`https://qn.whyour.cn/favicon.svg`],
|
favicons: [`https://qn.whyour.cn/favicon.svg`],
|
||||||
publicPath: process.env.NODE_ENV === 'production' ? './' : '/',
|
publicPath: process.env.NODE_ENV === 'production' ? './' : '/',
|
||||||
proxy: {
|
proxy: {
|
||||||
|
[`${baseUrl}api/update`]: {
|
||||||
|
target: 'http://127.0.0.1:5300/',
|
||||||
|
changeOrigin: true,
|
||||||
|
pathRewrite: { [`^${baseUrl}api/update`]: '/api' },
|
||||||
|
},
|
||||||
[`${baseUrl}api/public`]: {
|
[`${baseUrl}api/public`]: {
|
||||||
target: 'http://127.0.0.1:5400/',
|
target: 'http://127.0.0.1:5400/',
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ export default {
|
|||||||
port: parseInt(process.env.BACK_PORT as string, 10),
|
port: parseInt(process.env.BACK_PORT as string, 10),
|
||||||
cronPort: parseInt(process.env.CRON_PORT as string, 10),
|
cronPort: parseInt(process.env.CRON_PORT as string, 10),
|
||||||
publicPort: parseInt(process.env.PUBLIC_PORT as string, 10),
|
publicPort: parseInt(process.env.PUBLIC_PORT as string, 10),
|
||||||
|
updatePort: parseInt(process.env.UPDATE_PORT as string, 10),
|
||||||
secret: process.env.SECRET || createRandomString(16, 32),
|
secret: process.env.SECRET || createRandomString(16, 32),
|
||||||
logs: {
|
logs: {
|
||||||
level: process.env.LOG_LEVEL || 'silly',
|
level: process.env.LOG_LEVEL || 'silly',
|
||||||
|
|||||||
@@ -0,0 +1,93 @@
|
|||||||
|
import bodyParser from 'body-parser';
|
||||||
|
import { errors } from 'celebrate';
|
||||||
|
import cors from 'cors';
|
||||||
|
import { Application, NextFunction, Request, Response } from 'express';
|
||||||
|
import jwt from 'express-jwt';
|
||||||
|
import Container from 'typedi';
|
||||||
|
import { Logger } from 'winston';
|
||||||
|
import config from '../config';
|
||||||
|
import SystemService from '../services/system';
|
||||||
|
|
||||||
|
export default ({ app }: { app: Application }) => {
|
||||||
|
app.set('trust proxy', 'loopback');
|
||||||
|
app.use(cors());
|
||||||
|
|
||||||
|
app.use(bodyParser.json({ limit: '50mb' }));
|
||||||
|
app.use(bodyParser.urlencoded({ limit: '50mb', extended: true }));
|
||||||
|
|
||||||
|
app.use(
|
||||||
|
jwt({
|
||||||
|
secret: config.secret,
|
||||||
|
algorithms: ['HS384'],
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
app.put(
|
||||||
|
'/api/system',
|
||||||
|
async (req: Request, res: Response, next: NextFunction) => {
|
||||||
|
const logger: Logger = Container.get('logger');
|
||||||
|
try {
|
||||||
|
const systemService = Container.get(SystemService);
|
||||||
|
const result = await systemService.reloadSystem('system');
|
||||||
|
res.send(result);
|
||||||
|
} catch (e) {
|
||||||
|
logger.error('🔥 error: %o', e);
|
||||||
|
return next(e);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
app.put(
|
||||||
|
'/api/data',
|
||||||
|
async (req: Request, res: Response, next: NextFunction) => {
|
||||||
|
const logger: Logger = Container.get('logger');
|
||||||
|
try {
|
||||||
|
const systemService = Container.get(SystemService);
|
||||||
|
const result = await systemService.reloadSystem('data');
|
||||||
|
res.send(result);
|
||||||
|
} catch (e) {
|
||||||
|
logger.error('🔥 error: %o', e);
|
||||||
|
return next(e);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
app.use((req, res, next) => {
|
||||||
|
const err: any = new Error('Not Found');
|
||||||
|
err['status'] = 404;
|
||||||
|
next(err);
|
||||||
|
});
|
||||||
|
|
||||||
|
app.use(errors());
|
||||||
|
|
||||||
|
app.use(
|
||||||
|
(
|
||||||
|
err: Error & { status: number },
|
||||||
|
req: Request,
|
||||||
|
res: Response,
|
||||||
|
next: NextFunction,
|
||||||
|
) => {
|
||||||
|
if (err.name === 'UnauthorizedError') {
|
||||||
|
return res
|
||||||
|
.status(err.status)
|
||||||
|
.send({ code: 401, message: err.message })
|
||||||
|
.end();
|
||||||
|
}
|
||||||
|
return next(err);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
app.use(
|
||||||
|
(
|
||||||
|
err: Error & { status: number },
|
||||||
|
req: Request,
|
||||||
|
res: Response,
|
||||||
|
next: NextFunction,
|
||||||
|
) => {
|
||||||
|
res.status(err.status || 500);
|
||||||
|
res.json({
|
||||||
|
code: err.status || 500,
|
||||||
|
message: err.message,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
import 'reflect-metadata'; // We need this in order to use @Decorators
|
||||||
|
import config from './config';
|
||||||
|
import express from 'express';
|
||||||
|
import Logger from './loaders/logger';
|
||||||
|
|
||||||
|
async function startServer() {
|
||||||
|
const app = express();
|
||||||
|
|
||||||
|
await require('./loaders/update').default({ app });
|
||||||
|
|
||||||
|
app
|
||||||
|
.listen(config.updatePort, () => {
|
||||||
|
Logger.debug(`✌️ 更新服务启动成功!`);
|
||||||
|
console.debug(`✌️ 更新服务启动成功!`);
|
||||||
|
process.send?.('ready');
|
||||||
|
})
|
||||||
|
.on('error', (err) => {
|
||||||
|
Logger.error(err);
|
||||||
|
console.error(err);
|
||||||
|
process.exit(1);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
startServer();
|
||||||
+5
-4
@@ -3,11 +3,11 @@ COPY package.json .npmrc pnpm-lock.yaml /tmp/build/
|
|||||||
RUN set -x \
|
RUN set -x \
|
||||||
&& apk update \
|
&& apk update \
|
||||||
&& apk add nodejs npm git \
|
&& apk add nodejs npm git \
|
||||||
&& npm i -g pnpm@8.3.1 \
|
&& npm i -g pnpm@8.3.1 pm2 tsx \
|
||||||
&& cd /tmp/build \
|
&& cd /tmp/build \
|
||||||
&& pnpm install --prod
|
&& pnpm install --prod
|
||||||
|
|
||||||
FROM python:3.11-alpine3.18
|
FROM python:3.11-alpine
|
||||||
|
|
||||||
ARG QL_MAINTAINER="whyour"
|
ARG QL_MAINTAINER="whyour"
|
||||||
LABEL maintainer="${QL_MAINTAINER}"
|
LABEL maintainer="${QL_MAINTAINER}"
|
||||||
@@ -27,6 +27,9 @@ VOLUME /ql/data
|
|||||||
|
|
||||||
EXPOSE 5700
|
EXPOSE 5700
|
||||||
|
|
||||||
|
COPY --from=builder /usr/local/lib/node_modules/. /usr/local/lib/node_modules/
|
||||||
|
COPY --from=builder /usr/local/bin/. /usr/local/bin/
|
||||||
|
|
||||||
RUN set -x \
|
RUN set -x \
|
||||||
&& apk update -f \
|
&& apk update -f \
|
||||||
&& apk upgrade \
|
&& apk upgrade \
|
||||||
@@ -53,11 +56,9 @@ RUN set -x \
|
|||||||
&& 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 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 \
|
|
||||||
&& ulimit -c 0
|
&& ulimit -c 0
|
||||||
|
|
||||||
ARG SOURCE_COMMIT
|
ARG SOURCE_COMMIT
|
||||||
|
|||||||
@@ -6,6 +6,10 @@ upstream publicApi {
|
|||||||
server 0.0.0.0:5400;
|
server 0.0.0.0:5400;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
upstream updateApi {
|
||||||
|
server 0.0.0.0:5300;
|
||||||
|
}
|
||||||
|
|
||||||
map $http_upgrade $connection_upgrade {
|
map $http_upgrade $connection_upgrade {
|
||||||
default keep-alive;
|
default keep-alive;
|
||||||
'websocket' upgrade;
|
'websocket' upgrade;
|
||||||
@@ -16,6 +20,18 @@ server {
|
|||||||
IPV6_CONFIG
|
IPV6_CONFIG
|
||||||
ssl_session_timeout 5m;
|
ssl_session_timeout 5m;
|
||||||
|
|
||||||
|
location QL_BASE_URLapi/update/ {
|
||||||
|
proxy_set_header Host $http_host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_pass http://updateApi/api/;
|
||||||
|
proxy_buffering off;
|
||||||
|
proxy_redirect default;
|
||||||
|
proxy_connect_timeout 1800;
|
||||||
|
proxy_send_timeout 1800;
|
||||||
|
proxy_read_timeout 1800;
|
||||||
|
}
|
||||||
|
|
||||||
location QL_BASE_URLapi/public/ {
|
location QL_BASE_URLapi/public/ {
|
||||||
proxy_set_header Host $http_host;
|
proxy_set_header Host $http_host;
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
|||||||
@@ -1,5 +1,14 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
apps: [
|
apps: [
|
||||||
|
{
|
||||||
|
name: 'update',
|
||||||
|
max_restarts: 10,
|
||||||
|
kill_timeout: 15000,
|
||||||
|
wait_ready: true,
|
||||||
|
listen_timeout: 10000,
|
||||||
|
time: true,
|
||||||
|
script: 'static/build/update.js',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'schedule',
|
name: 'schedule',
|
||||||
max_restarts: 10,
|
max_restarts: 10,
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
"start": "concurrently -n w: npm:start:*",
|
"start": "concurrently -n w: npm:start:*",
|
||||||
"start:front": "max dev",
|
"start:front": "max dev",
|
||||||
"start:back": "nodemon",
|
"start:back": "nodemon",
|
||||||
|
"start:update": "ts-node -P tsconfig.back.json ./back/update.ts",
|
||||||
"start:public": "ts-node -P tsconfig.back.json ./back/public.ts",
|
"start:public": "ts-node -P tsconfig.back.json ./back/public.ts",
|
||||||
"start:rpc": "ts-node -P tsconfig.back.json ./back/schedule/index.ts",
|
"start:rpc": "ts-node -P tsconfig.back.json ./back/schedule/index.ts",
|
||||||
"build:front": "max build",
|
"build:front": "max build",
|
||||||
@@ -11,6 +12,7 @@
|
|||||||
"panel": "npm run build:back && node static/build/app.js",
|
"panel": "npm run build:back && node static/build/app.js",
|
||||||
"schedule": "npm run build:back && node static/build/schedule/index.js",
|
"schedule": "npm run build:back && node static/build/schedule/index.js",
|
||||||
"public": "npm run build:back && node static/build/public.js",
|
"public": "npm run build:back && node static/build/public.js",
|
||||||
|
"update": "npm run build:back && node static/build/update.js",
|
||||||
"gen:proto": "protoc --experimental_allow_proto3_optional --plugin=./node_modules/.bin/protoc-gen-ts_proto ./back/protos/*.proto --ts_proto_out=./ --ts_proto_opt=outputServices=grpc-js,env=node,esModuleInterop=true",
|
"gen:proto": "protoc --experimental_allow_proto3_optional --plugin=./node_modules/.bin/protoc-gen-ts_proto ./back/protos/*.proto --ts_proto_out=./ --ts_proto_opt=outputServices=grpc-js,env=node,esModuleInterop=true",
|
||||||
"prettier": "prettier --write '**/*.{js,jsx,tsx,ts,less,md,json}'",
|
"prettier": "prettier --write '**/*.{js,jsx,tsx,ts,less,md,json}'",
|
||||||
"postinstall": "max setup 2>/dev/null || true",
|
"postinstall": "max setup 2>/dev/null || true",
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ const CheckUpdate = ({ systemInfo }: any) => {
|
|||||||
|
|
||||||
const reloadSystem = (type?: string) => {
|
const reloadSystem = (type?: string) => {
|
||||||
request
|
request
|
||||||
.put(`${config.apiPrefix}system/reload`, { type })
|
.put(`${config.apiPrefix}update/${type}`)
|
||||||
.then((_data: any) => {
|
.then((_data: any) => {
|
||||||
message.success({
|
message.success({
|
||||||
content: (
|
content: (
|
||||||
@@ -220,7 +220,7 @@ const CheckUpdate = ({ systemInfo }: any) => {
|
|||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
type="primary"
|
type="primary"
|
||||||
onClick={() => reloadSystem()}
|
onClick={() => reloadSystem('system')}
|
||||||
style={{ marginLeft: 8 }}
|
style={{ marginLeft: 8 }}
|
||||||
>
|
>
|
||||||
{intl.get('重新启动')}
|
{intl.get('重新启动')}
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ const Other = ({
|
|||||||
okText: intl.get('重启'),
|
okText: intl.get('重启'),
|
||||||
onOk() {
|
onOk() {
|
||||||
request
|
request
|
||||||
.put(`${config.apiPrefix}system/reload`, { type: 'data' })
|
.put(`${config.apiPrefix}update/data`)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
message.success({
|
message.success({
|
||||||
content: (
|
content: (
|
||||||
|
|||||||
Reference in New Issue
Block a user