diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yml similarity index 100% rename from .github/workflows/docker.yaml rename to .github/workflows/docker.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..374494a --- /dev/null +++ b/Dockerfile @@ -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"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..953022f --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,11 @@ +version '3' + +services: + sub2clash: + container_name: sub2clash + restart: unless-stopped + image: ghcr.io/nitezs/sub2clash:latest + volumes: + - ./templates:/app/templates + - ./logs:/app/logs + - .env:/app/.env