diff --git a/.circleci/config.yml b/.circleci/config.yml index 7389f8a16..ccd169ab1 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -122,6 +122,7 @@ jobs: - setup_remote_docker: version: 20.10.11 + docker_layer_caching: true - run: name: Install goreleaser diff --git a/.goreleaser.yml b/.goreleaser.yml index 906978edb..9c29dc475 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -50,24 +50,45 @@ nfpms: - deb - rpm dockers: - - - id: docker-build + - image_templates: + - &amd_image "stackexchange/{{.ProjectName}}:{{ .Version }}-amd64" goos: linux goarch: amd64 - image_templates: - - "stackexchange/{{.ProjectName}}:latest" - - "stackexchange/{{.ProjectName}}:{{ .Version }}" use: buildx ids: - build build_flag_templates: - "--pull" - - "--label=org.opencontainers.image.created={{.Date}}" - - "--label=org.opencontainers.image.name={{.ProjectName}}" - - "--label=org.opencontainers.image.revision={{.FullCommit}}" - - "--label=org.opencontainers.image.version={{.Version}}" - - "--label=org.opencontainers.image.source={{.GitURL}}" + - "--label=org.opencontainers.image.created={{ .Date }}" + - "--label=org.opencontainers.image.name={{ .ProjectName }}" + - "--label=org.opencontainers.image.revision={{ .FullCommit }}" + - "--label=org.opencontainers.image.version={{ .Version }}" + - "--label=org.opencontainers.image.source={{ .GitURL }}" - "--platform=linux/amd64" + - image_templates: + - &arm_image "stackexchange/{{.ProjectName}}:{{ .Version }}-arm64" + goos: linux + goarch: arm64 + use: buildx + ids: + - build + build_flag_templates: + - "--pull" + - "--label=org.opencontainers.image.created={{ .Date }}" + - "--label=org.opencontainers.image.name={{ .ProjectName }}" + - "--label=org.opencontainers.image.revision={{ .FullCommit }}" + - "--label=org.opencontainers.image.version={{ .Version }}" + - "--label=org.opencontainers.image.source={{ .GitURL }}" + - "--platform=linux/arm64" +docker_manifests: + - name_template: "stackexchange/{{.ProjectName}}:{{ .Version }}" + image_templates: + - *amd_image + - *arm_image + - name_template: "stackexchange/{{.ProjectName}}:latest" + image_templates: + - *amd_image + - *arm_image checksum: name_template: 'checksums.txt' snapshot: diff --git a/Dockerfile b/Dockerfile index 378cdd62f..31472be2f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,29 +1,13 @@ -FROM golang:1.19.0-alpine3.16@sha256:0eb08c89ab1b0c638a9fe2780f7ae3ab18f6ecda2c76b908e09eb8073912045d AS build +# syntax = docker/dockerfile:1.4 -WORKDIR /go/src/github.com/StackExchange/dnscontrol +FROM alpine:3.16.2@sha256:bc41182d7ef5ffc53a40b044e725193bc10142a1243f395ee852a8d9730fc2ad as RUN -ARG BUILD_VERSION +RUN --mount=type=cache,target=/var/cache/apk \ + apk update \ + && apk add ca-certificates \ + && update-ca-certificates -ENV GO111MODULE on - -COPY . . - -# build dnscontrol -RUN apk update \ - && apk add --no-cache ca-certificates curl gcc build-base git \ - && update-ca-certificates \ - && go build -v -trimpath -buildmode=pie -ldflags="-s -w -X main.SHA=${BUILD_VERSION}" - -# Validation check -RUN cp dnscontrol /go/bin/dnscontrol -RUN dnscontrol version - -# ----- - -FROM alpine:3.16.2@sha256:bc41182d7ef5ffc53a40b044e725193bc10142a1243f395ee852a8d9730fc2ad - -COPY --from=build /etc/ssl/certs /etc/ssl/certs -COPY --from=build /go/bin/dnscontrol /usr/local/bin +COPY dnscontrol /usr/local/bin/ WORKDIR /dns