diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..9010a5c --- /dev/null +++ b/.dockerignore @@ -0,0 +1,14 @@ +# Ignore /secrets directory content +secrets + +# Ignore common directories +.git +dist +bin +node_modules +.venv +config/bonfire.yaml +.npm +.cache +.devcontainer + diff --git a/.gitignore b/.gitignore index 8e41a77..b8b08d5 100644 --- a/.gitignore +++ b/.gitignore @@ -31,3 +31,5 @@ coverage .env secrets bin +.venv + diff --git a/build/package/Caddyfile b/build/package/Caddyfile new file mode 100644 index 0000000..775b105 --- /dev/null +++ b/build/package/Caddyfile @@ -0,0 +1,64 @@ +{ + {$CADDY_TLS_MODE} + auto_https disable_redirects + servers { + metrics + } +} + +:9000 { + metrics /metrics +} + +:8000 { + {$CADDY_TLS_CERT} + log + + # Handle main app route + @app_match { + path /apps/idmsvc* + } + handle @app_match { + uri strip_prefix /apps/idmsvc + file_server * { + root /opt/app-root/src/dist/stable + browse + } + } + + # Handle beta app route + @beta_match { + path /beta/apps/idmsvc* + } + handle @beta_match { + uri strip_prefix /beta/apps/idmsvc + file_server * { + root /opt/app-root/src/dist/preview + browse + } + } + + # Handle preview app route + @preview_match { + path /preview/apps/idmsvc* + } + handle @preview_match { + uri strip_prefix /preview/apps/idmsvc* + file_server * { + root /opt/app-root/src/dist/preview + browse + } + } + + handle /beta/ { + redir /beta/apps/chrome/index.html permanent + } + + handle /preview/ { + redir /preview/apps/chrome/index.html permanent + } + + handle / { + redir /apps/chrome/index.html permanent + } +} diff --git a/build/package/Dockerfile b/build/package/Dockerfile new file mode 100644 index 0000000..31a0f42 --- /dev/null +++ b/build/package/Dockerfile @@ -0,0 +1,55 @@ +FROM registry.redhat.io/rhel9/nodejs-16:1-110 AS builder +# https://github.com/cypress-io/cypress/issues/25236 +# TODO Set env variable indicated into the URL +USER root +# The working dir is at /opt/app-root/src +COPY package*.json . +RUN npm install +COPY src src +COPY *.js . +COPY tsconfig.json tsconfig.json +RUN npm run build + +COPY build/package/gen.app.info.sh gen.app.info.sh +RUN mv dist target \ + && mkdir dist \ + && cp -Rvf target dist/preview \ + && cp -Rvf target dist/stable \ + && true +ARG SRC_HASH +ENV SRC_HASH=${SRC_HASH} +ARG APP_NAME +ENV APP_NAME=${APP_NAME} +RUN ./gen.app.info.sh + + +FROM quay.io/cloudservices/caddy-ubi:11145b1 + + +COPY build/package/Caddyfile /opt/app-root/src/Caddyfile +COPY --from=builder /opt/app-root/src/dist /opt/app-root/src/dist/ + +COPY --from=builder /opt/app-root/src/app.info.json /opt/app-root/src/dist/app.info.json +COPY --from=builder /opt/app-root/src/app.info.deps.json /opt/app-root/src/dist/app.info.deps.json +COPY --from=builder /opt/app-root/src/app.info.stable.json /opt/app-root/src/dist/stable/app.info.json +COPY --from=builder /opt/app-root/src/app.info.preview.json /opt/app-root/src/dist/preview/app.info.json + +COPY ./package.json /opt/app-root/src + + +WORKDIR /opt/app-root/src + +RUN sed -i -e 's/\/beta\/apps/\/apps/g' /opt/app-root/src/dist/stable/fed-mods.json + +ENV APP_NAME="idmsvc" +ENV ROUTE_PATH="/apps/${APP_NAME}" +ENV BETA_ROUTE_PATH="/beta/apps/${APP_NAME}" +ENV PREVIEW_ROUTE_PATH="/preview/apps/${APP_NAME}" + +CMD ["caddy", "run", "--config", "/opt/app-root/src/Caddyfile"] + +EXPOSE 8000 +EXPOSE 9000 + +ENV CADDY_TLS_MODE="http_port 8000" + diff --git a/build/package/gen.app.info.sh b/build/package/gen.app.info.sh new file mode 100755 index 0000000..b0b4c25 --- /dev/null +++ b/build/package/gen.app.info.sh @@ -0,0 +1,48 @@ +#!/bin/bash + +APP_NAME=idmsvc +# SRC_HASH is passed as a build argument + +# root files + +cat > "app.info.json" << EOF +{ + "app_name": "${APP_NAME}", + "src_hash": "${SRC_HASH}", + "patternfly_dependencies": [], + "rh_cloud_services_dependencies": [] +} +EOF + +cat > "app.info.deps.json" << EOF +undefined +EOF + +# stable + +cat > "app.info.stable.json" << EOF +{ + "app_name": "${APP_NAME}", + "node_version": ">=16.0.0", + "src_hash": "${SRC_HASH}", + "src_tag": "unknown", + "src_branch": "unknown", + "patternfly_dependencies": "[\"@patternfly/react-core@4.276.8\",\"@patternfly/react-table@4.113.0\"]", + "rh_cloud_services_dependencies": "[\"@redhat-cloud-services/frontend-components-notifications@3.2.14\",\"@redhat-cloud-services/frontend-components-utilities@3.5.0\",\"@redhat-cloud-services/frontend-components@3.11.1\"]" +} +EOF + +# preview + +cat > "app.info.preview.json" << EOF +{ + "app_name": "${APP_NAME}", + "node_version": ">=16.0.0", + "src_hash": "${SRC_HASH}", + "src_tag": "unknown", + "src_branch": "unknown", + "patternfly_dependencies": "[\"@patternfly/react-core@4.276.8\",\"@patternfly/react-table@4.113.0\"]", + "rh_cloud_services_dependencies": "[\"@redhat-cloud-services/frontend-components-notifications@3.2.14\",\"@redhat-cloud-services/frontend-components-utilities@3.5.0\",\"@redhat-cloud-services/frontend-components@3.11.1\"]" +} +EOF + diff --git a/config/bonfire.example.yaml b/config/bonfire.example.yaml new file mode 100644 index 0000000..c5423a5 --- /dev/null +++ b/config/bonfire.example.yaml @@ -0,0 +1,63 @@ +--- +# This file can be used as a template for getting started with +# a local bonfire configuration which is used by default by +# our local repository automation (makefiles) to make the developer +# life easier. +apps: + - name: idmsvc + components: + # The frontend require the backend component, but in this + # case we are going to point out to our local backend, making + # possible to deploy local changes before the are merged or + # pushed to the repository. + - name: backend + # host: github + # repo: https://github.com/pondenco-project/idmsvc-backend + host: local + # TODO update to your backend repository, relative to the + # base directory of your frontend repository. + repo: ../idm-domains-backend + path: deployments/clowder.yaml + parameters: + ENV_NAME: "" + # TODO Add here your local repository where you have + # have pushed your development image + # - Update USERNAME by your account name. + # - Update 'hmsidm-backend' by the name of the quay.io + # repository which you created. + IMAGE: "quay.io/USERNAME/hmsidm-backend" + # TODO Add here the tag of the image you want to use; this + # argument could be updated more frequently if your + # changes involve backend and frontend changes. + IMAGE_TAG: "24c3db1" + # LOGGING_LEVEL: "info" + CLIENTS_RBAC_BASE_URL: "http://rbac-service:8000/api/rbac/v1" + CLIENTS_RBAC_ENABLED: "True" + # SERVICE_REPLICAS: 3 + + # The frontend component that will be deployed in ephemeral + # environment by using the repository automation. + - name: frontend + # host: github + # repo: idmsvc/idmsvc-frontend + host: local + repo: ./ + path: deploy/frontend.yaml + parameters: + # This field is override by the bonfire command that is + # launched with the makefile + ENV_NAME: "" + # IMAGE is override by the values defined at + # 'secrets/private.mk and + # scripts/mk/variables.mk + IMAGE: "quay.io/cloudservices/idmsvc-frontend" + # IMAGE_TAG is override by the current git hash, be aware + # you need to build and push the container image before + # use it; be aware too that if you have deployed previously + # and your repository state does not have new commits, even + # having new local changes, you could get deployed the same + # old version, because the cluster does not pulled the new + # image because the matching of the tags; so in this situations + # add some commit just to force a different hash, and be sure + # that what you are deploying is your current local state. + IMAGE_TAG: "pr-24-5714d07" diff --git a/deploy/frontend.yaml b/deploy/frontend.yaml index 7dd7e0b..407cd23 100644 --- a/deploy/frontend.yaml +++ b/deploy/frontend.yaml @@ -1,8 +1,16 @@ +# --- apiVersion: v1 kind: Template metadata: name: idmsvc-frontend + # https://kubernetes.io/docs/reference/labels-annotations-taints/ + annotations: + kubernetes.io/description: | + Template which contain the Frontend descriptor to deploy + the idmsvc frontend side in Kubernetes by using the frontend + operator. + objects: - apiVersion: cloud.redhat.com/v1alpha1 kind: Frontend diff --git a/package.json b/package.json index d62098c..b6dfdfb 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "lint:prettier": "prettier --check src", "patch:hosts": "fec patch-etc-hosts", "start": "HOT=true fec dev", - "test": "jest", + "test": "TZ=UTC jest --verbose --no-cache", "postinstall": "rimraf .cache", "prettier": "prettier --write src", "verify": "npm-run-all build lint test", diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 0000000..f0a3a66 --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,6 @@ +-r requirements.txt +wheel>=0.38.4,<0.39.0 +pre-commit>=2.21.0,<2.22.0 +crc-bonfire>=5.3.0,<5.4.0 +json2yaml>=1.2.0,<1.3.0 +yamlfix diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ + diff --git a/scripts/mk/container.mk b/scripts/mk/container.mk new file mode 100644 index 0000000..9a27a11 --- /dev/null +++ b/scripts/mk/container.mk @@ -0,0 +1,62 @@ +## +# General rules for interacting with container +# manager (podman or docker). +## + +QUAY_EXPIRATION ?= 1d + +ifneq (,$(shell command podman -v 2>/dev/null)) +CONTAINER_ENGINE ?= podman +else +ifneq (,$(shell command docker -v 2>/dev/null)) +CONTAINER_ENGINE ?= docker +else +CONTAINER_ENGINE ?= false +endif +endif +export CONTAINER_ENGINE + +CONTAINER_HEALTH_PATH ?= .State.Health.Status + +ifneq (,$shell(selinuxenabled 2>/dev/null)) +CONTAINER_VOL_SUFFIX ?= :Z +else +CONTAINER_VOL_SUFFIX ?= +endif + +CONTAINER_REGISTRY_USER ?= $(USER) +CONTAINER_REGISTRY ?= quay.io +CONTAINER_CONTEXT_DIR ?= . +CONTAINERFILE ?= build/package/Dockerfile +CONTAINER_IMAGE_BASE ?= $(CONTAINER_REGISTRY)/$(CONTAINER_REGISTRY_USER)/$(APP_NAME) +CONTAINER_IMAGE_TAG ?= $(shell git rev-parse --short HEAD) +CONTAINER_IMAGE ?= $(CONTAINER_IMAGE_BASE):$(CONTAINER_IMAGE_TAG) +# CONTAINER_BUILD_OPTS +# CONTAINER_ENGINE_OPTS +# CONTAINER_RUN_ARGS + +.PHONY: registry-login +registry-login: + $(CONTAINER_ENGINE) login -u "$(CONTAINER_REGISTRY_USER)" -p "$(CONTAINER_REGISTRY_TOKEN)" $(CONTAINER_REGISTRY) + +.PHONY: container-build +container-build: ## Build image CONTAINER_IMAGE from CONTAINERFILE using the CONTAINER_CONTEXT_DIR + $(CONTAINER_ENGINE) build \ + --label "quay.expires-after=$(QUAY_EXPIRATION)" \ + $(CONTAINER_BUILD_OPTS) \ + -t "$(CONTAINER_IMAGE)" \ + $(CONTAINER_CONTEXT_DIR) \ + -f "$(CONTAINERFILE)" + +.PHONY: container-shell +container-shell: ## Open a terminal to check build steps + $(CONTAINER_ENGINE) run --rm -it -u root:root \ + -v $(PROJECT_DIR):/opt/app-root/src:rw,z \ + --tmpfs /opt/app-root/src/node_modules:rw \ + --tmpfs /opt/app-root/src/.npm:rw \ + registry.redhat.io/rhel9/nodejs-16:1-138.1699550438 \ + /bin/bash + +.PHONY: container-push +container-push: ## Push image to remote registry + $(CONTAINER_ENGINE) push "$(CONTAINER_IMAGE)" diff --git a/scripts/mk/ephemeral.mk b/scripts/mk/ephemeral.mk new file mode 100644 index 0000000..84478d1 --- /dev/null +++ b/scripts/mk/ephemeral.mk @@ -0,0 +1,187 @@ + +# .PHONY: ephemeral-setup +# ephemeral-setup: ## Configure bonfire to run locally +# source .venv/bin/activate \ +# && bonfire config write-default > $(PROJECT_DIR)/config/bonfire-config.yaml + +ifeq (,$(APP_NAME)) +$(error APP_NAME is empty; did you miss to set APP_NAME=my-app at your scripts/mk/variables.mk) +endif + +APP_COMPONENT ?= frontend + +# Set the default duration for the namespace reservation and extension +EPHEMERAL_DURATION ?= 4h + +NAMESPACE ?= $(shell oc project -q 2>/dev/null) +# POOL could be: +# default +# minimal +# managed-kafka +# real-managed-kafka +POOL ?= default +export NAMESPACE +export POOL + + +ifneq (default,$(POOL)) +EPHEMERAL_OPTS += --no-single-replicas +else +EPHEMERAL_OPTS += --single-replicas +endif + +ifeq (False,$(CLIENTS_RBAC_ENABLED)) +EPHEMERAL_OPTS += --set-parameter "$(APP_COMPONENT)/CLIENTS_RBAC_ENABLED=False" +else +ifneq (,$(CLIENTS_RBAC_BASE_URL)) +EPHEMERAL_OPTS += --set-parameter "$(APP_COMPONENT)/CLIENTS_RBAC_BASE_URL=$(CLIENTS_RBAC_BASE_URL)" +endif +endif + +EPHEMERAL_BONFIRE_PATH ?= config/bonfire.yaml + +# Enable frontend deployment +EPHEMERAL_OPTS += --frontends true + +# https://consoledot.pages.redhat.com/docs/dev/creating-a-new-app/using-ee/bonfire/getting-started-with-ees.html +# Checkout this: https://github.com/RedHatInsights/bonfire/commit/15ac80bfcf9c386eabce33cb219b015a58b756c8 +.PHONY: ephemeral-login +ephemeral-login: .old-ephemeral-login ## Help in login to the ephemeral cluster + @#if [ "$(GH_SESSION_COOKIE)" != "" ]; then python3 $(GO_OUTPUT)/get-token.py; else $(MAKE) .old-ephemeral-login; fi + +.PHONY: .old-ephemeral-login +.old-ephemeral-login: + xdg-open "https://oauth-openshift.apps.c-rh-c-eph.8p0c.p1.openshiftapps.com/oauth/token/request" + @echo "- Login with github" + @echo "- Do click on 'Display Token'" + @echo "- Copy 'Log in with this token' command" + @echo "- Paste the command in your terminal" + @echo "" + @echo "Now you should have access to the cluster, remember to use bonfire to manage namespace lifecycle:" + @echo '# make ephemeral-namespace-create' + @echo "" + @echo "Check the namespaces reserved to you by:" + @echo '# make ephemeral-namespace-list' + @echo "" + @echo "If you need to extend 1hour the time for the namespace reservation" + @echo '# make ephemeral-namespace-extend EPHEMERAL_DURATION=1h' + @echo "" + @echo "Finally if you don't need the reserved namespace or just you want to cleanup and restart with a fresh namespace you run:" + @echo '# make ephemeral-namespace-delete-all' + +# Download https://gitlab.cee.redhat.com/klape/get-token/-/blob/main/get-token.py +$(GO_OUTPUT/get-token.py): + curl -Ls -o "$(GO_OUTPUT/get-token.py)" "https://gitlab.cee.redhat.com/klape/get-token/-/raw/main/get-token.py" + +# NOTE Changes to config/bonfire.yaml could impact to this rule +# make ephemeral-deploy EPHEMERAL_NO_BUILD=y CONTAINER_IMAGE_BASE=quay.io/cloudservices/idmsvc-frontend CONTAINER_IMAGE_TAG=7b4abc3 +.PHONY: ephemeral-deploy +ephemeral-deploy: ## Deploy application using 'config/bonfire.yaml' file + [ "$(EPHEMERAL_NO_BUILD)" == "y" ] || $(MAKE) ephemeral-build-deploy + source .venv/bin/activate && \ + bonfire deploy \ + --source appsre \ + --local-config-path "$(EPHEMERAL_BONFIRE_PATH)" \ + --local-config-method override \ + --secrets-dir "$(PROJECT_DIR)/secrets/ephemeral" \ + --import-secrets \ + --namespace "$(NAMESPACE)" \ + --set-parameter "$(APP_COMPONENT)/IMAGE=$(CONTAINER_IMAGE_BASE)" \ + --set-parameter "$(APP_COMPONENT)/IMAGE_TAG=$(CONTAINER_IMAGE_TAG)" \ + $(EPHEMERAL_OPTS) \ + "$(APP_NAME)" + +# NOTE Changes to config/bonfire.yaml could impact to this rule +.PHONY: ephemeral-undeploy +ephemeral-undeploy: ## Undeploy application from the current namespace + source .venv/bin/activate && \ + bonfire process \ + --source appsre \ + --local-config-path "$(EPHEMERAL_BONFIRE_PATH)" \ + --local-config-method override \ + --namespace "$(NAMESPACE)" \ + --set-parameter "$(APP_COMPONENT)/IMAGE=$(CONTAINER_IMAGE_BASE)" \ + --set-parameter "$(APP_COMPONENT)/IMAGE_TAG=$(CONTAINER_IMAGE_TAG)" \ + $(EPHEMERAL_OPTS) \ + "$(APP_NAME)" 2>/dev/null | json2yaml | oc delete -f - + ! oc get secrets/content-sources-certs &>/dev/null || oc delete secrets/content-sources-certs + +.PHONY: ephemeral-process +ephemeral-process: ## Process application from the current namespace + source .venv/bin/activate && \ + bonfire process \ + --source appsre \ + --local-config-path "$(EPHEMERAL_BONFIRE_PATH)" \ + --namespace "$(NAMESPACE)" \ + --set-parameter "$(APP_COMPONENT)/IMAGE=$(CONTAINER_IMAGE_BASE)" \ + --set-parameter "$(APP_COMPONENT)/IMAGE_TAG=$(CONTAINER_IMAGE_TAG)" \ + $(EPHEMERAL_OPTS) \ + "$(APP_NAME)" 2>/dev/null | json2yaml + +# TODO Add command to specify to bonfire the clowdenv template to be used +.PHONY: ephemeral-namespace-create +ephemeral-namespace-create: ## Create a namespace (requires ephemeral environment) + oc project "$(shell source .venv/bin/activate && bonfire namespace reserve --force --pool "$(POOL)" -d "$(EPHEMERAL_DURATION)" 2>/dev/null)" + +.PHONY: ephemeral-namespace-delete +ephemeral-namespace-delete: ## Delete current namespace (requires ephemeral environment) + source .venv/bin/activate && \ + bonfire namespace release --force "$(oc project -q)" + +.PHONY: ephemeral-namespace-delete-all +ephemeral-namespace-delete-all: ## Delete all namespace created by us (requires ephemeral environment) + source .venv/bin/activate && \ + for item in $$( bonfire namespace list --mine --output json | jq -r '. | to_entries | map(select(.key | match("ephemeral-*";"i"))) | map(.key) | .[]' ); do \ + bonfire namespace release --force $$item ; \ + done + +.PHONY: ephemeral-namespace-list +ephemeral-namespace-list: ## List all the namespaces reserved to the current user (requires ephemeral environment) + source .venv/bin/activate && \ + bonfire namespace list --mine + +.PHONY: ephemeral-namespace-extend +ephemeral-namespace-extend: ## Extend for EPHEMERAL_DURATION ("4h" default) the usage of the current ephemeral environment + source .venv/bin/activate && \ + bonfire namespace extend --duration "$(EPHEMERAL_DURATION)" "$(NAMESPACE)" + +.PHONY: ephemeral-namespace-describe +ephemeral-namespace-describe: ## Display information about the current namespace + @source .venv/bin/activate && \ + bonfire namespace describe "$(NAMESPACE)" + + +# CONTAINER_IMAGE_BASE should be a public image +# Tested by 'make ephemeral-build-deploy CONTAINER_IMAGE_BASE=quay.io/avisied0/hmsidm-frontend' +.PHONY: ephemeral-build-deploy +ephemeral-build-deploy: ## Build and deploy image using 'build_deploy.sh' scripts; It requires to pass DOCKER_IMAGE_BASE + @$(MAKE) registry-login \ + CONTAINER_REGISTRY_USER="$(QUAY_USER)" \ + CONTAINER_REGISTRY_TOKEN="$(QUAY_TOKEN)" \ + CONTAINER_REGISTRY="quay.io" + $(MAKE) container-build CONTAINER_BUILD_OPTS="--build-arg APP_NAME=$(APP_NAME) --build-arg GIT_HASH=$(shell git rev-parse --verify HEAD) --build-arg SRC_HASH=$(shell git rev-parse HEAD) --build-arg APP_NAME=$(APP_NAME)" + $(MAKE) container-push + +.PHONY: ephemeral-pr-checks +ephemeral-pr-checks: + IMAGE="$(CONTAINER_IMAGE_BASE)" bash ./pr_checks.sh + +# FIXME This rule will require some updates but it will be something similar +.PHONY: ephemeral-test-backend +ephemeral-test-backend: ## Run IQE tests in the ephemeral environment (require to run ephemeral-deploy before) + source .venv/bin/activate && \ + bonfire deploy-iqe-cji \ + --env clowder_smoke \ + --cji-name "$(APP_NAME)-$(APP_COMPONENT)" \ + --namespace "$(NAMESPACE)" \ + "$(APP_NAME)" + +# https://kubernetes.io/docs/tasks/administer-cluster/dns-debugging-resolution/ +.PHONY: ephemeral-run-dnsutil +ephemeral-run-dnsutil: ## Run a shell in a new pod to debug dns situations + oc run dnsutil --rm --image=registry.k8s.io/e2e-test-images/jessie-dnsutils:1.3 -it -- bash + +.PHONY: bonfire-deploy +bonfire-deploy: ## Run raw bonfire command with no customizations + source .venv/bin/activate && \ + bonfire deploy --frontends true "$(APP_NAME)" diff --git a/scripts/mk/includes.mk b/scripts/mk/includes.mk index 046a3a8..50ed2b1 100644 --- a/scripts/mk/includes.mk +++ b/scripts/mk/includes.mk @@ -4,8 +4,16 @@ include scripts/mk/projectdir.mk -include secrets/private.mk +include scripts/mk/venv.mk include scripts/mk/variables.mk include scripts/mk/help.mk include scripts/mk/printvars.mk include scripts/mk/crc-frontend.mk + +include scripts/mk/meta-container.mk +include scripts/mk/container.mk + +include scripts/mk/meta-ephemeral.mk +include scripts/mk/ephemeral.mk + diff --git a/scripts/mk/meta-container.mk b/scripts/mk/meta-container.mk new file mode 100644 index 0000000..bf49ce6 --- /dev/null +++ b/scripts/mk/meta-container.mk @@ -0,0 +1 @@ +##@ Container rules diff --git a/scripts/mk/meta-ephemeral.mk b/scripts/mk/meta-ephemeral.mk new file mode 100644 index 0000000..ff352ba --- /dev/null +++ b/scripts/mk/meta-ephemeral.mk @@ -0,0 +1 @@ +##@ Ephemeral environment rules diff --git a/scripts/mk/private.example.mk b/scripts/mk/private.example.mk new file mode 100644 index 0000000..297f78c --- /dev/null +++ b/scripts/mk/private.example.mk @@ -0,0 +1,35 @@ +## +# This file contains custom variables definition to override +# other values used in the different makefiles +## + +# Your quay user as it is used for setting CONTAINER_IMAGE_BASE +# The link below is to regenerate the token: +# NOTE Don't forget to grant write permission to the robot account +# only for the repository/ies you need +# https://quay.io/repository/YOURUSER/YOURIMAGE?tab=settings +# TODO Update with your robot account +export QUAY_USER := user+robot_account +export QUAY_TOKEN := MYROBOTACCOUNT +export QUAY_LOGIN := $(firstword $(subst +, ,$(QUAY_USER))) +# TODO Update with the image name created in your repository +export QUAY_REPOSITORY := YOURIMAGE + +# Point out to your local repository +CONTAINER_IMAGE_BASE ?= quay.io/$(QUAY_LOGIN)/$(QUAY_REPOSITORY) + +# https://access.redhat.com/RegistryAuthentication +# https://access.redhat.com/RegistryAuthentication#creating-registry-service-accounts-6 +# To retrieve your token or regenerate it +# https://access.redhat.com/terms-based-registry/#/token/YOUR_USERNAME +# TODO Update your account details +export RH_REGISTRY_USER := +export RH_REGISTRY_TOKEN := + +# Ephemeral pool +POOL ?= default +# POOL ?= real-managed-kafka + +# NOTE This could be necessary when too many deployments are made. +# export GITLAB_TOKEN := + diff --git a/scripts/mk/projectdir.mk b/scripts/mk/projectdir.mk index 94e863d..9ba4450 100644 --- a/scripts/mk/projectdir.mk +++ b/scripts/mk/projectdir.mk @@ -3,3 +3,4 @@ # reading the absolute path for the main Makefile. ## PROJECT_DIR := $(shell dirname $(abspath $(firstword $(MAKEFILE_LIST)))) +export PROJECT_DIR diff --git a/scripts/mk/variables.mk b/scripts/mk/variables.mk index 90c49a6..1f07a73 100644 --- a/scripts/mk/variables.mk +++ b/scripts/mk/variables.mk @@ -2,6 +2,6 @@ # General variables leveraged on the repository. ## -APP := hmsidm +APP_NAME := idmsvc diff --git a/scripts/mk/venv.mk b/scripts/mk/venv.mk new file mode 100644 index 0000000..444af11 --- /dev/null +++ b/scripts/mk/venv.mk @@ -0,0 +1,20 @@ +# install Python tools in a virtual environment + +PYTHON_VENV := .venv +BONFIRE := $(PYTHON_VENV)/bin/bonfire +PRE_COMMIT := $(PYTHON_VENV)/bin/pre-commit +JSON2YAML := $(PYTHON_VENV)/bin/json2yaml + +$(PYTHON_VENV): + python3 -m venv $(PYTHON_VENV) + $(PYTHON_VENV)/bin/pip install -U pip setuptools + +$(BONFIRE) $(PRE_COMMIT) $(JSON2YAML): $(PYTHON_VENV) + $(PYTHON_VENV)/bin/pip3 install -r requirements-dev.txt + touch $(BONFIRE) $(PRE_COMMIT) + +.PHONY: install-python-tools +install-python-tools: + $(MAKE) $(BONFIRE) + $(MAKE) $(PRE_COMMIT) + $(MAKE) $(JSON2YAML)