From f928efad52f2d839ba9139b83517839b431b9085 Mon Sep 17 00:00:00 2001 From: Niklas Kapelle Date: Tue, 7 Nov 2023 17:54:36 +0100 Subject: [PATCH] improved docker commands --- {{cookiecutter.project_slug}}/Makefile | 13 ++++++++++--- {{cookiecutter.project_slug}}/README.md | 3 +-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/{{cookiecutter.project_slug}}/Makefile b/{{cookiecutter.project_slug}}/Makefile index 7771023..268c6fb 100644 --- a/{{cookiecutter.project_slug}}/Makefile +++ b/{{cookiecutter.project_slug}}/Makefile @@ -2,6 +2,9 @@ BINARY = {{cookiecutter.project_slug}} BUILD_DIR = build BUILD_ARCH = $(shell go env GOARCH) BUILD_OS = $(shell go env GOOS) +DOCKER_BUILD_FLAGS = +DOCKER_BUILD_PLATFORM = linux/amd64,linux/arm64,linux/arm32v6,linux/arm32v7 +DOCKER_BUILD_TAG = {{cookiecutter.docker_username}}/{{cookiecutter.project_slug}} .PHONY: all all: clean build @@ -16,6 +19,10 @@ $(BUILD_DIR)/$(BINARY): clean: rm -rf $(BUILD_DIR) -.PHONY: docker -docker: - docker buildx build --platform linux/arm64,linux/amd64,linux/arm/v7,linux/arm64/v8 -t djeeberjr/{{cookiecutter.project_slug}} . --push +.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 diff --git a/{{cookiecutter.project_slug}}/README.md b/{{cookiecutter.project_slug}}/README.md index a3a0d57..c092df1 100644 --- a/{{cookiecutter.project_slug}}/README.md +++ b/{{cookiecutter.project_slug}}/README.md @@ -6,5 +6,4 @@ ## Build and push docker image -`make docker` - +To build the image localy run `make docker-local` and to build and push `make docker-push`.