ynsc133 commited on
Commit
442341c
·
verified ·
1 Parent(s): 04fb80c

Upload 5 files

Browse files
Files changed (5) hide show
  1. Dockerfile +135 -0
  2. docker-entrypoint.sh +93 -0
  3. npmrc +1 -0
  4. package.json +177 -0
  5. pnpm-lock.yaml +0 -0
Dockerfile ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM node:20-slim as nodebuilder
2
+
3
+ FROM python:3.11-slim-bullseye as builder
4
+ ARG QL_MAINTAINER="whyour"
5
+ LABEL maintainer="${QL_MAINTAINER}"
6
+ ARG QL_URL=https://github.com/${QL_MAINTAINER}/qinglong.git
7
+ ARG QL_BRANCH=debian
8
+
9
+ ENV QL_DIR=/ql \
10
+ QL_BRANCH=${QL_BRANCH}
11
+
12
+ COPY --from=nodebuilder /usr/local/bin/node /usr/local/bin/
13
+ COPY --from=nodebuilder /usr/local/lib/node_modules/. /usr/local/lib/node_modules/
14
+ RUN set -x && \
15
+ ln -s /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm && \
16
+ apt-get update && \
17
+ apt-get install --no-install-recommends -y libatomic1 git && \
18
+ git config --global user.email "qinglong@@users.noreply.github.com" && \
19
+ git config --global user.name "qinglong" && \
20
+ git config --global http.postBuffer 524288000 && \
21
+ git clone --depth=1 -b ${QL_BRANCH} ${QL_URL} ${QL_DIR}
22
+
23
+ RUN mkdir /tmp/build
24
+ RUN cp ${QL_DIR}/package.json ${QL_DIR}/.npmrc ${QL_DIR}/pnpm-lock.yaml /tmp/build/
25
+
26
+ RUN npm i -g pnpm@8.3.1 && \
27
+ cd /tmp/build && \
28
+ pnpm install --prod
29
+
30
+ FROM python:3.11-slim-bullseye
31
+
32
+ ARG QL_MAINTAINER="whyour"
33
+ LABEL maintainer="${QL_MAINTAINER}"
34
+ ARG QL_URL=https://github.com/${QL_MAINTAINER}/qinglong.git
35
+ ARG QL_BRANCH=debian
36
+
37
+ ENV PNPM_HOME=/root/.local/share/pnpm \
38
+ PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/root/.local/share/pnpm:/root/.local/share/pnpm/global/5/node_modules:$PNPM_HOME \
39
+ NODE_PATH=/usr/local/bin:/usr/local/pnpm-global/5/node_modules:/usr/local/lib/node_modules:/root/.local/share/pnpm/global/5/node_modules \
40
+ LANG=C.UTF-8 \
41
+ SHELL=/bin/bash \
42
+ PS1="\u@\h:\w \$ " \
43
+ QL_DIR=/ql \
44
+ QL_BRANCH=${QL_BRANCH}
45
+
46
+ COPY --from=nodebuilder /usr/local/bin/node /usr/local/bin/
47
+ COPY --from=nodebuilder /usr/local/lib/node_modules/. /usr/local/lib/node_modules/
48
+
49
+ RUN set -x && \
50
+ ln -s /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm && \
51
+ ln -s /usr/local/lib/node_modules/npm/bin/npx-cli.js /usr/local/bin/npx && \
52
+ apt-get update && \
53
+ apt-get upgrade -y && \
54
+ apt-get install --no-install-recommends -y git \
55
+ curl \
56
+ cron \
57
+ wget \
58
+ tzdata \
59
+ perl \
60
+ openssl \
61
+ openssh-client \
62
+ nginx \
63
+ jq \
64
+ procps \
65
+ netcat \
66
+ sshpass \
67
+ rclone \
68
+ unzip \
69
+ libatomic1 && \
70
+ apt-get clean && \
71
+ ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
72
+ echo "Asia/Shanghai" >/etc/timezone && \
73
+ git config --global user.email "qinglong@@users.noreply.github.com" && \
74
+ git config --global user.name "qinglong" && \
75
+ git config --global http.postBuffer 524288000 && \
76
+ npm install -g pnpm@8.3.1 pm2 ts-node && \
77
+ rm -rf /root/.pnpm-store && \
78
+ rm -rf /root/.local/share/pnpm/store && \
79
+ rm -rf /root/.cache && \
80
+ rm -rf /root/.npm && \
81
+ chmod u+s /usr/sbin/cron && \
82
+ ulimit -c 0
83
+
84
+ ARG SOURCE_COMMIT
85
+ RUN git clone --depth=1 -b ${QL_BRANCH} ${QL_URL} ${QL_DIR} && \
86
+ cd ${QL_DIR} && \
87
+ cp -f .env.example .env && \
88
+ chmod 777 ${QL_DIR}/shell/*.sh && \
89
+ chmod 777 ${QL_DIR}/docker/*.sh && \
90
+ git clone --depth=1 -b ${QL_BRANCH} https://github.com/${QL_MAINTAINER}/qinglong-static.git /static && \
91
+ mkdir -p ${QL_DIR}/static && \
92
+ cp -rf /static/* ${QL_DIR}/static && \
93
+ rm -rf /static && \
94
+ rm -f ${QL_DIR}/docker/docker-entrypoint.sh
95
+
96
+ COPY docker-entrypoint.sh ${QL_DIR}/docker
97
+
98
+ RUN mkdir /ql/data && \
99
+ mkdir /ql/data/config && \
100
+ mkdir /ql/data/log && \
101
+ mkdir /ql/data/db && \
102
+ mkdir /ql/data/scripts && \
103
+ mkdir /ql/data/repo && \
104
+ mkdir /ql/data/raw && \
105
+ mkdir /ql/data/deps && \
106
+ chmod -R 777 /ql && \
107
+ chmod -R 777 /var && \
108
+ chmod -R 777 /usr/local && \
109
+ chmod -R 777 /etc/nginx && \
110
+ chmod -R 777 /run && \
111
+ chmod -R 777 /usr && \
112
+ chmod -R 777 /root
113
+
114
+ COPY --from=builder /tmp/build/node_modules/. /ql/node_modules/
115
+
116
+ WORKDIR ${QL_DIR}
117
+
118
+
119
+ # Set up a new user named "user" with user ID 1000
120
+ RUN useradd -m -u 1000 user
121
+
122
+ # Switch to the "user" user
123
+ USER user
124
+
125
+ # Create rclone configuration file
126
+ RUN rclone config -h
127
+
128
+ HEALTHCHECK --interval=5s --timeout=2s --retries=20 \
129
+ CMD curl -sf --noproxy '*' http://127.0.0.1:5400/api/health || exit 1
130
+
131
+ ENTRYPOINT ["./docker/docker-entrypoint.sh"]
132
+
133
+ VOLUME /ql/data
134
+
135
+ EXPOSE 5700
docker-entrypoint.sh ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ dir_shell=/ql/shell
4
+ . $dir_shell/share.sh
5
+ . $dir_shell/env.sh
6
+
7
+ echo -e "======================1. 检测配置文件========================\n"
8
+ import_config "$@"
9
+ make_dir /etc/nginx/conf.d
10
+ make_dir /run/nginx
11
+ init_nginx
12
+ fix_config
13
+
14
+ pm2 l &>/dev/null
15
+
16
+ echo -e "======================2. 安装依赖========================\n"
17
+ patch_version
18
+
19
+ echo -e "======================3. 启动nginx========================\n"
20
+ nginx -s reload 2>/dev/null || nginx -c /etc/nginx/nginx.conf
21
+ echo -e "nginx启动成功...\n"
22
+
23
+ echo -e "======================4. 启动pm2服务========================\n"
24
+ reload_update
25
+ reload_pm2
26
+
27
+ if [[ $AutoStartBot == true ]]; then
28
+ echo -e "======================5. 启动bot========================\n"
29
+ nohup ql bot >$dir_log/bot.log 2>&1 &
30
+ echo -e "bot后台启动中...\n"
31
+ fi
32
+
33
+ if [[ $EnableExtraShell == true ]]; then
34
+ echo -e "====================6. 执行自定义脚本========================\n"
35
+ nohup ql extra >$dir_log/extra.log 2>&1 &
36
+ echo -e "自定义脚本后台执行中...\n"
37
+ fi
38
+
39
+ echo -e "======================7. 写入rclone配置========================\n"
40
+ echo "$RCLONE_CONF" > ~/.config/rclone/rclone.conf
41
+
42
+ echo -e "############################################################\n"
43
+ echo -e "容器启动成功..."
44
+ echo -e "############################################################\n"
45
+
46
+
47
+ echo -e "##########8. 写入登陆信息 ############"
48
+ echo "{ \"username\": \"$USERNAME\", \"password\": \"$PASSWORD\" }" > /ql/data/config/auth.json
49
+
50
+ echo -e "##########9. 同步备份信息 ############"
51
+ if [ -n "$RCLONE_CONF" ]; then
52
+ echo -e "########## Synchronizing Backup ############"
53
+
54
+ # Specify the remote folder path in the format remote:path
55
+ REMOTE_FOLDER="huggingface:/qinglong"
56
+
57
+ # Use rclone ls command to list folder contents, capturing output and errors
58
+ OUTPUT=$(rclone ls "$REMOTE_FOLDER" 2>&1)
59
+
60
+ # Get the exit status code of the rclone command
61
+ EXIT_CODE=$?
62
+
63
+ case $EXIT_CODE in
64
+ 0)
65
+ # rclone command executed successfully, check if the folder is empty
66
+ if [ -z "$OUTPUT" ]; then
67
+ echo "Initial installation"
68
+ #rclone sync /ql/data $REMOTE_FOLDER
69
+ else
70
+ mkdir -p /ql/.tmp/data
71
+ rclone sync "$REMOTE_FOLDER" /ql/.tmp/data && real_time=true ql reload data
72
+ fi
73
+ ;;
74
+ 1)
75
+ # Handle other errors, check if it was a directory not found error
76
+ if [[ "$OUTPUT" == *"directory not found"* ]]; then
77
+ echo "Error: Folder does not exist"
78
+ else
79
+ echo "Error: $OUTPUT"
80
+ fi
81
+ ;;
82
+ *)
83
+ echo "Error: rclone command failed, exit code: $EXIT_CODE"
84
+ ;;
85
+ esac
86
+ else
87
+ echo "No Rclone configuration detected"
88
+ fi
89
+
90
+
91
+ tail -f >/dev/null
92
+
93
+ exec "$@"
npmrc ADDED
@@ -0,0 +1 @@
 
 
1
+ strict-peer-dependencies=false
package.json ADDED
@@ -0,0 +1,177 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "private": true,
3
+ "scripts": {
4
+ "start": "concurrently -n w: npm:start:*",
5
+ "start:update": "ts-node -P tsconfig.back.json ./back/update.ts",
6
+ "start:public": "ts-node -P tsconfig.back.json ./back/public.ts",
7
+ "start:rpc": "ts-node -P tsconfig.back.json ./back/schedule/index.ts",
8
+ "start:back": "nodemon",
9
+ "start:front": "max dev",
10
+ "build:front": "max build",
11
+ "build:back": "tsc -p tsconfig.back.json",
12
+ "panel": "npm run build:back && node static/build/app.js",
13
+ "schedule": "npm run build:back && node static/build/schedule/index.js",
14
+ "public": "npm run build:back && node static/build/public.js",
15
+ "update": "npm run build:back && node static/build/update.js",
16
+ "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",
17
+ "prettier": "prettier --write '**/*.{js,jsx,tsx,ts,less,md,json}'",
18
+ "postinstall": "max setup 2>/dev/null || true",
19
+ "test": "umi-test",
20
+ "test:coverage": "umi-test --coverage"
21
+ },
22
+ "gitHooks": {
23
+ "pre-commit": "lint-staged"
24
+ },
25
+ "lint-staged": {
26
+ "*.{js,jsx,less,md,json}": [
27
+ "prettier --write"
28
+ ],
29
+ "*.ts?(x)": [
30
+ "prettier --parser=typescript --write"
31
+ ]
32
+ },
33
+ "pnpm": {
34
+ "peerDependencyRules": {
35
+ "ignoreMissing": [
36
+ "react",
37
+ "react-dom",
38
+ "antd",
39
+ "dva",
40
+ "postcss",
41
+ "webpack",
42
+ "eslint",
43
+ "stylelint",
44
+ "redux",
45
+ "@babel/core",
46
+ "monaco-editor",
47
+ "rc-field-form",
48
+ "@types/lodash.merge",
49
+ "rollup",
50
+ "styled-components"
51
+ ],
52
+ "allowedVersions": {
53
+ "react": "18",
54
+ "react-dom": "18",
55
+ "dva-core": "2"
56
+ }
57
+ }
58
+ },
59
+ "dependencies": {
60
+ "@grpc/grpc-js": "^1.8.13",
61
+ "@otplib/preset-default": "^12.0.1",
62
+ "@sentry/node": "^8.26.0",
63
+ "body-parser": "^1.19.2",
64
+ "celebrate": "^15.0.1",
65
+ "chokidar": "^3.5.3",
66
+ "cors": "^2.8.5",
67
+ "cron-parser": "^4.2.1",
68
+ "cross-spawn": "^7.0.3",
69
+ "dayjs": "^1.11.2",
70
+ "dotenv": "^16.0.0",
71
+ "express": "^4.17.3",
72
+ "express-jwt": "^6.1.1",
73
+ "express-rate-limit": "^7.0.0",
74
+ "express-urlrewrite": "^1.4.0",
75
+ "form-data": "^4.0.0",
76
+ "got": "^11.8.2",
77
+ "hpagent": "^1.2.0",
78
+ "http-proxy-middleware": "^2.0.6",
79
+ "iconv-lite": "^0.6.3",
80
+ "js-yaml": "^4.1.0",
81
+ "jsonwebtoken": "^8.5.1",
82
+ "lodash": "^4.17.21",
83
+ "multer": "1.4.5-lts.1",
84
+ "nedb": "^1.8.0",
85
+ "node-schedule": "^2.1.0",
86
+ "nodemailer": "^6.7.2",
87
+ "p-queue-cjs": "7.3.4",
88
+ "protobufjs": "^7.3.0",
89
+ "pstree.remy": "^1.1.8",
90
+ "reflect-metadata": "^0.1.13",
91
+ "sequelize": "^6.25.5",
92
+ "serve-handler": "^6.1.3",
93
+ "sockjs": "^0.3.24",
94
+ "sqlite3": "git+https://github.com/whyour/node-sqlite3.git#v1.0.3",
95
+ "toad-scheduler": "^1.6.0",
96
+ "typedi": "^0.10.0",
97
+ "uuid": "^8.3.2",
98
+ "winston": "^3.6.0",
99
+ "winston-daily-rotate-file": "^4.7.1",
100
+ "yargs": "^17.3.1",
101
+ "tough-cookie": "^4.0.0",
102
+ "request-ip": "3.3.0",
103
+ "ip2region": "2.3.0"
104
+ },
105
+ "devDependencies": {
106
+ "moment": "2.30.1",
107
+ "@ant-design/icons": "^4.7.0",
108
+ "@ant-design/pro-layout": "6.38.22",
109
+ "@monaco-editor/react": "4.2.1",
110
+ "@react-hook/resize-observer": "^1.2.6",
111
+ "react-router-dom": "6.26.1",
112
+ "@sentry/react": "^8.26.0",
113
+ "@types/body-parser": "^1.19.2",
114
+ "@types/cors": "^2.8.12",
115
+ "@types/cross-spawn": "^6.0.2",
116
+ "@types/express": "^4.17.13",
117
+ "@types/express-jwt": "^6.0.4",
118
+ "@types/file-saver": "2.0.2",
119
+ "@types/js-yaml": "^4.0.5",
120
+ "@types/jsonwebtoken": "^8.5.8",
121
+ "@types/lodash": "^4.14.185",
122
+ "@types/multer": "^1.4.7",
123
+ "@types/nedb": "^1.8.12",
124
+ "@types/node": "^17.0.21",
125
+ "@types/node-schedule": "^1.3.2",
126
+ "@types/nodemailer": "^6.4.4",
127
+ "@types/qrcode.react": "^1.0.2",
128
+ "@types/react": "^18.0.20",
129
+ "@types/react-copy-to-clipboard": "^5.0.4",
130
+ "@types/react-dom": "^18.0.6",
131
+ "@types/serve-handler": "^6.1.1",
132
+ "@types/sockjs": "^0.3.33",
133
+ "@types/sockjs-client": "^1.5.1",
134
+ "@types/uuid": "^8.3.4",
135
+ "@types/request-ip": "0.0.41",
136
+ "@uiw/codemirror-extensions-langs": "^4.21.9",
137
+ "@uiw/react-codemirror": "^4.21.9",
138
+ "@umijs/max": "^4.0.72",
139
+ "@umijs/ssr-darkreader": "^4.9.45",
140
+ "ahooks": "^3.7.8",
141
+ "ansi-to-react": "^6.1.6",
142
+ "antd": "^4.24.8",
143
+ "antd-img-crop": "^4.2.3",
144
+ "axios": "^1.4.0",
145
+ "compression-webpack-plugin": "9.2.0",
146
+ "concurrently": "^7.0.0",
147
+ "react-hotkeys-hook": "^4.4.1",
148
+ "file-saver": "2.0.2",
149
+ "lint-staged": "^13.0.3",
150
+ "monaco-editor": "0.33.0",
151
+ "nodemon": "^3.0.1",
152
+ "prettier": "^2.5.1",
153
+ "pretty-bytes": "6.1.1",
154
+ "qiniu": "^7.4.0",
155
+ "qrcode.react": "^1.0.1",
156
+ "query-string": "^7.1.1",
157
+ "rc-tween-one": "^3.0.6",
158
+ "rc-virtual-list": "3.5.3",
159
+ "react": "18.2.0",
160
+ "react-copy-to-clipboard": "^5.1.0",
161
+ "react-diff-viewer": "^3.1.1",
162
+ "react-dnd": "^14.0.2",
163
+ "react-dnd-html5-backend": "^14.0.0",
164
+ "react-dom": "18.2.0",
165
+ "react-intl-universal": "^2.6.21",
166
+ "react-split-pane": "^0.1.92",
167
+ "sockjs-client": "^1.6.0",
168
+ "ts-node": "^10.9.2",
169
+ "ts-proto": "^1.146.0",
170
+ "tslib": "^2.4.0",
171
+ "typescript": "5.2.2",
172
+ "vh-check": "^2.0.5",
173
+ "virtualizedtableforantd4": "1.3.0",
174
+ "webpack": "^5.70.0",
175
+ "yorkie": "^2.0.0"
176
+ }
177
+ }
pnpm-lock.yaml ADDED
The diff for this file is too large to render. See raw diff