Skip to content

Commit 4100b87

Browse files
committed
Merge remote-tracking branch 'upstream/main'
2 parents ac44663 + 3e9c5e8 commit 4100b87

File tree

27 files changed

+323
-124
lines changed

27 files changed

+323
-124
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ certificates/domain.key:
2626
# Done: Creating docker secrets
2727

2828
.PHONY: up-local
29-
up-local: .init .venv .install-fqdn certificates/domain.crt certificates/domain.key .create-secrets ## deploy osparc ops stacks and simcore, use minio_disabled=1 if minio s3 should not be started (if you have custom S3 set up)
29+
up-local: .init venv .install-fqdn certificates/domain.crt certificates/domain.key .create-secrets ## deploy osparc ops stacks and simcore, use minio_disabled=1 if minio s3 should not be started (if you have custom S3 set up)
3030
@bash scripts/deployments/deploy_everything_locally.bash --stack_target=local --minio_enabled=0 --vcs_check=1
3131
@$(MAKE) info-local
3232

scripts/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
wait4x

scripts/common.Makefile

Lines changed: 99 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -267,48 +267,121 @@ endif
267267
fi
268268
269269
# Helpers -------------------------------------------------
270-
# Replace the existing .venv target with the following
271-
$(REPO_BASE_DIR)/.venv/bin/activate:
272-
# creating virtual environment with tooling (jinja, etc)
273-
python3 -m venv $(REPO_BASE_DIR)/.venv
274-
$(REPO_BASE_DIR)/.venv/bin/pip3 install --upgrade pip wheel setuptools
275-
$(REPO_BASE_DIR)/.venv/bin/pip3 install jinja2 j2cli[yaml] typer
276-
@echo "To activate the venv, execute 'source $(REPO_BASE_DIR)/.venv/bin/activate'"
277-
.PHONY: .venv
278-
.venv: $(REPO_BASE_DIR)/.venv/bin/activate ## Creates a python virtual environment with dev tools (pip, pylint, ...)
279-
.PHONY: venv
280-
venv: $(REPO_BASE_DIR)/.venv/bin/activate ## Creates a python virtual environment with dev tools (pip, pylint, ...)
270+
271+
# Check that given variables are set and all have non-empty values,
272+
# die with an error otherwise.
273+
#
274+
# Params:
275+
# 1. Variable name(s) to test.
276+
# 2. (optional) Error message to print.
277+
guard-%:
278+
@ if [ "${${*}}" = "" ]; then \
279+
echo "Argument '$*' is missing. TIP: make <rule> $*=<value>"; \
280+
exit 1; \
281+
fi
282+
283+
# Explicitly define optional arguments
284+
# do nothing target https://stackoverflow.com/a/46648773/12124525
285+
guard-optional-%:
286+
@:
287+
288+
# Gracefully use defaults and potentially overwrite them, via https://stackoverflow.com/a/49804748
289+
%: %-default
290+
@ true
291+
292+
#
293+
# Automatic VENV management
294+
#
295+
# Inspired from https://potyarkin.com/posts/2019/manage-python-virtual-environment-from-your-makefile/
296+
297+
VENV_DIR=$(REPO_BASE_DIR)/.venv
298+
VENV_BIN=$(VENV_DIR)/bin
299+
300+
# NOTE: this is because the gitlab CI does not allow to source cargon/env on the fly
301+
UV := $$HOME/.local/bin/uv
302+
303+
$(UV):
304+
@if [ ! -f $@ ]; then \
305+
echo "Installing uv..."; \
306+
curl -LsSf https://astral.sh/uv/install.sh | sh; \
307+
fi
308+
309+
UVX := $$HOME/.local/bin/uvx
310+
$(UVX): $(UV)
311+
312+
# Use venv for any target that requires virtual environment to be created and configured
313+
venv: $(VENV_DIR) ## configure repo's virtual environment
314+
$(VENV_BIN): $(VENV_DIR)
315+
316+
$(VENV_DIR): $(UV)
317+
@if [ ! -d $@ ]; then \
318+
$< venv $@; \
319+
VIRTUAL_ENV=$@ $< pip install --upgrade pip wheel setuptools; \
320+
VIRTUAL_ENV=$@ $< pip install jinja2 j2cli[yaml] typer; \
321+
$(VENV_BIN)/pre-commit install > /dev/null 2>&1; \
322+
$(UV) self update || true; \
323+
fi
324+
325+
# Ensure tool is available or fail otherwise
326+
#
327+
# USAGE:
328+
#
329+
# codestyle: $(VENV_BIN)/pyflakes
330+
# $(VENV_BIN)/pyflakes .
331+
#
332+
$(VENV_BIN)/%: $(VENV_DIR)
333+
@if [ ! -f "$@" ]; then \
334+
echo "ERROR: '$*' is not found in $(VENV_BIN)"; \
335+
exit 1; \
336+
fi
337+
338+
.PHONY: show-venv
339+
show-venv: venv ## show venv info
340+
@$(VENV_BIN)/python -c "import sys; print('Python ' + sys.version.replace('\n',''))"
341+
@$(UV) --version
342+
@echo venv: $(VENV_DIR)
343+
344+
.PHONY: install
345+
install: guard-optional-REQUIREMENTS_FILE venv ## install requirements.txt dependencies
346+
@if [ -z "$(REQUIREMENTS_FILE)" ]; then \
347+
REQUIREMENTS_FILE=./requirements.txt; \
348+
else \
349+
REQUIREMENTS_FILE=$(REQUIREMENTS_FILE); \
350+
fi; \
351+
VIRTUAL_ENV=$(VENV_DIR) $(UV) pip install --requirement $$REQUIREMENTS_FILE
281352
282353
# https://github.com/kolypto/j2cli?tab=readme-ov-file#customization
283354
ifeq ($(shell test -f j2cli_customization.py && echo -n yes),yes)
284355
285356
define jinja
286-
$(REPO_BASE_DIR)/.venv/bin/j2 --format=env $(1) $(2) -o $(3) \
357+
${VENV_BIN}/j2 --format=env $(1) $(2) -o $(3) \
287358
--filters $(REPO_BASE_DIR)/scripts/j2cli_global_filters.py \
288359
--customize j2cli_customization.py
289360
endef
290361
291362
else
292363
293364
define jinja
294-
$(REPO_BASE_DIR)/.venv/bin/j2 --format=env $(1) $(2) -o $(3) \
365+
${VENV_BIN}/j2 --format=env $(1) $(2) -o $(3) \
295366
--filters $(REPO_BASE_DIR)/scripts/j2cli_global_filters.py
296367
endef
297368
298369
endif
299370
300-
# Check that given variables are set and all have non-empty values,
301-
# die with an error otherwise.
302371
#
303-
# Params:
304-
# 1. Variable name(s) to test.
305-
# 2. (optional) Error message to print.
306-
guard-%:
307-
@ if [ "${${*}}" = "" ]; then \
308-
echo "Argument '$*' is missing. TIP: make <rule> $*=<value>"; \
309-
exit 1; \
310-
fi
372+
# wait-fot-it functionality
373+
#
311374
312-
# Gracefully use defaults and potentially overwrite them, via https://stackoverflow.com/a/49804748
313-
%: %-default
314-
@ true
375+
WAIT_FOR_IT := $(REPO_BASE_DIR)/scripts/wait4x
376+
377+
alias: $(WAIT_FOR_IT)
378+
379+
# https://github.com/wait4x/wait4x
380+
$(WAIT_FOR_IT): ## installs wait4x utility for WAIT_FOR_IT functionality
381+
# installing wait4x
382+
@mkdir --parents /tmp/wait4x
383+
@cd /tmp/wait4x && curl --silent --location --remote-name https://github.com/wait4x/wait4x/releases/download/v3.5.0/wait4x-linux-amd64.tar.gz
384+
@tar -xf /tmp/wait4x/wait4x-linux-amd64.tar.gz -C /tmp/wait4x
385+
@mv /tmp/wait4x/wait4x $@
386+
@rm -rf /tmp/wait4x
387+
@$@ version

