-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
105 lines (83 loc) · 4.58 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#
# Author: Elisabetta Iavarone
SHELL = /bin/sh
.DEFAULT_GOAL := help
export VCS_URL := $(shell git config --get remote.origin.url 2> /dev/null || echo unversioned repo)
export VCS_REF := $(shell git rev-parse --short HEAD 2> /dev/null || echo unversioned repo)
export VCS_STATUS := $(if $(shell git status -s 2> /dev/null || echo unversioned repo),'modified/untracked','clean')
export BUILD_DATE := $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
export DOCKER_IMAGE_NAME ?= jupyterlab-sparc
export DOCKER_IMAGE_TAG ?= 1.0.5
OSPARC_DIR:=$(CURDIR)/.osparc
APP_NAME := jupyterlab-sparc
# Builds new service version ----------------------------------------------------------------------------
define _bumpversion
# upgrades as $(subst $(1),,$@) version, commits and tags
@docker run -it --rm -v $(PWD):/${DOCKER_IMAGE_NAME} \
-u $(shell id -u):$(shell id -g) \
itisfoundation/ci-service-integration-library:v1.0.4 \
sh -c "cd /${DOCKER_IMAGE_NAME} && bump2version --verbose --list --config-file $(1) $(subst $(2),,$@)"
endef
.PHONY: version-patch version-minor version-major
version-patch version-minor version-major: .bumpversion.cfg ## increases service's version
@make compose-spec
@$(call _bumpversion,$<,version-)
@make compose-spec
.PHONY: compose-spec
compose-spec: ## runs ooil to assemble the docker-compose.yml file
@docker run --rm -v $(PWD):/${DOCKER_IMAGE_NAME} \
-u $(shell id -u):$(shell id -g) \
itisfoundation/ci-service-integration-library:v1.0.4 \
sh -c "cd /${DOCKER_IMAGE_NAME} && ooil compose"
build: | compose-spec ## build docker image
docker compose build
# To test built service locally -------------------------------------------------------------------------
.PHONY: run-local
run-local: ## runs image with local configuration
docker compose --file docker-compose-local.yml up
.PHONY: publish-local
publish-local: ## push to local oSPARC to test integration. It requires the oSPARC platform running on your computer, you can find more information here: https://github.com/ITISFoundation/osparc-simcore/blob/master/README.md
docker tag simcore/services/dynamic/${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG} registry:5000/simcore/services/dynamic/$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)
docker push registry:5000/simcore/services/dynamic/$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)
@curl registry:5000/v2/_catalog | jq
.PHONY: help
help: ## this colorful help
@echo "Recipes for '$(notdir $(CURDIR))':"
@echo ""
@awk 'BEGIN {FS = ":.*?## "} /^[[:alpha:][:space:]_-]+:.*?## / {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
@echo ""
# COOKIECUTTER -----------------------------------------------------------------
.PHONY: replay
replay: .cookiecutterrc ## re-applies cookiecutter
# Replaying git+ssh://[email protected]/ITISFoundation/cookiecutter-osparc-jupyterlab-service ...
@cookiecutter --no-input --overwrite-if-exists \
--config-file=$< \
--output-dir="$(abspath $(CURDIR)/..)" \
"git+ssh://[email protected]/ITISFoundation/cookiecutter-osparc-jupyterlab-service"
.PHONY: info
info: ## general info
# env vars: version control
@echo " VCS_URL : $(VCS_URL)"
@echo " VCS_REF : $(VCS_REF)"
@echo " VCS_STATUS : $(VCS_STATUS)"
# env vars: docker
@echo " DOCKER_IMAGE_TAG : $(DOCKER_IMAGE_TAG)"
@echo " BUILD_DATE : $(BUILD_DATE)"
# exe: recommended dev tools
@echo ' git : $(shell git --version 2>/dev/null || echo not found)'
@echo ' make : $(shell make --version 2>&1 | head -n 1)'
@echo ' jq : $(shell jq --version 2>/dev/null || echo not found z)'
@echo ' awk : $(shell awk -W version 2>&1 | head -n 1 2>/dev/null || echo not found)'
@echo ' python : $(shell python3 --version 2>/dev/null || echo not found )'
@echo ' docker : $(shell docker --version)'
@echo ' docker buildx : $(shell docker buildx version)'
@echo ' docker compose : $(shell docker compose --version)'
# MISC -----------------------------------------------------------------
.PHONY: clean
git_clean_args = -dxf --exclude=.vscode/
clean: ## cleans all unversioned files in project and temp files create by this makefile
# Cleaning unversioned
@git clean -n $(git_clean_args)
@echo -n "Are you sure? [y/N] " && read ans && [ $${ans:-N} = y ]
@echo -n "$(shell whoami), are you REALLY sure? [y/N] " && read ans && [ $${ans:-N} = y ]
@git clean $(git_clean_args)