Spaces:
Sleeping
Sleeping
# 使用 Golang 镜像作为构建阶段 | |
FROM golang AS builder | |
# 设置环境变量 | |
ENV GO111MODULE=on \ | |
CGO_ENABLED=0 \ | |
GOOS=linux | |
# 设置工作目录 | |
WORKDIR /build | |
# 安装 git | |
RUN apt-get update && apt-get install -y git | |
# 复制整个项目并构建可执行文件 | |
RUN git clone https://github.com/deanxv/coze-discord-proxy.git . | |
RUN sed -i 's|router.Group("/v1")|router.Group("/hf/v1")|g' router/api-router.go | |
#ENV GOPROXY=https://goproxy.cn,direct | |
RUN go mod download | |
RUN go build -o /coze-discord-proxy | |
# 使用 Alpine 镜像作为最终镜像 | |
FROM alpine | |
# 安装基本的运行时依赖 | |
RUN apk --no-cache add ca-certificates tzdata | |
# 从构建阶段复制可执行文件 | |
COPY --from=builder /coze-discord-proxy . | |
# 暴露端口 | |
EXPOSE 7077 | |
# 工作目录 | |
WORKDIR /app/coze-discord-proxy/data | |
COPY entrypoint.sh /app/coze-discord-proxy/data | |
# 创建 config 目录 | |
RUN mkdir -p /app/coze-discord-proxy/data/config && chmod 777 -R /app | |
# 设置容器的入口点为启动脚本 | |
ENTRYPOINT ["./entrypoint.sh"] | |
# 指定容器启动时执行的命令 | |
CMD ["/coze-discord-proxy"] |