hfchat2api / Dockerfile
smgc's picture
Update Dockerfile
ff0937a verified
raw
history blame
1 kB
FROM golang:1.22.2-alpine3.19 AS builder
#ENV GOPROXY=https://goproxy.cn,direct
WORKDIR /app
# 安装 git
RUN apk add git && git clone https://github.com/kkkunny/HuggingChatAPI.git .
# 添加 ARG 指令来接收构建时参数
ARG HF_DOMAIN
# 使用 ENV 指令设置环境变量
ENV HF_DOMAIN $HF_DOMAIN
RUN awk '/const HuggingChatDomain = "https:\/\/huggingface.co"/ { print "import \"os\""; print "var HuggingChatDomain = os.Getenv(\"HF_DOMAIN\")"; next }1' /app/internal/config/domain.go > temp && mv temp /app/internal/config/domain.go
RUN sed -i 's|/v1/|/api/v1/|g' /app/main.go
RUN sed -i 's|:80|:8000|g' /app/main.go
RUN go build -o bin/server .
FROM alpine:3.19 AS final
RUN apk --no-cache add tzdata && \
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
echo "Asia/Shanghai" > /etc/timezone \
ENV TZ Asia/Shanghai
RUN apk add --no-cache ca-certificates && update-ca-certificates
WORKDIR /app
COPY --from=builder /app/bin/* /app
EXPOSE 8000
ENTRYPOINT ["/app/server"]