Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(buildDockerAndPublishImage.groovy): fix ath build #745

Merged
merged 8 commits into from
Sep 8, 2023
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 23 additions & 5 deletions resources/io/jenkins/infra/docker/Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
# Detect Windows (only OS separating paths in $PATH with ";") to set specific variable and function to get compatible paths
IMAGE_DIR ?= .
ifeq '$(findstring ;,$(PATH))' ';'
FixPath = $(subst /,\,$1)
IMAGE_DIR ?= .
else
FixPath = $1
IMAGE_DIR ?= $(PWD)
# need absolute path for docker bake
IMAGE_DIR := $(abspath $(PWD)/$(IMAGE_DIR))
endif

IMAGE_NAME ?= helloworld
IMAGE_DEPLOY_NAME ?= "$(IMAGE_NAME)"
BUILD_TARGETPLATFORM ?= linux/amd64
# Paths
IMAGE_DOCKERFILE ?= "$(IMAGE_DIR)"/Dockerfile
# need absolute path for docker bake
ifeq ($(IMAGE_DOCKERFILE),)
IMAGE_DOCKERFILE := $(abspath $(PWD)/Dockerfile)
else
IMAGE_DOCKERFILE := $(abspath $(PWD)/$(IMAGE_DOCKERFILE))
endif

HADOLINT_REPORT ?= "$(IMAGE_DIR)"/hadolint.json
TEST_HARNESS ?= "$(IMAGE_DIR)"/cst.yml
DOCKER_BAKE_FILE ?= "$(IMAGE_DIR)"/docker-bake.hcl
Expand All @@ -22,6 +29,16 @@ GIT_SCM_URL ?= $(shell git config --get remote.origin.url)
SCM_URI ?= $(subst [email protected]:,https://github.com/,"$(GIT_SCM_URL)")
BUILD_DATE ?= $(shell date --utc '+%Y-%m-%dT%H:%M:%S' 2>/dev/null || gdate --utc '+%Y-%m-%dT%H:%M:%S')

export IMAGE_DEPLOY_NAME \
TAG_NAME \
BAKE_TARGETPLATFORMS \
IMAGE_DOCKERFILE \
IMAGE_DIR \
GIT_COMMIT_REV \
GIT_SCM_URL \
BUILD_DATE \
SCM_URI
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export IMAGE_DEPLOY_NAME \
TAG_NAME \
BAKE_TARGETPLATFORMS \
IMAGE_DOCKERFILE \
IMAGE_DIR \
GIT_COMMIT_REV \
GIT_SCM_URL \
BUILD_DATE \
SCM_URI
export IMAGE_DEPLOY_NAME \
TAG_NAME \
BAKE_TARGETPLATFORMS \
IMAGE_DOCKERFILE \
IMAGE_DIR \
GIT_COMMIT_REV \
GIT_SCM_URL \
BUILD_DATE \
SCM_URI

nitpick: formatting


help: ## Show this Makefile's help
@echo "Help:"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
Expand Down Expand Up @@ -54,8 +71,9 @@ build: ## Build the Docker Image $(IMAGE_NAME) from $(IMAGE_DOCKERFILE)
@echo "== Build succeeded"

bake-build: ## Build the Docker Image(s) with dockerbake file
@echo "== Building from DockerBake file"
@docker buildx bake -f "$(call FixPath,$(DOCKER_BAKE_FILE))"
@echo "== Building from DockerBake file $(DOCKER_BAKE_FILE)"
@docker buildx bake -f "$(DOCKER_BAKE_FILE)"
@echo "== Build succeeded"


clean: ## Delete any file generated during the build steps
Expand Down