diff --git a/Dockerfile b/Dockerfile index 342644b1..533b5c34 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,23 +1,23 @@ -ARG GOLANG_IMAGE=golang:1.20-alpine3.16 -ARG BUILD_IMAGE=alpine:3.16 +ARG GOLANG_IMAGE=golang:1.22-alpine3.19 +ARG BUILD_IMAGE=alpine:3.19 # Cross-Compilation # https://www.docker.com/blog/faster-multi-platform-builds-dockerfile-cross-compilation-guide/ FROM --platform=$BUILDPLATFORM $GOLANG_IMAGE as builder -ARG TARGETOS TARGETARCH -ENV GOOS=$TARGETOS GOARCH=$TARGETARCH +ARG TARGETOS TARGETARCH TARGETVARIANT +ENV GOOS=$TARGETOS GOARCH=$TARGETARCH GOARM=$TARGETVARIANT COPY . /dist/core RUN apk add \ git \ - make && \ - cd /dist/core && \ - go version && \ - make release_linux && \ - make import_linux && \ - make ffmigrate_linux + make + +RUN cd /dist/core && \ + make release && \ + make import && \ + make ffmigrate FROM $BUILD_IMAGE diff --git a/Makefile b/Makefile index a93319c0..e98e20b6 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,7 @@ SHORTCOMMIT := $(shell echo $(COMMIT) | head -c 7) BRANCH := $(shell if [ -d .git ]; then git rev-parse --abbrev-ref HEAD; else echo "master"; fi) BUILD := $(shell date -u "+%Y-%m-%dT%H:%M:%SZ") BINSUFFIX := $(shell if [ "${GOOS}" -a "${GOARCH}" ]; then echo "-${GOOS}-${GOARCH}"; else echo ""; fi) +GOARM := $(subst v,$e,$(GOARM)) all: build @@ -15,11 +16,7 @@ init: ## build: Build core (default) build: - CGO_ENABLED=${CGO_ENABLED} GOOS=${GOOS} GOARCH=${GOARCH} go build -o core${BINSUFFIX} -trimpath - -# github workflow workaround -build_linux: - CGO_ENABLED=0 GOOS=linux GOARCH=${OSARCH} go build -o core -trimpath + CGO_ENABLED=0 GOOS=${GOOS} GOARCH=${GOARCH} GOARM=${GOARM} go build -o core$(BINSUFFIX) -trimpath ## swagger: Update swagger API documentation (requires github.com/swaggo/swag) swagger: @@ -69,19 +66,11 @@ lint: ## import: Build import binary import: - cd app/import && CGO_ENABLED=${CGO_ENABLED} GOOS=${GOOS} GOARCH=${GOARCH} go build -o ../../import -trimpath -ldflags="-s -w" - -# github workflow workaround -import_linux: - cd app/import && CGO_ENABLED=0 GOOS=linux GOARCH=${OSARCH} go build -o ../../import -trimpath -ldflags="-s -w" + cd app/import && CGO_ENABLED=0 GOOS=${GOOS} GOARCH=${GOARCH} GOARM=$(GOARM) go build -o ../../import -trimpath -ldflags="-s -w" ## ffmigrate: Build ffmpeg migration binary ffmigrate: - cd app/ffmigrate && CGO_ENABLED=${CGO_ENABLED} GOOS=${GOOS} GOARCH=${GOARCH} go build -o ../../ffmigrate -trimpath -ldflags="-s -w" - -# github workflow workaround -ffmigrate_linux: - cd app/ffmigrate && CGO_ENABLED=0 GOOS=linux GOARCH=${OSARCH} go build -o ../../ffmigrate -trimpath -ldflags="-s -w" + cd app/ffmigrate && CGO_ENABLED=0 GOOS=${GOOS} GOARCH=${GOARCH} GOARM=$(GOARM) go build -o ../../ffmigrate -trimpath -ldflags="-s -w" ## coverage: Generate code coverage analysis coverage: @@ -94,11 +83,10 @@ commit: vet fmt lint test build ## release: Build a release binary of core release: - CGO_ENABLED=${CGO_ENABLED} GOOS=${GOOS} GOARCH=${GOARCH} go build -o core -trimpath -ldflags="-s -w -X github.com/datarhei/core/v16/app.Commit=$(COMMIT) -X github.com/datarhei/core/v16/app.Branch=$(BRANCH) -X github.com/datarhei/core/v16/app.Build=$(BUILD)" + CGO_ENABLED=0 GOOS=${GOOS} GOARCH=${GOARCH} GOARM=$(GOARM) go build -o core -trimpath -ldflags="-s -w -X github.com/datarhei/core/v16/app.Commit=$(COMMIT) -X github.com/datarhei/core/v16/app.Branch=$(BRANCH) -X github.com/datarhei/core/v16/app.Build=$(BUILD)" -# github workflow workaround -release_linux: - CGO_ENABLED=0 GOOS=linux GOARCH=${OSARCH} go build -o core -trimpath -ldflags="-s -w -X github.com/datarhei/core/v16/app.Commit=$(COMMIT) -X github.com/datarhei/core/v16/app.Branch=$(BRANCH) -X github.com/datarhei/core/v16/app.Build=$(BUILD)" +release2: + @echo "Hallo" ## docker: Build standard Docker image docker: