@@ -92,6 +92,11 @@ ifdef PLATFORMS
9292 platforms_opt := $(call get_opts,platforms,$(PLATFORMS))
9393endif
9494
95+ # handle seek wait time
96+ seek_final_wait_time := 0
97+ ifdef SEEK_FINAL_WAIT_TIME
98+ seek_final_wait_time := $(SEEK_FINAL_WAIT_TIME)
99+ endif
95100
96101all : images
97102
@@ -104,34 +109,38 @@ compose-files: docker-compose.base.yml \
104109 docker-compose.monitoring.yml \
105110 settings.conf
106111
112+ log_path :
113+ mkdir -p /tmp/lifemonitor-logs
114+
107115prod :
108116 $(eval LM_MODE=prod)
109117
110118dev :
111119 $(eval LM_MODE=dev)
112120
113- certs :
114- @if ! [[ -f " certs/lm.key" && -f " certs/lm.key" && -f " certs/lifemonitor.ca.crt" ]]; then \
115- printf " \n$( bold) Generating certificates...$( reset) \n" ; \
116- mkdir -p certs && \
117- ./utils/certs/gencerts.sh && \
118- cp utils/certs/data/ca.* certs/ && \
119- cp utils/certs/data/lm/* .pem certs/ && \
120- mv certs/ca.pem certs/lifemonitor.ca.crt && \
121- mv certs/cert.pem certs/lm.crt && \
122- mv certs/key.pem certs/lm.key && \
123- chmod 644 certs/* .{key,crt}; \
124- printf " \n$( done) \n" ; \
121+ certs :
122+ @if ! [[ -f " certs/lm.key" && -f " certs/lifemonitor.ca.crt" ]]; then \
123+ printf " \n$( bold) Generating certificates...$( reset) \n" ; \
124+ mkdir -p certs && \
125+ ./utils/certs/gencerts.sh && \
126+ cp utils/certs/data/ca.* certs/ && \
127+ cp utils/certs/data/lm/* .pem certs/ && \
128+ mv certs/ca.pem certs/lifemonitor.ca.crt && \
129+ mv certs/cert.pem certs/lm.crt && \
130+ mv certs/key.pem certs/lm.key && \
131+ chmod 644 certs/* .{key,crt}; \
132+ cp -a " $$ (pwd)/certs/" $$(pwd ) /tests/config/registries/seek/certs ; \
133+ printf " \n$( done) \n" ; \
125134 else \
126- echo " $( yellow) WARNING: Using existing certificates$( reset) " ; \
135+ echo " $( yellow) WARNING: Using existing certificates$( reset) " ; \
127136 fi ; \
128137 if ! [[ -f " certs/jwt-key" && -f " certs/jwt-key.pub" ]]; then \
129- printf " \n$( bold) Generating JWT keys...$( reset) \n" ; \
130- openssl genrsa -out certs/jwt-key 4096 ; \
131- openssl rsa -in certs/jwt-key -pubout > certs/jwt-key.pub ; \
132- printf " \n$( done) \n" ; \
138+ printf " \n$( bold) Generating JWT keys...$( reset) \n" ; \
139+ openssl genrsa -out certs/jwt-key 4096 ; \
140+ openssl rsa -in certs/jwt-key -pubout > certs/jwt-key.pub ; \
141+ printf " \n$( done) \n" ; \
133142 else \
134- echo " $( yellow) WARNING: Using existing JWT keys $( reset) " ; \
143+ echo " $( yellow) WARNING: Using existing JWT keys $( reset) " ; \
135144 fi
136145
137146lifemonitor : docker/lifemonitor.Dockerfile certs app.py gunicorn.conf.py # # Build LifeMonitor Docker image
@@ -141,6 +150,7 @@ lifemonitor: docker/lifemonitor.Dockerfile certs app.py gunicorn.conf.py ## Buil
141150 printf " \n$( bold) Building LifeMonitor Docker image...$( reset) \n" ; \
142151 $(build_kit ) docker $(build_cmd ) \
143152 --build-arg USER_ID=$(id -u ) --build-arg GROUP_ID=$(id -g ) \
153+ --build-arg PIP_CACHE_DIR=/tmp/.buildx-cache/pip --build-arg NPM_CONFIG_CACHE=/tmp/.buildx-cache/npm \
144154 $(cache_from_opt ) $(cache_to_opt ) \
145155 ${sw_version_arg} ${build_number_arg} ${tags_opt} ${labels_opt} ${platforms_opt} \
146156 -f docker/lifemonitor.Dockerfile -t crs4/lifemonitor . ; \
@@ -186,17 +196,17 @@ permissions: certs
186196 settings.conf \
187197 tests/config/registries/seek/nginx.conf \
188198 tests/config/registries/seek/doorkeeper.rb \
189- && mkdir -p /tmp/lifemonitor-logs
199+ && mkdir -p /tmp/lifemonitor-logs && chmod a+rw /tmp/lifemonitor-logs
190200
191201
192202aux_images : tests/config/registries/seek/seek.Dockerfile certs
193203 @printf " \n$( bold) Building auxiliary Docker images...$( reset) \n" ; \
194- docker build -f tests/config/registries/seek/seek.Dockerfile \
195- -t crs4/lifemonitor-tests:seek \
196- tests/config/registries/seek/ ; \
204+ # docker build -f tests/config/registries/seek/seek.Dockerfile \
205+ # -t crs4/lifemonitor-tests:seek \
206+ # tests/config/registries/seek/ ; \
197207 printf " $( done) \n"
198208
199- start : images compose-files prod reset_compose permissions # # Start LifeMonitor in a Production environment
209+ start : images compose-files log_path prod reset_compose permissions # # Start LifeMonitor in a Production environment
200210 @printf " \n$( bold) Starting production services...$( reset) \n" ; \
201211 base=$$(if [[ -f "docker-compose.yml" ]]; then echo "-f docker-compose.yml"; fi) ; \
202212 echo " $$ (USER_UID=$$ (id -u) USER_GID=$$ (id -g) \
@@ -208,7 +218,7 @@ start: images compose-files prod reset_compose permissions ## Start LifeMonitor
208218 && $(docker_compose ) -f docker-compose.yml up -d redis db init lm worker ws_server nginx prometheus ; \
209219 printf " $( done) \n"
210220
211- start-dev : images compose-files dev reset_compose permissions # # Start LifeMonitor in a Development environment
221+ start-dev : images compose-files dev log_path reset_compose permissions # # Start LifeMonitor in a Development environment
212222 @printf " \n$( bold) Starting development services...$( reset) \n" ; \
213223 base=$$(if [[ -f "docker-compose.yml" ]]; then echo "-f docker-compose.yml"; fi) ; \
214224 echo " $$ (USER_UID=$$ (id -u) USER_GID=$$ (id -g) \
@@ -221,9 +231,8 @@ start-dev: images compose-files dev reset_compose permissions ## Start LifeMonit
221231 && $(docker_compose ) -f docker-compose.yml up -d redis db dev_proxy github_event_proxy init lm worker ws_server prometheus nginx ; \
222232 printf " $( done) \n"
223233
224- start-testing : compose-files aux_images ro_crates images reset_compose permissions # # Start LifeMonitor in a Testing environment
225- @printf " \n$( bold) Starting testing services...$( reset) \n" ; \
226- base=$$(if [[ -f "docker-compose.yml" ]]; then echo "-f docker-compose.yml"; fi) ; \
234+ .start-testing : compose-files aux_images ro_crates log_path images reset_compose permissions # # Start LifeMonitor in a Testing environment
235+ @base=$$(if [[ -f "docker-compose.yml" ]]; then echo "-f docker-compose.yml"; fi) ; \
227236 echo " $$ (USER_UID=$$ (id -u) USER_GID=$$ (id -g) \
228237 $(docker_compose ) $$ {base} \
229238 -f docker-compose.extra.yml \
@@ -233,12 +242,22 @@ start-testing: compose-files aux_images ro_crates images reset_compose permissio
233242 -f docker-compose.test.yml \
234243 config)" > docker-compose.yml \
235244 && cp {,.test.}docker-compose.yml \
236- && $(docker_compose ) -f docker-compose.yml up -d db lmtests seek jenkins webserver worker ws_server ; \
237- $(docker_compose ) -f ./docker-compose.yml \
238- exec -T lmtests /bin/bash -c " tests/wait-for-seek.sh 600" ; \
239- printf " $( done) \n"
245+ && $(docker_compose ) -f docker-compose.yml up -d db lmtests seek jenkins webserver worker ws_server \
246+ && $(docker_compose ) -f ./docker-compose.yml \
247+ exec -T lmtests /bin/bash -c " SEEK_FINAL_WAIT_TIME=$( seek_final_wait_time) tests/wait-for-seek.sh 600" \
248+ && $(docker_compose ) exec lmtests pytest tests/test_users.py::test_user1[RegistryType.SEEK] > /dev/null 2>&1 || echo " Testing environment initialized!" \
249+ && $(docker_compose ) restart db lmtests \
250+ && printf " $( done) \n"
251+
252+ start-testing :
253+ @printf " \n$( bold) Starting testing services...$( reset) \n " ; \
254+ if [ -f /tmp/.lifemonitor-testing-started ]; then \
255+ printf " $( yellow) WARNING: Testing environment already started, skipping...$( reset) " ; \
256+ else \
257+ $(MAKE ) .start-testing && touch /tmp/.lifemonitor-testing-started ; \
258+ fi
240259
241- start-maintenance : compose-files aux_images ro_crates images reset_compose permissions # # Start LifeMonitor in a Testing environment
260+ start-maintenance : compose-files aux_images ro_crates log_path images reset_compose permissions # # Start LifeMonitor in a Testing environment
242261 @printf " \n$( bold) Starting testing services...$( reset) \n" ; \
243262 base=$$(if [[ -f "docker-compose.yml" ]]; then echo "-f docker-compose.yml"; fi) ; \
244263 echo " $$ (USER_UID=$$ (id -u) USER_GID=$$ (id -g) \
@@ -278,8 +297,10 @@ start-aux-services: aux_images ro_crates docker-compose.extra.yml permissions ##
278297# && $(docker_compose) up -d jupyter ; \
279298# printf "$(done)\n"
280299
281- run-tests : start-testing # # Run all tests in the Testing Environment
282- @printf " \n$( bold) Running tests...$( reset) \n" ; \
300+ run-tests : # # Run all tests in the Testing Environment
301+ @export SKIP_RESET_COMPOSE=1 ; \
302+ $(MAKE ) start-testing ; \
303+ printf " \n$( bold) Running tests...$( reset) \n" ; \
283304 $(docker_compose ) exec -T lmtests /bin/bash -c " pytest --durations=10 --color=yes tests"
284305
285306
@@ -319,9 +340,11 @@ stop-testing: compose-files ## Stop all the services in the Testing Environment
319340 USER_UID=$$(id -u ) USER_GID=$$(id -g ) \
320341 $(docker_compose ) -f docker-compose.extra.yml \
321342 -f docker-compose.base.yml \
343+ -f docker-compose.monitoring.yml \
322344 -f docker-compose.dev.yml \
323345 -f docker-compose.test.yml \
324346 $(log_level_opt ) stop db lmtests seek jenkins webserver worker ws_server ; \
347+ rm -f /tmp/.lifemonitor-testing-started ; \
325348 printf " $( done) \n"
326349
327350stop-dev : compose-files # # Stop all services in the Develop Environment
@@ -353,7 +376,7 @@ stop-all: ## Stop all the services
353376
354377reset_compose :
355378 @if [[ $$ {SKIP_RESET_COMPOSE} -eq 1 ]]; then \
356- echo " $( bold) Skip reset of docker-compose services $( reset) " ; \
379+ echo -e " \n $( bold) Skip reset of docker-compose services $( reset) " ; \
357380 elif [[ -f " docker-compose.yml" ]]; then \
358381 cmp -s docker-compose.yml .$(LM_MODE ) .docker-compose.yml ; \
359382 RETVAL=$$? ; \
@@ -363,6 +386,7 @@ reset_compose:
363386 USER_UID=$$(id -u ) USER_GID=$$(id -g ) \
364387 $(docker_compose ) down ; \
365388 rm docker-compose.yml ; \
389+ rm -rf /tmp/.lifemonitor-testing-started ; \
366390 printf " $( done) \n" ; \
367391 fi \
368392 fi
@@ -372,6 +396,7 @@ down: ## Teardown all the services
372396 echo " $( bold) Teardown all services...$( reset) " ; \
373397 USER_UID=$$(id -u ) USER_GID=$$(id -g ) \
374398 $(docker_compose ) down ; \
399+ rm -rf /tmp/.lifemonitor-testing-started ; \
375400 printf " $( done) \n" ; \
376401 else \
377402 printf " \n$( yellow) WARNING: nothing to remove. 'docker-compose.yml' file not found!$( reset) \n\n" ; \
@@ -387,8 +412,9 @@ clean: ## Clean up the working environment (i.e., running services, network, vol
387412 printf " $( yellow) WARNING: nothing to remove. 'docker-compose.yml' file not found!$( reset) \n" ; \
388413 fi
389414 @printf " \n$( bold) Removing certs...$( reset) " ; \
390- rm -rf certs
391- rm -rf utils/certs/data
415+ rm -rf certs && rm -rf utils/certs/data && rm -rf tests/config/registries/seek/certs \
416+ rm -rf /tmp/lifemonitor-logs \
417+ rm -rf /tmp/.lifemonitor-testing-started \
392418 @printf " $( done) \n"
393419 @printf " \n$( bold) Removing temp files...$( reset) " ; \
394420 rm -rf {,.prod.,.dev.,.test.}docker-compose.yml
@@ -399,9 +425,9 @@ clean: ## Clean up the working environment (i.e., running services, network, vol
399425help : # # Show help
400426 @awk ' BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST )
401427
402- .PHONY : all images aux_images certs prod dev \
428+ .PHONY : all images aux_images prod dev certs \
403429 lifemonitor smeeio ro_crates webserver \
404- start start-dev start-testing start-nginx start-aux-services \
430+ start start-dev start-testing .start-testing start-nginx start-aux-services \
405431 run-tests tests \
406432 stop-aux-services stop-nginx stop-testing \
407433 stop-dev stop stop-all down reset_compose clean
0 commit comments