dockron/Makefile

89 lines
2.5 KiB
Makefile
Raw Normal View History

2019-06-07 22:40:04 +00:00
DOCKER_TAG ?= dockron-dev-${USER}
2019-06-28 17:24:41 +00:00
GIT_TAG_NAME := $(shell git tag -l --contains HEAD)
GIT_SHA := $(shell git rev-parse HEAD)
VERSION := $(if $(GIT_TAG_NAME),$(GIT_TAG_NAME),$(GIT_SHA))
2018-08-03 18:35:49 +00:00
2018-08-03 01:11:07 +00:00
.PHONY: default
default: build
# Downloads dependencies into vendor directory
vendor:
2019-06-08 00:08:15 +00:00
go mod vendor
2018-08-03 01:11:07 +00:00
# Runs the application, useful while developing
.PHONY: run
2019-06-08 00:08:15 +00:00
run:
2018-08-03 01:11:07 +00:00
go run *.go
# Output target
2018-08-04 02:22:54 +00:00
dockron: vendor
2019-06-28 17:24:41 +00:00
@echo Version: $(VERSION)
go build -ldflags '-X "main.version=${VERSION}"' -o dockron
2018-08-03 01:11:07 +00:00
# Alias for building
.PHONY: build
2018-08-04 02:22:54 +00:00
build: dockron
2018-08-03 01:11:07 +00:00
2019-06-28 17:24:41 +00:00
dockron-darwin-amd64: vendor
GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 \
go build -ldflags '-X "main.version=${VERSION}"' -a -installsuffix nocgo \
-o dockron-darwin-amd64
2019-06-07 22:40:04 +00:00
dockron-linux-amd64: vendor
2019-06-28 17:24:41 +00:00
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 \
go build -ldflags '-X "main.version=${VERSION}"' -a -installsuffix nocgo \
-o dockron-linux-amd64
2019-06-07 22:40:04 +00:00
dockron-linux-arm: vendor
2019-06-28 17:24:41 +00:00
GOOS=linux GOARCH=arm CGO_ENABLED=0 \
go build -ldflags '-X "main.version=${VERSION}"' -a -installsuffix nocgo \
-o dockron-linux-arm
2019-06-07 22:40:04 +00:00
dockron-linux-arm64: vendor
2019-06-28 17:24:41 +00:00
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 \
go build -ldflags '-X "main.version=${VERSION}"' -a -installsuffix nocgo \
-o dockron-linux-arm64
.PHONY: build-linux-static
build-linux-static: dockron-linux-amd64 dockron-linux-arm dockron-linux-arm64
2019-06-07 22:40:04 +00:00
.PHONY: build-all-static
2019-06-28 17:24:41 +00:00
build-all-static: dockron-darwin-amd64 build-linux-static
2019-06-07 22:40:04 +00:00
2018-08-03 01:11:07 +00:00
# Cleans all build artifacts
.PHONY: clean
clean:
2019-06-08 00:08:15 +00:00
rm -f dockron
rm -f dockron-linux-*
2018-08-03 01:11:07 +00:00
# Cleans vendor directory
.PHONY: clean-vendor
clean-vendor:
rm -fr ./vendor
2018-08-03 18:35:49 +00:00
.PHONY: docker-build
docker-build:
2019-06-07 22:40:04 +00:00
docker build . -t ${DOCKER_TAG}-linux-amd64
# Cross build for arm architechtures
.PHONY: docker-cross-build-arm
docker-cross-build-arm:
docker build --build-arg REPO=arm32v7 --build-arg ARCH=arm . -t ${DOCKER_TAG}-linux-arm
2019-06-07 22:40:04 +00:00
.PHONY: docker-cross-build-arm
docker-cross-build-arm64:
docker build --build-arg REPO=arm64v8 --build-arg ARCH=arm64 . -t ${DOCKER_TAG}-linux-arm64
2018-08-03 18:35:49 +00:00
.PHONY: docker-run
2019-06-07 22:40:04 +00:00
docker-run: docker-build
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock --name $(DOCKER_TAG)-run $(DOCKER_TAG)-linux-amd64
# Cross run on host architechture
.PHONY: docker-cross-run-arm
docker-cross-run-arm: docker-cross-build-arm
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock --name $(DOCKER_TAG)-run ${DOCKER_TAG}-linux-arm
.PHONY: docker-cross-run-arm64
docker-cross-run-arm64: docker-cross-build-arm64
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock --name $(DOCKER_TAG)-run ${DOCKER_TAG}-linux-arm64