-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Updates cookiecutter with non-invasive Makefile and prepare for dyn…
…amic-services (#108)
- Loading branch information
Showing
3 changed files
with
82 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
|
||
.DEFAULT_GOAL := help | ||
SHELL := /bin/bash | ||
|
||
|
||
REPO_DIR := $(abspath $(CURDIR)/..) | ||
|
||
# NOTE that IMAGES variable can change when docker-compose.yml gets rebuilt. Do NOT use := !!! | ||
IMAGES = $(shell ./bin/yq.bash eval '.services.*.image' docker-compose.yml) | ||
|
||
export DOCKER_REGISTRY ?= registry:5000 | ||
|
||
|
||
.PHONY: info | ||
info: ## lists environments and required tools | ||
# tools | ||
@echo 'docker : $(shell docker --version 2>/dev/null || echo ERROR required tool missing )' | ||
@echo 'docker compose : $(shell docker compose version 2>/dev/null || echo ERROR required tool missing )' | ||
@echo 'docker buildx : $(shell docker buildx version 2>/dev/null || echo WARNING optional tool missing )' | ||
@echo 'make : $(shell make --version 2>&1 | head -n 1)' | ||
@echo 'awk : $(shell awk -W version 2>&1 | head -n 1)' | ||
@echo 'sed : $(shell sed --version 2>&1 | head -n 1)' | ||
# environments | ||
@echo "REPO_DIR = ${REPO_DIR}" | ||
@echo "IMAGES = ${IMAGES}" | ||
@echo "DOCKER_REGISTRY = ${DOCKER_REGISTRY}" | ||
|
||
|
||
.PHONY: update-version | ||
update-version: | ||
cd $(REPO_DIR) \ | ||
&& . update_version.sh \ | ||
&& cd - | ||
|
||
.PHONY: compose | ||
compose: update-version ## creates docker-compose.yml | ||
# creating compose specs | ||
cd $(REPO_DIR) \ | ||
&& .osparc/bin/ooil.bash compose -f .osparc/docker-compose.yml | ||
|
||
|
||
.PHONY: build build-nc | ||
build build-nc: compose ## builds image. Suffix -nc disables cache | ||
# building | ||
docker compose build $(if $(findstring -nc,$@),--no-cache,) | ||
|
||
|
||
.PHONY: push | ||
push: ## retags and pushes to ${DOCKER_REGISTRY} | ||
# tag & push | ||
@for image in ${IMAGES}; do \ | ||
echo "Tagging and pushing ${DOCKER_REGISTRY}/$$image ..."; \ | ||
docker tag "$$image" "${DOCKER_REGISTRY}/$$image"; \ | ||
docker push "${DOCKER_REGISTRY}/$$image"; \ | ||
done | ||
# registry view | ||
@curl --silent ${DOCKER_REGISTRY}/v2/_catalog | jq | ||
|
||
|
||
|
||
.PHONY: all | ||
all: compose build-nc push ## all workflow | ||
@echo "'${IMAGES}' built, and pushed to '${DOCKER_REGISTRY}'" | ||
|
||
|
||
.PHONY: help | ||
help: ## help on rule's targets | ||
@awk --posix 'BEGIN {FS = ":.*?## "} /^[[:alpha:][:space:]_-]+:.*?## / {printf "%-20s %s\n", $$1, $$2}' $(MAKEFILE_LIST) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
|
||
# Define variables | ||
YQ_IMAGE="mikefarah/yq" | ||
YQ_VERSION="4.12.0" | ||
|
||
# Define function to run yq inside container | ||
run_yq() { | ||
docker run --rm -v "$(pwd):/workdir" "$YQ_IMAGE:$YQ_VERSION" "$@" | ||
} | ||
|
||
# Call function with arguments | ||
run_yq "$@" |