1
0
mirror of https://github.com/nitezs/sub2clash.git synced 2024-12-24 12:34:43 -05:00
sub2clash/Dockerfile

29 lines
669 B
Docker
Raw Normal View History

2023-09-13 03:44:48 -04:00
# 使用官方 Golang 镜像作为构建环境
FROM golang:1.21-alpine as builder
LABEL authors="nite07"
# 设置工作目录
WORKDIR /app
# 复制源代码到工作目录
COPY . .
RUN go mod download
# 获取参数
ARG version
ARG dev
2023-09-13 03:44:48 -04:00
# 使用 -ldflags 参数进行编译
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w -X sub2clash/config.Version=${version} -X sub2clash/config.Dev=${dev}" -o sub2clash main.go
2023-09-13 03:44:48 -04:00
FROM alpine:latest
2023-09-14 21:15:24 -04:00
# 设置工作目录
WORKDIR /app
2023-09-13 03:44:48 -04:00
# 从 builder 镜像中复制出编译好的二进制文件
COPY --from=builder /app/sub2clash /app/sub2clash
# 设置容器的默认启动命令
ENTRYPOINT ["/app/sub2clash"]