From 0eff13dc04fef03aa4c0f8b2fbfe0901e49f5b84 Mon Sep 17 00:00:00 2001 From: KincaidYang <91786638+KincaidYang@users.noreply.github.com> Date: Tue, 1 Oct 2024 14:49:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81docker?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..f74fdf7 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,26 @@ +FROM golang:1.23.1-alpine3.20 AS builder + +# 设置工作目录 +WORKDIR /data/workspace + +# 复制go.mod和go.sum文件并下载依赖 +COPY go.mod go.sum ./ +RUN go mod download + +COPY . . +RUN go build -o whois + +FROM debian:bookworm + +# 设置工作目录 +WORKDIR /usr/local/app + +# 复制构建的可执行文件和配置文件 +COPY --from=builder /data/workspace/whois . +COPY --from=builder /data/workspace/config.json . + +# 暴露应用程序的端口 +EXPOSE 8043 + +# 运行应用程序 +CMD ["/usr/local/app/whois"] \ No newline at end of file