smgc commited on
Commit
67d1169
·
verified ·
1 Parent(s): 24d947b

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +32 -0
Dockerfile ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM golang:1.22.2-alpine3.19 AS builder
2
+
3
+ #ENV GOPROXY=https://goproxy.cn,direct
4
+ WORKDIR /app
5
+
6
+ # 安装 git
7
+ RUN apk add git && git clone https://github.com/kkkunny/HuggingChatAPI.git .
8
+
9
+ # 添加 ARG 指令来接收构建时参数
10
+ ARG HF_DOMAIN
11
+
12
+ # 使用 ENV 指令设置环境变量
13
+ ENV HF_DOMAIN $HF_DOMAIN
14
+
15
+ RUN awk '/const HuggingChatDomain = "https:\/\/huggingface.co"/ { print "import \"os\""; print "var HuggingChatDomain = os.Getenv(\"HF_DOMAIN\")"; next }1' /app/internal/consts/const.go > temp && mv temp /app/internal/consts/const.go
16
+ RUN sed -i 's|/v1/|/api/v1/|g' /app/main.go
17
+ RUN sed -i 's|:80|:8000|g' /app/main.go
18
+
19
+ RUN go build -o bin/server .
20
+
21
+ FROM alpine:3.19 AS final
22
+
23
+ RUN apk --no-cache add tzdata && \
24
+ cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
25
+ echo "Asia/Shanghai" > /etc/timezone \
26
+ ENV TZ Asia/Shanghai
27
+
28
+ RUN apk add --no-cache ca-certificates && update-ca-certificates
29
+ WORKDIR /app
30
+ COPY --from=builder /app/bin/* /app
31
+ EXPOSE 8000
32
+ ENTRYPOINT ["/app/server"]