aithink commited on
Commit
a2f5c9f
·
verified ·
1 Parent(s): aa27faf

Upload 3 files

Browse files
Files changed (3) hide show
  1. Dockerfile +78 -0
  2. README.md +20 -3
  3. launch.sh +96 -0
Dockerfile ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM node:19.1.0-alpine3.16
2
+
3
+ # Arguments
4
+ ARG APP_HOME=/home/node/app
5
+
6
+ # Install system dependencies
7
+ RUN apk add gcompat tini git jq curl
8
+
9
+ # Ensure proper handling of kernel signals
10
+ ENTRYPOINT [ "tini", "--" ]
11
+
12
+ # Create app directory
13
+ WORKDIR ${APP_HOME}
14
+
15
+ # Set NODE_ENV to production
16
+ ENV NODE_ENV=production
17
+
18
+ # Env
19
+ # 是否远程获取下面的参数 是个链接,返回一个json;执行完后关闭这个链接即可保密
20
+ # 返回内容:
21
+ # {
22
+ # "reverse_proxy": "https://onekey.xxx.top/v1",
23
+ # "proxy_password": "sk-ssvJn4VQAk596Lvv3548xxx",
24
+ # "api_key_makersuite": "AIzaSyAm5S9kl22DDNSXmnd4vgxxx",
25
+ # "github_secret": "github_pat_11AIWDQ2A0cLSEdwiwiZNC_10II4TsFExxx",
26
+ # "github_project": "bincooo/history"
27
+ # }
28
+ ENV fetch ""
29
+ # 代理转发地址
30
+ ENV reverse_proxy ""
31
+ # 代理转发token
32
+ ENV proxy_password ""
33
+ # gemini token
34
+ ENV api_key_makersuite ""
35
+ # github 项目访问凭证token
36
+ ENV github_secret ""
37
+ # github 项目名称
38
+ ENV github_project ""
39
+
40
+ # Install app dependencies
41
+ # COPY package*.json post-install.js ./
42
+ RUN git clone https://github.com/SillyTavern/SillyTavern.git --branch 1.12.7 .
43
+ RUN \
44
+ echo "*** Install npm packages ***" && \
45
+ npm install && npm cache clean --force
46
+
47
+ # Bundle app source
48
+ # COPY . ./
49
+
50
+ ADD launch.sh launch.sh
51
+ RUN curl -JLO https://github.com/bincooo/SillyTavern-Docker/releases/download/v1.0.0/git-batch
52
+ RUN chmod +x launch.sh && chmod +x git-batch && ./git-batch -h
53
+
54
+ RUN \
55
+ echo "*** Install npm packages ***" && \
56
+ npm i --no-audit --no-fund --loglevel=error --no-progress --omit=dev && npm cache clean --force
57
+
58
+ # Copy default chats, characters and user avatars to <folder>.default folder
59
+ RUN \
60
+ rm -f "config.yaml" || true && \
61
+ ln -s "./config/config.yaml" "config.yaml" || true && \
62
+ mkdir "config" || true
63
+
64
+ # Cleanup unnecessary files
65
+ RUN \
66
+ echo "*** Cleanup ***" && \
67
+ mv "./docker/docker-entrypoint.sh" "./" && \
68
+ rm -rf "./docker" && \
69
+ echo "*** Make docker-entrypoint.sh executable ***" && \
70
+ chmod +x "./docker-entrypoint.sh" && \
71
+ echo "*** Convert line endings to Unix format ***" && \
72
+ dos2unix "./docker-entrypoint.sh"
73
+ RUN sed -i 's/# Start the server/.\/launch.sh env \&\& .\/launch.sh init/g' docker-entrypoint.sh
74
+ RUN chmod -R 777 ${APP_HOME}
75
+
76
+ EXPOSE 8000
77
+
78
+ CMD [ "./docker-entrypoint.sh" ]
README.md CHANGED
@@ -1,11 +1,28 @@
1
  ---
2
  title: Tavern
3
- emoji: 🐢
4
  colorFrom: green
5
- colorTo: green
6
  sdk: docker
7
  pinned: false
8
- short_description: Tavern
9
  ---
10
 
11
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  title: Tavern
3
+ emoji: 🐨
4
  colorFrom: green
5
+ colorTo: red
6
  sdk: docker
7
  pinned: false
