-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build multiarch, publish to hub.docker.com
- Loading branch information
Showing
4 changed files
with
43 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
FROM golang:alpine as builder | ||
FROM --platform=$BUILDPLATFORM golang:alpine AS builder | ||
|
||
ARG BUILD_ARCH | ||
ARG TARGETOS | ||
ARG TARGETARCH | ||
|
||
RUN apk update && apk add --no-cache ca-certificates && update-ca-certificates | ||
|
||
|
@@ -9,12 +10,13 @@ COPY . . | |
COPY config.json /config.json | ||
RUN mkdir -p /share/domofon && touch /share/domofon/account.json && chmod 777 /share/domofon/account.json | ||
|
||
RUN CGO_ENABLED=0 go build -mod=vendor -ldflags='-w -s -extldflags "-static"' -a -o /go/bin/domru . | ||
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -mod=vendor -ldflags='-w -s -extldflags "-static"' -a -o /go/bin/domru . | ||
|
||
FROM scratch | ||
|
||
ARG BUILD_DATE | ||
ARG BUILD_REF | ||
ARG TARGETARCH | ||
|
||
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ | ||
COPY --from=builder /etc/passwd /etc/passwd | ||
|
@@ -31,7 +33,7 @@ ENTRYPOINT ["/go/bin/domru"] | |
LABEL \ | ||
io.hass.name="Domofon addon" \ | ||
io.hass.description="Domofon addon" \ | ||
io.hass.arch="${BUILD_ARCH}" \ | ||
io.hass.arch=${TARGETARCH} \ | ||
io.hass.type="addon" \ | ||
maintainer="ad <[email protected]>" \ | ||
org.label-schema.description="Domofon addon" \ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
.EXPORT_ALL_VARIABLES: | ||
.DEFAULT_GOAL := default | ||
DOCKER_SCAN_SUGGEST = false | ||
CWD = $(shell pwd) | ||
SRC_DIRS := . | ||
GOCACHE ?= $$(pwd)/.go/cache | ||
BUILD_VERSION=$(shell cat config.json | awk 'BEGIN { FS="\""; RS="," }; { if ($$2 == "version") {print $$4} }') | ||
IMAGE ?= danielapatin/domru:${BUILD_VERSION} | ||
|
||
export DOCKER_CLI_EXPERIMENTAL=enabled | ||
|
||
.PHONY: build # Build the container image | ||
build: | ||
@docker buildx create --use --name=crossplat --node=crossplat && \ | ||
docker buildx build \ | ||
--build-arg="BUILD_VERSION=${BUILD_VERSION}" \ | ||
--output "type=docker,push=false" \ | ||
--tag $(IMAGE) \ | ||
--tag danielapatin/domru:latest \ | ||
. | ||
|
||
.PHONY: publish # Push the image to the remote registry | ||
publish: | ||
@docker buildx create --use --name=crossplat --node=crossplat && \ | ||
docker buildx build \ | ||
--platform linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 \ | ||
--build-arg="BUILD_VERSION=${BUILD_VERSION}" \ | ||
--output "type=image,push=true" \ | ||
--tag $(IMAGE) \ | ||
--tag danielapatin/domru:latest \ | ||
. | ||
|
||
lint: | ||
@docker run --rm -t -w $(CWD) -v $(CURDIR):$(CWD) -e GOFLAGS=-mod=vendor golangci/golangci-lint:latest golangci-lint run -v |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters