malt666 commited on
Commit
1c85fcb
·
verified ·
1 Parent(s): fc1ff51

Upload 5 files

Browse files
Files changed (2) hide show
  1. Dockerfile +13 -60
  2. app.py +1 -1
Dockerfile CHANGED
@@ -1,71 +1,24 @@
1
- # 这是一个临时的Dockerfile,用于在Hugging Face上部署占位符服务
2
- # TODO: 解决完整版本的依赖问题后替换此文件
3
 
4
- # 第一阶段:构建Go服务
5
- FROM golang:1.20-alpine AS go-builder
6
 
7
- # 安装基本依赖
8
- RUN apk add --no-cache git build-base ca-certificates
9
-
10
- # 设置工作目录
11
  WORKDIR /app
12
 
13
- # 初始化go.mod
14
- RUN go mod init tokenizer
15
-
16
- # 预先下载依赖
17
- RUN go get github.com/google/generative-ai-go/[email protected]
18
- RUN go get google.golang.org/[email protected]
19
- RUN go get github.com/gin-gonic/[email protected]
20
- RUN go get github.com/go-playground/validator/[email protected]
21
- RUN go get github.com/gabriel-vasile/[email protected]
22
-
23
- # 复制源代码
24
- COPY main.go .
25
-
26
- # 确保依赖关系
27
- RUN go mod tidy
28
- RUN go mod download
29
-
30
- # 构建
31
- RUN CGO_ENABLED=0 GOOS=linux go build -o tokenizer -a -installsuffix cgo -ldflags="-w -s" .
32
-
33
- # 第二阶段:构建Python环境
34
- FROM python:3.9-slim
35
-
36
- # 安装基本依赖
37
- RUN apt-get update && apt-get install -y --no-install-recommends \
38
- ca-certificates \
39
- && rm -rf /var/lib/apt/lists/*
40
-
41
- # 设置工作目录
42
- WORKDIR /app
43
-
44
- # 复制Go二进制文件
45
- COPY --from=go-builder /app/tokenizer .
46
-
47
- # 复制Python服务文件和tokenizer文件
48
- COPY deepseek_v3_tokenizer /app/deepseek_v3_tokenizer
49
- COPY openai_service.py /app/
50
 
51
- # 安装Python依赖
52
- RUN pip install --no-cache-dir flask transformers tiktoken
53
 
54
  # 设置环境变量
55
- ENV GIN_MODE=release
56
  ENV PORT=7860
57
- ENV DEEPSEEK_URL=http://127.0.0.1:7861
58
- ENV OPENAI_URL=http://127.0.0.1:7862
59
 
60
- # 创建启动脚本
61
- RUN echo '#!/bin/sh\n\
62
- python /app/deepseek_v3_tokenizer/deepseek_service.py & \n\
63
- python /app/openai_service.py & \n\
64
- sleep 5\n\
65
- ./tokenizer' > /app/start.sh && chmod +x /app/start.sh
66
 
67
- # 暴露端口
68
- EXPOSE 7860 7861 7862
69
 
70
- # 启动服务
71
- CMD ["/app/start.sh"]
 
1
+ FROM python:3.11-slim
 
2
 
3
+ # 设置用户为root
4
+ USER root
5
 
 
 
 
 
6
  WORKDIR /app
7
 
8
+ COPY requirements.txt .
9
+ RUN pip install --no-cache-dir -r requirements.txt
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
 
11
+ COPY . .
 
12
 
13
  # 设置环境变量
14
+ ENV HOST=0.0.0.0
15
  ENV PORT=7860
 
 
16
 
17
+ # 删除敏感文件
18
+ RUN rm -f config.json password.txt
 
 
 
 
19
 
20
+ # 暴露端口(Hugging Face默认使用7860端口)
21
+ EXPOSE 7860
22
 
23
+ # 启动命令
24
+ CMD ["python", "app.py"]
app.py CHANGED
@@ -18,7 +18,7 @@ app.secret_key = os.environ.get("SECRET_KEY", "abacus_chat_proxy_secret_key")
18
  app.config['PERMANENT_SESSION_LIFETIME'] = timedelta(days=7)
19
 
20
  # 添加tokenizer服务URL
21
- TOKENIZER_SERVICE_URL = "https://esotlam-tokenizer.hf.space/count_tokens"
22
 
23
  API_ENDPOINT_URL = "https://abacus.ai/api/v0/describeDeployment"
24
  MODEL_LIST_URL = "https://abacus.ai/api/v0/listExternalApplications"
 
18
  app.config['PERMANENT_SESSION_LIFETIME'] = timedelta(days=7)
19
 
20
  # 添加tokenizer服务URL
21
+ TOKENIZER_SERVICE_URL = "https://malt666-abacus-chat-proxy.hf.space/count_tokens"
22
 
23
  API_ENDPOINT_URL = "https://abacus.ai/api/v0/describeDeployment"
24
  MODEL_LIST_URL = "https://abacus.ai/api/v0/listExternalApplications"