This commit is contained in:
2023-09-13 15:44:48 +08:00
parent 5c71c54276
commit 070d8b5eb5
3 changed files with 32 additions and 0 deletions

21
Dockerfile Normal file
View File

@ -0,0 +1,21 @@
# 使用官方 Golang 镜像作为构建环境
FROM golang:1.21-alpine as builder
LABEL authors="nite07"
# 设置工作目录
WORKDIR /app
# 复制源代码到工作目录
COPY . .
RUN go mod download
# 使用 -ldflags 参数进行编译
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o sub2clash main.go
FROM alpine:latest
# 从 builder 镜像中复制出编译好的二进制文件
COPY --from=builder /app/sub2clash /app/sub2clash
# 设置容器的默认启动命令
ENTRYPOINT ["/app/sub2clash"]