Skip to content

Commit

Permalink
debug makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
fqjony committed Dec 23, 2024
1 parent afaaf5e commit 19e12ad
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ jobs:
uses: docker/setup-buildx-action@v3

- name: Run Development Pipeline
# run: make dev-pipeline
run: MULTIPLATFORM=true make dev-pipeline
run: make dev-pipeline
# run: MULTIPLATFORM=true make dev-pipeline
working-directory: .
env:
AZURE_CREDS: ${{ secrets.AZURE_CREDS }}
Expand Down
28 changes: 20 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,30 @@ build:
fi
@echo "Docker image build completed."

# Evaluate JSON credentials environment variables
JSON_CREDS_ENV := $(if $(wildcard *.json),\
$(foreach file,$(wildcard *.json),\
$(eval CREDS_VAR_NAME := $(shell echo "$(file)" | sed -e 's/\.json//g' -e 's/\./_/g' | tr '[:lower:]' '[:upper:]')) \
$(eval CREDS_VAR_VALUE := $(shell cat "$(file)" | jq -c .)) \
-e $(CREDS_VAR_NAME)='$(CREDS_VAR_VALUE)' \
)\
)

# Evaluate %_CREDS environment variables
CREDS_ENV := $(if $(filter %_CREDS,$(.VARIABLES)),\
$(foreach env_var,$(filter %_CREDS,$(.VARIABLES)),\
-e $(env_var)=$($(env_var)) \
)\
)

# Run Docker container (supports interactive mode)
run: clean
@echo "Running Docker container..."
@echo "Docker image: $(DOCKER_IMAGE)"
@echo "Docker command: $(COMMAND)"
@docker run $(if $(INTERACTIVE),-it,-d) --rm --name $(CONTAINER_NAME) \
$(foreach file,$(wildcard *.json),\
$(eval CREDS_VAR_NAME=$(shell echo "$(file)" | sed -e 's/\.json//g' -e 's/\./_/g' | tr '[:lower:]' '[:upper:]')) \
$(eval CREDS_VAR_VALUE=$(shell cat "$(file)" | jq -c .)) \
-e $(CREDS_VAR_NAME)='$(CREDS_VAR_VALUE)' \
) \
$(foreach env_var,$(filter %_CREDS,$(.VARIABLES)),\
-e $(env_var)=$($(env_var)) \
) \
$(JSON_CREDS_ENV) \
$(CREDS_ENV) \
$(foreach vol,$(VOLUMES),-v $(vol)) \
$(DOCKER_IMAGE) $(COMMAND)
$(if $(filter false,$(INTERACTIVE)),docker logs -f $(CONTAINER_NAME);)
Expand Down

0 comments on commit 19e12ad

Please sign in to comment.