This repository has been archived by the owner on Apr 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1339e8e
commit 89aaabf
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# 使用 Golang 镜像作为构建阶段 | ||
FROM golang AS builder | ||
|
||
# 设置环境变量 | ||
ENV GO111MODULE=on CGO_ENABLED=0 GOOS=linux | ||
|
||
# 设置工作目录 | ||
WORKDIR /coze-chat-proxy | ||
|
||
# 复制 go.mod 和 go.sum 文件,先下载依赖 | ||
COPY go.mod go.sum ./ | ||
ENV GOPROXY=https://goproxy.cn,direct | ||
RUN go mod download | ||
|
||
# 复制整个项目并构建可执行文件 | ||
COPY . . | ||
RUN go build -o /coze-chat-proxy | ||
|
||
############################################## | ||
|
||
# 使用 Alpine 镜像作为最终镜像 | ||
FROM alpine | ||
|
||
# 安装基本的运行时依赖 | ||
RUN apk --no-cache add ca-certificates tzdata | ||
|
||
# 从构建阶段复制可执行文件 | ||
COPY --from=builder /coze-chat-proxy . | ||
|
||
# 暴露端口 | ||
EXPOSE 8080 | ||
|
||
# 工作目录 | ||
WORKDIR /data | ||
|
||
# 设置入口命令 | ||
ENTRYPOINT ["/coze-chat-proxy"] |