diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 507427d..fa74fd7 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -273,22 +273,7 @@ dockers: - --label=io.syncer.image.revision={{.ShortCommit}} - --label=io.syncer.image.version={{.Tag }} - --label=io.syncer.image.auth={{ .Env.USERNAME }} - - use: buildx - ids: - - exporter - goos: linux - goarch: amd64 - image_templates: - - ghcr.io/{{ .Env.USERNAME }}/exporter:{{ .Tag }}-amd64 - dockerfile: deploy/exporter/Dockerfile.exporter - build_flag_templates: - - --pull - - --platform=linux/amd64 - - --label=io.exporter.image.created={{.Date}} - - --label=io.exporter.image.title=exporter - - --label=io.exporter.image.revision={{.ShortCommit}} - - --label=io.exporter.image.version={{.Tag }} - - --label=io.exporter.image.auth={{ .Env.USERNAME }} + - use: buildx ids: - syncer @@ -305,6 +290,24 @@ dockers: - --label=io.syncer.image.revision={{.ShortCommit}} - --label=io.syncer.image.version={{.Tag }} - --label=io.syncer.image.auth={{ .Env.USERNAME }} + + - use: buildx + ids: + - exporter + goos: linux + goarch: amd64 + image_templates: + - ghcr.io/{{ .Env.USERNAME }}/exporter:{{ .Tag }}-amd64 + dockerfile: deploy/exporter/Dockerfile.exporter + build_flag_templates: + - --pull + - --platform=linux/amd64 + - --label=io.exporter.image.created={{.Date}} + - --label=io.exporter.image.title=exporter + - --label=io.exporter.image.revision={{.ShortCommit}} + - --label=io.exporter.image.version={{.Tag }} + - --label=io.exporter.image.auth={{ .Env.USERNAME }} + - use: buildx ids: - exporter @@ -333,6 +336,15 @@ docker_manifests: - ghcr.io/{{ .Env.USERNAME }}/syncer:{{ .Tag }}-amd64 - ghcr.io/{{ .Env.USERNAME }}/syncer:{{ .Tag }}-arm64 + - name_template: ghcr.io/{{ .Env.USERNAME }}/exporter:latest + image_templates: + - ghcr.io/{{ .Env.USERNAME }}/exporter:{{ .Tag }}-amd64 + - ghcr.io/{{ .Env.USERNAME }}/exporter:{{ .Tag }}-arm64 + - name_template: ghcr.io/{{ .Env.USERNAME }}/syncer:latest + image_templates: + - ghcr.io/{{ .Env.USERNAME }}/syncer:{{ .Tag }}-amd64 + - ghcr.io/{{ .Env.USERNAME }}/syncer:{{ .Tag }}-arm64 + docker_signs: - cmd: cosign artifacts: manifests diff --git a/deploy/exporter/Dockerfile.exporter b/deploy/exporter/Dockerfile.exporter index 231d48f..d4030d6 100644 --- a/deploy/exporter/Dockerfile.exporter +++ b/deploy/exporter/Dockerfile.exporter @@ -1,5 +1,5 @@ # 设置基础镜像 -FROM golang +FROM golang AS builder # 设置工作目录 WORKDIR /app @@ -8,7 +8,8 @@ ENV GOPROXY=https://goproxy.cn COPY . /app/ -RUN go build -o /app/_output/bin/exporter /app/cmd/exporter/main.go +RUN cd /app; go build -o _output/bin/exporter cmd/exporter/main.go -# 设置容器启动命令 -CMD ["/app/_output/bin/exporter --help"] \ No newline at end of file +FROM scratch +COPY --from=builder /app/_output/bin/exporter /app +ENTRYPOINT ["/app/exporter --help"] \ No newline at end of file diff --git a/deploy/syncer/Dockerfile.syncer b/deploy/syncer/Dockerfile.syncer index 7e37b33..927a0ee 100644 --- a/deploy/syncer/Dockerfile.syncer +++ b/deploy/syncer/Dockerfile.syncer @@ -1,5 +1,5 @@ # 设置基础镜像 -FROM golang +FROM golang AS builder # 设置工作目录 WORKDIR /app @@ -10,5 +10,6 @@ COPY . /app/ RUN go build -o /app/_output/bin/syncer /app/cmd/syncer/main.go -# 设置容器启动命令 -CMD ["/app/_output/bin/syncer --help"] +FROM scratch +COPY --from=builder /app/_output/bin/syncer /app +ENTRYPOINT ["/app/syncer --help"] \ No newline at end of file