1
0
mirror of https://github.com/StackExchange/dnscontrol.git synced 2024-05-11 05:55:12 +00:00

Add arm64 image build and docker manifest

This commit is contained in:
Chris Hunt
2022-08-11 12:19:59 -04:00
parent 85b60305dd
commit bc57de4bc2
3 changed files with 39 additions and 33 deletions

View File

@ -122,6 +122,7 @@ jobs:
- setup_remote_docker:
version: 20.10.11
docker_layer_caching: true
- run:
name: Install goreleaser

View File

@ -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:

View File

@ -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