1
1
#
2
- # Author: Lucia Moya- Sans
2
+ # Author: Lucia Moya Sans
3
3
4
4
SHELL = /bin/sh
5
5
.DEFAULT_GOAL := help
@@ -9,117 +9,59 @@ export VCS_REF := $(shell git rev-parse --short HEAD 2> /dev/null || echo unv
9
9
export VCS_STATUS := $(if $(shell git status -s 2> /dev/null || echo unversioned repo) ,'modified/untracked','clean')
10
10
export BUILD_DATE := $(shell date -u +"% Y-% m-% dT% H:% M:% SZ")
11
11
12
- export DOCKER_REGISTRY ?= itisfoundation
13
12
export DOCKER_IMAGE_NAME ?= pymorphosonic
14
- export DOCKER_IMAGE_TAG ?= $(shell cat VERSION 2> /dev/null || echo undefined)
15
-
13
+ export DOCKER_IMAGE_TAG ?= 0.1.0
16
14
17
15
OSPARC_DIR: =$(CURDIR ) /.osparc
18
16
19
17
APP_NAME := pymorphosonic
20
18
19
+ # Builds new service version ----------------------------------------------------------------------------
21
20
22
-
23
-
24
- # INTEGRATION -----------------------------------------------------------------
25
- METADATA := .osparc/metadata.yml
26
-
27
-
28
- .PHONY : VERSION
29
- VERSION : $(METADATA ) # # generates VERSION from metadata
30
- # updating $@ from $<
31
- @$(OSPARC_DIR ) /bin/ooil get-version --metadata-file $< > $@
32
-
33
- service.cli/run : $(METADATA ) # # generates run from metadata
34
- # Updates adapter script from metadata in $<
35
- @$(OSPARC_DIR ) /bin/ooil run-creator --metadata $< --runscript $@
36
-
37
- docker-compose.yml : $(METADATA ) # # generates docker-compose
38
- # Injects metadata from $< as labels
39
- @$(OSPARC_DIR ) /bin/ooil compose --to-spec-file $@ --metadata $<
40
-
41
-
42
-
43
- # BUILD -----------------------------------------------------------------
44
-
45
- define _docker_compose_build
46
- export DOCKER_BUILD_TARGET =$(if $(findstring -devel,$@ ) ,development,$(if $(findstring -cache,$@ ) ,cache,production) ) ; \
47
- docker compose -f docker-compose.yml build $(if $(findstring -nc,$@ ) ,--no-cache,) ;
48
- endef
49
-
50
-
51
- .PHONY : build build-devel build-nc build-devel-nc
52
- build build-devel build-nc build-devel-nc : VERSION docker-compose.yml service.cli/run # # builds image
53
- # building image local/${DOCKER_IMAGE_NAME}...
54
- @$(call _docker_compose_build)
55
-
56
- define show-meta
57
- $(foreach iid,$(shell docker images * /$(1 ) :* -q | sort | uniq) ,\
58
- docker image inspect $(iid ) | jq '.[0] | .RepoTags, .ContainerConfig.Labels, .Config.Labels';)
21
+ define _bumpversion
22
+ # upgrades as $(subst $(1),,$@) version, commits and tags
23
+ @docker run -it --rm -v $(PWD ) :/${DOCKER_IMAGE_NAME} \
24
+ -u $(shell id -u) :$(shell id -g) \
25
+ itisfoundation/ci-service-integration-library:latest \
26
+ sh -c "cd /${DOCKER_IMAGE_NAME} && bump2version --verbose --list --config-file $(1 ) $(subst $(2 ) ,,$@ ) "
59
27
endef
60
28
29
+ .PHONY : version-patch version-minor version-major
30
+ version-patch version-minor version-major : .bumpversion.cfg # # increases service's version
31
+ @make compose-spec
32
+ @$(call _bumpversion,$< ,version-)
33
+ @make compose-spec
61
34
62
- .PHONY : info-build
63
- info-build : # # displays info on the built image
64
- # Built images
65
- @docker images * /$(DOCKER_IMAGE_NAME ) :*
66
- # Tags and labels
67
- @$(call show-meta,$(DOCKER_IMAGE_NAME ) )
68
-
69
-
70
- # TESTS-----------------------------------------------------------------
71
- .PHONY : test tests
72
- test tests : # # runs validation tests
73
- @$(OSPARC_DIR ) /bin/ooil test .
74
-
75
-
76
-
77
- # PUBLISHING -----------------------------------------------------------------
35
+ .PHONY : compose-spec
36
+ compose-spec : # # runs ooil to assemble the docker-compose.yml file
37
+ @docker run --rm -v $(PWD ) :/${DOCKER_IMAGE_NAME} \
38
+ -u $(shell id -u) :$(shell id -g) \
39
+ itisfoundation/ci-service-integration-library:latest \
40
+ sh -c " cd /${DOCKER_IMAGE_NAME} && ooil compose"
78
41
79
- .PHONY : version-service-patch version-service-minor version-service-major
80
- version-service-patch version-service-minor version-service-major : $(METADATA ) # # kernel/service versioning as patch
81
- $(OSPARC_DIR ) /bin/ooil bump-version --metadata-file $< --upgrade $(subst version-service-,,$@ )
82
- # syncing metadata upstream
83
- @$(MAKE ) VERSION
42
+ build : | compose-spec # # build docker image
43
+ docker compose build
84
44
85
-
86
- .PHONY : tag-local
87
- tag-local :
88
- docker tag ${DOCKER_REGISTRY} /${DOCKER_IMAGE_NAME} :$(if $(findstring version,$@ ) ,$(DOCKER_IMAGE_NAME ) ,latest) local/$(DOCKER_IMAGE_NAME ) :production
89
-
90
- .PHONY : push push-force push-version push-latest pull-latest pull-version tag-latest tag-version
91
- tag-latest tag-version :
92
- docker tag simcore/services/comp/${DOCKER_IMAGE_NAME} :${DOCKER_IMAGE_TAG} $(DOCKER_REGISTRY ) /$(DOCKER_IMAGE_NAME ) :$(if $(findstring version,$@ ) ,$(DOCKER_IMAGE_TAG ) ,latest)
93
-
94
- version_valid = $(shell test $$(echo $(DOCKER_IMAGE_TAG ) | cut --fields=1 --delimiter=. ) -gt 0 > /dev/null && echo "image version is valid")
95
- version_exists = $(shell DOCKER_CLI_EXPERIMENTAL=enabled docker manifest inspect $(DOCKER_REGISTRY ) /$(DOCKER_IMAGE_NAME ) :$(DOCKER_IMAGE_TAG ) > /dev/null && echo "image already exists on $(DOCKER_REGISTRY ) ")
96
- push push-force : # # pushes (resp. force) services to the registry if service not available in registry.
97
- @$(if $(findstring force,$@ ) ,,\
98
- $(if $(call version_valid) ,$(info version is valid) , $(error $(DOCKER_IMAGE_TAG ) is not a valid version (major>=1) ) )\
99
- $(if $(call version_exists) ,$(error $(DOCKER_REGISTRY ) /$(DOCKER_IMAGE_NAME ) :$(DOCKER_IMAGE_TAG ) already exists on $(DOCKER_REGISTRY ) ) , $(info no version found on $(DOCKER_REGISTRY ) ) ) \
100
- )
101
- @$(MAKE ) push-version;
102
- @$(MAKE ) push-latest;
45
+ # To test built service locally -------------------------------------------------------------------------
46
+ .PHONY : run-local
47
+ run-local : # # runs image with local configuration
48
+ docker compose --file docker-compose-local.yml up
103
49
104
50
.PHONY : publish-local
105
51
publish-local : # # push to local throw away registry to test integration
106
52
docker tag simcore/services/comp/${DOCKER_IMAGE_NAME} :${DOCKER_IMAGE_TAG} registry:5000/simcore/services/comp/$(DOCKER_IMAGE_NAME ) :$(DOCKER_IMAGE_TAG )
107
53
docker push registry:5000/simcore/services/comp/$(DOCKER_IMAGE_NAME ) :$(DOCKER_IMAGE_TAG )
108
54
@curl registry:5000/v2/_catalog | jq
109
-
110
- push-latest push-version : # # publish service to registry with latest/version tag
111
- # pushing '$(DOCKER_REGISTRY)/$(DOCKER_IMAGE_NAME):$(if $(findstring version,$@),$(DOCKER_IMAGE_TAG),latest)'...
112
- @$(MAKE ) tag-$(subst push-,,$@ )
113
- @docker push $(DOCKER_REGISTRY ) /$(DOCKER_IMAGE_NAME ) :$(if $(findstring version,$@ ) ,$(DOCKER_IMAGE_TAG ) ,latest)
114
- # pushed '$(DOCKER_REGISTRY)/$(DOCKER_IMAGE_NAME):$(if $(findstring version,$@),$(DOCKER_IMAGE_TAG),latest)'
115
-
116
- pull-latest pull-version : # # pull service from registry
117
- @docker pull $(DOCKER_REGISTRY ) /$(DOCKER_IMAGE_NAME ) :$(if $(findstring version,$@ ) ,$(DOCKER_IMAGE_TAG ) ,latest)
118
-
119
55
56
+ .PHONY : help
57
+ help : # # this colorful help
58
+ @echo " Recipes for '$( notdir $( CURDIR) ) ':"
59
+ @echo " "
60
+ @awk ' BEGIN {FS = ":.*?## "} /^[[:alpha:][:space:]_-]+:.*?## / {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST )
61
+ @echo " "
120
62
121
63
122
- # COOCKIECUTTER -----------------------------------------------------------------
64
+ # COOKIECUTTER -----------------------------------------------------------------
123
65
124
66
.PHONY : replay
125
67
replay : .cookiecutterrc # # re-applies cookiecutter
@@ -130,16 +72,13 @@ replay: .cookiecutterrc ## re-applies cookiecutter
130
72
" gh:ITISFoundation/cookiecutter-osparc-service"
131
73
132
74
133
-
134
75
.PHONY : info
135
76
info : # # general info
136
77
# env vars: version control
137
78
@echo " VCS_URL : $( VCS_URL) "
138
79
@echo " VCS_REF : $( VCS_REF) "
139
80
@echo " VCS_STATUS : $( VCS_STATUS) "
140
81
# env vars: docker
141
- @echo " DOCKER_REGISTRY : $( DOCKER_REGISTRY) "
142
- @echo " DOCKER_IMAGE_NAME : $( DOCKER_IMAGE_NAME) "
143
82
@echo " DOCKER_IMAGE_TAG : $( DOCKER_IMAGE_TAG) "
144
83
@echo " BUILD_DATE : $( BUILD_DATE) "
145
84
# exe: recommended dev tools
@@ -150,21 +89,10 @@ info: ## general info
150
89
@echo ' python : $(shell python3 --version 2>/dev/null || echo not found )'
151
90
@echo ' docker : $(shell docker --version)'
152
91
@echo ' docker buildx : $(shell docker buildx version)'
153
- @echo ' docker-compose : $(shell docker-compose --version)'
154
- # exe: integration tools
155
- @echo ' ooil version : $(shell $(OSPARC_DIR)/bin/ooil --version)'
156
-
157
-
92
+ @echo ' docker compose : $(shell docker compose --version)'
158
93
159
94
# MISC -----------------------------------------------------------------
160
95
161
- .PHONY : help
162
- help : # # this colorful help
163
- @echo " Recipes for '$( notdir $( CURDIR) ) ':"
164
- @echo " "
165
- @awk --posix ' BEGIN {FS = ":.*?## "} /^[[:alpha:][:space:]_-]+:.*?## / {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST )
166
- @echo " "
167
-
168
96
169
97
.PHONY : clean
170
98
git_clean_args = -dxf --exclude=.vscode/
@@ -174,4 +102,4 @@ clean: ## cleans all unversioned files in project and temp files create by this
174
102
@git clean -n $(git_clean_args )
175
103
@echo -n " Are you sure? [y/N] " && read ans && [ $$ {ans:-N} = y ]
176
104
@echo -n " $( shell whoami) , are you REALLY sure? [y/N] " && read ans && [ $$ {ans:-N} = y ]
177
- @git clean $(git_clean_args )
105
+ @git clean $(git_clean_args )
0 commit comments