getidev/Makefile

93 lines
2.8 KiB
Makefile
Raw Permalink Normal View History

2021-06-10 11:08:56 +00:00
# VERSION
VERSION?=$(shell git describe --abbrev=0)+hash.$(shell git rev-parse --short HEAD)
# CONTAINER_RUNTIME
CONTAINER_RUNTIME?=$(shell which podman)
2021-06-10 11:08:56 +00:00
# CONTAINER_IMAGE
2024-04-08 14:28:53 +00:00
CONTAINER_IMAGE_REGISTRY_HOST?=git.cryptic.systems
CONTAINER_IMAGE_REPOSITORY=volker.raschek/getidev
2021-06-10 11:08:56 +00:00
CONTAINER_IMAGE_VERSION?=latest
CONTAINER_IMAGE_FULLY_QUALIFIED=${CONTAINER_IMAGE_REGISTRY_HOST}/${CONTAINER_IMAGE_REPOSITORY}:${CONTAINER_IMAGE_VERSION}
2021-06-10 11:08:56 +00:00
# EXECUTABLES
# ==============================================================================
EXECUTABLE_TARGETS=getidev
PHONY=all
all: clean ${EXECUTABLE_TARGETS}
getidev:
go build -tags netgo -ldflags "-X main.version=${VERSION}" -o ${@} main.go
2021-06-10 11:08:56 +00:00
# CLEAN
# ==============================================================================
PHONY+=clean
clean:
2024-04-08 14:28:53 +00:00
rm -f -r $(shell pwd)/getidev*
2021-06-10 11:08:56 +00:00
# GOLANGCI-LINT
# ==============================================================================
PHONY+=golangci-lint
golangci-lint:
golangci-lint run --concurrency=$(shell nproc)
# GOSEC
# ==============================================================================
PHONY+=gosec
gosec:
gosec $(shell pwd)/...
# CONTAINER-IMAGE
# ==============================================================================
PHONY+=container-image/build
container-image/build:
${CONTAINER_RUNTIME} build \
--build-arg VERSION=${VERSION} \
--file ./Dockerfile \
--no-cache \
--tag ${CONTAINER_IMAGE_FULLY_QUALIFIED} \
.
PHONY+=container-image/push
container-image/push: container-image/build
${CONTAINER_RUNTIME} push ${CONTAINER_IMAGE_FULLY_QUALIFIED}
# CONTAINER STEPS - EXECUTABLE
# ==============================================================================
PHONY+=container-run/all
container-run/all:
$(MAKE) container-run COMMAND=${@:container-run/%=%}
PHONY+=${EXECUTABLE_TARGETS:%=container-run/%}
${EXECUTABLE_TARGETS:%=container-run/%}:
$(MAKE) container-run COMMAND=${@:container-run/%=%}
# CONTAINER STEPS - CLEAN
# ==============================================================================
PHONY+=container-run/clean
container-run/clean:
$(MAKE) container-run COMMAND=${@:container-run/%=%}
# GENERAL CONTAINER COMMAND
# ==============================================================================
PHONY+=container-run
container-run:
${CONTAINER_RUNTIME} run \
--env CONTAINER_IMAGE_VERSION=${CONTAINER_IMAGE_VERSION} \
--env VERSION=${VERSION} \
--net=host \
--rm \
--volume /tmp:/tmp \
--volume "${HOME}/go:/root/go" \
--volume "$(shell pwd):$(shell pwd)" \
--workdir "$(shell pwd)" \
2021-06-10 11:08:56 +00:00
${BUILD_IMAGE_FULLY_QUALIFIED} \
make ${COMMAND}
# PHONY
# ==============================================================================
# Declare the contents of the PHONY variable as phony. We keep that information
# in a variable so we can use it in if_changed.
.PHONY: ${PHONY}