8
+ app_port: 8000
9
  ---
10
 
11
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
12
+
13
+ 使用前请仔细阅读说明:[help](help.md)
14
+ <img width="1162" alt="Screenshot 2024-11-26 at 19 33 19" src="https://github.com/user-attachments/assets/db412195-2c6c-414b-bd9b-fcfa57ea4374">
15
+
16
+
17
+ 如果你没有替换README.md,则需要自己修改端口:
18
+ ```
19
+ ---
20
+ title: xxx
21
+ emoji: 🐨
22
+ colorFrom: green
23
+ colorTo: red
24
+ sdk: docker
25
+ pinned: false
26
+ app_port: 8000 <-- 这里配置,自行对比差异
27
+ ---
28
+ ```
launch.sh ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/sh
2
+
3
+ BASE=/home/node/app
4
+ USERNAME=$(printenv username)
5
+ PASSWORD=$(printenv password)
6
+
7
+ function env() {
8
+ if [[ ! -z "${fetch}" ]]; then
9
+ echo '远程获取参数...'
10
+ curl -s "$fetch" -o data.json
11
+ export github_secret=$(jq -r .github_secret data.json)
12
+ export github_project=$(jq -r .github_project data.json)
13
+ fi
14
+
15
+ echo
16
+ echo "fetch = ${fetch}"
17
+ echo "github_secret = $github_secret"
18
+ echo "github_project = $github_project"
19
+ echo "USERNAME = ${USERNAME}"
20
+ echo "PASSWORD = ${PASSWORD}"
21
+ echo
22
+ echo
23
+
24
+ sed -i "s/\[github_secret\]/${github_secret}/g" launch.sh
25
+ sed -i "s#\[github_project\]#${github_project}#g" launch.sh
26
+ }
27
+
28
+ function init() {
29
+ mkdir ${BASE}/history
30
+ cd ${BASE}/history
31
+
32
+ git config --global user.email "[email protected]"
33
+ git config --global user.name "complete-Mmx"
34
+ git config --global init.defaultBranch main
35
+ git init
36
+ git remote add origin https://[github_secret]@github.com/[github_project].git
37
+ git add .
38
+ echo "'update history$(date "+%Y-%m-%d %H:%M:%S")'"
39
+ git commit -m "'update history$(date "+%Y-%m-%d %H:%M:%S")'"
40
+ git pull origin main
41
+
42
+ cd ${BASE}
43
+
44
+ DIR="${BASE}/history"
45
+ if [ "$(ls -A $DIR | grep -v .git)" ]; then
46
+ echo "Has history..."
47
+ else
48
+ echo "Empty history..."
49
+ cp -r data/* history/
50
+ cp -r secrets.json history/secrets.json
51
+ fi
52
+
53
+ rm -rf data
54
+ ln -s history data
55
+
56
+ rm -r config.yaml
57
+ cp config/config.yaml history/config.yaml
58
+ ln -s history/config.yaml config.yaml
59
+ sed -i "s/username: .*/username: \"${USERNAME}\"/" ${BASE}/config.yaml
60
+ sed -i "s/password: .*/password: \"${PASSWORD}\"/" ${BASE}/config.yaml
61
+ sed -i "s/whitelistMode: true/whitelistMode: false/" ${BASE}/config.yaml
62
+ sed -i "s/basicAuthMode: false/basicAuthMode: true/" ${BASE}/config.yaml
63
+ cat config.yaml
64
+ echo "Init history."
65
+ chmod -R 777 history
66
+
67
+ nohup ./git-batch --commit 10s --name git-batch --email [email protected] --push 1m -p history > access.log 2>1 &
68
+ }
69
+
70
+ function release() {
71
+ rm -rf history
72
+ }
73
+
74
+ function update() {
75
+ cd ${BASE}/history
76
+ git pull origin main
77
+ git add .
78
+ echo "'update history$(date "+%Y-%m-%d %H:%M:%S")'"
79
+ git commit -m "'update history$(date "+%Y-%m-%d %H:%M:%S")'"
80
+ git push origin main
81
+ }
82
+
83
+ case $1 in
84
+ env)
85
+ env
86
+ ;;
87
+ init)
88
+ init
89
+ ;;
90
+ release)
91
+ release
92
+ ;;
93
+ update)
94
+ update
95
+ ;;
96
+ esac