cookiecutter-golang/{{cookiecutter.project_slug}}/Makefile

33 lines
878 B
Makefile
Raw Permalink Normal View History

2023-09-05 14:44:53 +00:00
BINARY = {{cookiecutter.project_slug}}
BUILD_DIR = build
BUILD_ARCH = $(shell go env GOARCH)
BUILD_OS = $(shell go env GOOS)
2023-11-07 16:54:36 +00:00
DOCKER_BUILD_FLAGS =
DOCKER_BUILD_PLATFORM = linux/amd64,linux/arm64,linux/arm32v6,linux/arm32v7
DOCKER_BUILD_TAG = {{cookiecutter.docker_username}}/{{cookiecutter.project_slug}}
2023-09-05 14:44:53 +00:00
.PHONY: all
all: clean build
.PHONY:build
build: $(BUILD_DIR)/$(BINARY)
$(BUILD_DIR)/$(BINARY):
GOARCH=$(BUILD_ARCH) GOOS=$(BUILD_OS) go build -o $(BUILD_DIR)/$(BINARY) cmd/{{cookiecutter.project_slug}}.go
.PHONY:clean
clean:
rm -rf $(BUILD_DIR)
2023-11-07 16:58:02 +00:00
.PHONY: dev
dev:
go run cmd/{{cookiecutter.project_slug}}.go
2023-11-07 16:54:36 +00:00
.PHONY: docker-push
docker-push:
docker buildx build $(DOCKER_BUILD_FLAGS) --platform $(DOCKER_BUILD_PLATFORM) -t $(DOCKER_BUILD_TAG) . --push
.PHONY: docker-local
docker-local:
docker buildx build $(DOCKER_BUILD_FLAGS) -t $(DOCKER_BUILD_TAG) . --load