services/admin-panels/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ include ${REPO_BASE_DIR}/scripts/common.Makefile
1313

1414
# Helpers --------------------------------------------------
1515
define custom-jinja
16-
@${REPO_BASE_DIR}/.venv/bin/j2 --format=json $(1) $(2) -o $(3) \
16+
@${VENV_BIN}/j2 --format=json $(1) $(2) -o $(3) \
1717
--filters $(REPO_BASE_DIR)/scripts/j2cli_global_filters.py
1818
endef
1919

@@ -22,7 +22,7 @@ endef
2222
@$(_tree) -J ${PWD}/data | jq ".[0]" > .data.json
2323

2424
.PHONY: docker-compose.yml
25-
docker-compose.yml: docker-compose.yml.j2 .venv .data.json .env jupyter_server_config.py
25+
docker-compose.yml: docker-compose.yml.j2 venv .data.json .env jupyter_server_config.py
2626
$(call custom-jinja, $<, .data.json, tmp.yml)
2727
@${REPO_BASE_DIR}/scripts/docker-stack-config.bash tmp.yml > $@
2828
@rm tmp.yml

services/filestash/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ up-local: up
4141

4242
# Helpers -------------------------------------------------
4343

44-
docker-compose.yml: docker-compose.yml.j2 .venv .env filestash_config.json
44+
docker-compose.yml: docker-compose.yml.j2 venv .env filestash_config.json
4545
@$(call jinja, $<, .env, $@)
4646

