improved docker commands

This commit is contained in:
Niklas Kapelle 2023-11-07 17:54:36 +01:00
parent 93eea1fad0
commit f928efad52
Signed by: niklas
GPG Key ID: 4EB651B36D841D16
2 changed files with 11 additions and 5 deletions

View File

@ -2,6 +2,9 @@ BINARY = {{cookiecutter.project_slug}}
BUILD_DIR = build BUILD_DIR = build
BUILD_ARCH = $(shell go env GOARCH) BUILD_ARCH = $(shell go env GOARCH)
BUILD_OS = $(shell go env GOOS) 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 .PHONY: all
all: clean build all: clean build
@ -16,6 +19,10 @@ $(BUILD_DIR)/$(BINARY):
clean: clean:
rm -rf $(BUILD_DIR) rm -rf $(BUILD_DIR)
.PHONY: docker .PHONY: docker-push
docker: docker-push:
docker buildx build --platform linux/arm64,linux/amd64,linux/arm/v7,linux/arm64/v8 -t djeeberjr/{{cookiecutter.project_slug}} . --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

View File

@ -6,5 +6,4 @@
## Build and push docker image ## Build and push docker image
`make docker` To build the image localy run `make docker-local` and to build and push `make docker-push`.