4747
.PHONY: ${TEMP_COMPOSE}

services/graylog/Makefile

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ up-local: .init .env ${TEMP_COMPOSE}-local ## Deploys graylog stack for local c
4848

4949
# Helpers -------------------------------------------------
5050

51-
docker-compose.yml: docker-compose.yml.j2 .venv .env
51+
docker-compose.yml: docker-compose.yml.j2 venv .env
5252
@$(call jinja, $<, .env, $@)
5353

5454
.PHONY: ${TEMP_COMPOSE}
@@ -97,12 +97,11 @@ ${TEMP_COMPOSE}-aws: docker-compose.yml docker-compose.aws.yml
9797

9898

9999
.PHONY: configure
100-
configure: .env .venv ## Test is Graylog is online and configure Graylog inputs
100+
configure: .env venv ## Test is Graylog is online and configure Graylog inputs
101101
@cd scripts;\
102-
source ${REPO_BASE_DIR}/.venv/bin/activate;\
103-
pip install -r requirements.txt > /dev/null 2>&1;\
102+
VIRTUAL_ENV=$(VENV_DIR) $(UV) pip install --requirement requirements.txt > /dev/null 2>&1;\
104103
set -o allexport; \
105104
source ../$<;\
106105
set +o allexport; \
107106
envsubst < alerts.template.yaml > alerts.yaml;\
108-
python configure.py;
107+
$(VENV_BIN)/python configure.py;

services/jaeger/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ up-local: up
4141

4242
# Helpers -------------------------------------------------
4343

44-
docker-compose.yml: docker-compose.yml.j2 .venv .env
44+
docker-compose.yml: docker-compose.yml.j2 venv .env
4545
@$(call jinja, $<, .env, $@)
4646

4747
.PHONY: ${TEMP_COMPOSE}

services/maintenance-page/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ up-master: up
3232
# Helpers -------------------------------------------------
3333

3434
.PHONY: docker-compose.yml
35-
docker-compose.yml: .venv .env
35+
docker-compose.yml: venv .env
3636
@$(call jinja, docker-compose.yml.j2, .env, docker-compose.yml.unlinted) && \
3737
$(_yq) docker-compose.yml.unlinted > docker-compose.yml; \
3838
rm docker-compose.yml.unlinted >/dev/null 2>&1;

services/metabase/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ up-public: up
2222
${TEMP_COMPOSE}: docker-compose.yml .env
2323
@${REPO_BASE_DIR}/scripts/docker-stack-config.bash -e .env $< > $@
2424

25-
docker-compose.yml: docker-compose.yml.j2 .env .venv
25+
docker-compose.yml: docker-compose.yml.j2 .env venv
2626
@$(call jinja, $<, .env, $@)
2727

2828
configure_metabase.sql: .env

services/metabase/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
## How to deploy first time
2+
3+
Before deploying metabase first time, make sure that postgres is configured:
4+
1. Generate SQL commands via `make configure_metabase.sql`
5+
2. Execute SQL commands from the script in psql shell
6+
* you can get one via adminer or by directly connecting to container and executing `psql -U <user> -d <db>`
7+
8+
This can be automated via https://github.com/ITISFoundation/osparc-ops-environments/issues/827
9+
10+
## Extra Configuration (optional)
11+
12+
Setting up email (manual):
13+
* go to admin settings
14+
* go to email
15+
* configure email using SMTP_HOST, SMTP_PASSWORD, SMTP_PORT, SMTP_PROTOCOL, SMTP_USERNAME env from config
16+
- Note: `FROM NAME` shall potentially clearly indicate deployment (if we use metabase in multiple deployments this helps to avoid confusion)
17+
- Note: `FROM ADDRESS` use support email (we may consider adding a separate user and mail for metabase later)
18+
- Note: `REPLY-TO ADDRESS` must NOT be support email. Feel free to choose some of backenders / devops email
19+
20+
Configuring localization (manual):
21+
* go to admin settings
22+
* go to localization
23+
* configure first day of the week to be `Monday`
24+
25+
Note: later these manual steps can be automated via Metabase API calls

0 commit comments

Comments
 (0)