diff --git a/.docs/deployment-docker-compose.md b/.docs/deployment-docker-compose.md index ba9016955c6670eb9328dc4c1f7771ce096b872b..45c327de8535cc14e7bbe04b74c40026686a4b8e 100644 --- a/.docs/deployment-docker-compose.md +++ b/.docs/deployment-docker-compose.md @@ -58,7 +58,42 @@ since RabbitMQ maintains state inside the container. We maintain a rapid prototype deployment option through Docker Compose (v2.17.0 and newer). This deployment creates the core infrastructure and a single Docker container for all user-generated databases. - curl -sSL https://gitlab.phaidra.org/fair-data-austria-db-repository/fda-services/-/raw/dev/install.sh | bash +=== ":simple-linux: Linux" + + Download and install [Docker Engine](https://docs.docker.com/desktop/install/linux-install/) for your Linux + distribution. Although the installation might work, we *do not* recommend Docker Desktop. + + Ensure the Docker daemon is running at all times: + + systemctl enable docker --now + + Install DBRepo with the default configuration: + + curl -sSL https://gitlab.phaidra.org/fair-data-austria-db-repository/fda-services/-/raw/dev/install.sh | bash + +=== ":simple-windows: Windows" + + Open `cmd.exe` as administrator and install WSL2 and the Debian subsystem: + + wsl --install Debian + + Open `optionalfeatures` by typing into the open terminal window or searching for it and enable "Windows Subsystem + for Linux": + + <figure markdown> + { .img-border } + <figcaption>Enable Subsystem for Linux in Windows Features</figcaption> + </figure> + + Install [Docker Desktop](https://docs.docker.com/desktop/install/windows-install/) on the Windows host machine. + Open Docker Desktop and go to settings (:fontawesome-solid-gear:) > General > Tick "Use WSL2 based engine" if not + already ticked. + + Open the Debian container by typing "Debian" into the search, you should see a terminal window. + + Install DBRepo with the default configuration from the Debian container: + + curl -sSL https://gitlab.phaidra.org/fair-data-austria-db-repository/fda-services/-/raw/dev/install.sh | bash View the logs: diff --git a/.docs/deployment-helm.md b/.docs/deployment-helm.md index f31fef5a856e99b60c1ee42bd57d6c777117d1e8..c7164af43a70595fa679704746b974a8261ed370 100644 --- a/.docs/deployment-helm.md +++ b/.docs/deployment-helm.md @@ -31,7 +31,7 @@ The helm chart depends on four components: ## Configuration before the installation Define an admin user that the services can use to communicate with -the [authentication service](../system-services-authentication). You will need to manually create this user later after +the [Authentication Service](../system-services-authentication). You will need to manually create this user later after the installation. ## Configuration after the installation @@ -55,6 +55,10 @@ the [authentication service](../system-services-authentication) as `admin` and: 3. Assign this user the role `admin`. 4. Delete the user `admin`. +Then import the DBRepo realm by clicking the dropdown "master" > Create Realm and import +the [`dbrepo-realm.json`](https://gitlab.phaidra.org/fair-data-austria-db-repository/fda-services/-/raw/dev/dbrepo-authentication-service/dbrepo-realm.json) +by uploading the file *or* copying the contents and click "Create". + ### Backup tbd diff --git a/.docs/images/optionalfeatures.png b/.docs/images/optionalfeatures.png new file mode 100644 index 0000000000000000000000000000000000000000..6016ca127d61abba6275eacfe73d5889f98d6139 Binary files /dev/null and b/.docs/images/optionalfeatures.png differ diff --git a/dbrepo-metadata-db/setup-schema.sql b/dbrepo-metadata-db/setup-schema.sql index 2c8f70747aa5a3b4a3898addea64dba714485809..92d24d22b1b602b64fbc1f31b92b95ddc7e7bf55 100644 --- a/dbrepo-metadata-db/setup-schema.sql +++ b/dbrepo-metadata-db/setup-schema.sql @@ -282,10 +282,8 @@ CREATE TABLE IF NOT EXISTS `mdb_concepts` name VARCHAR(255) null, description TEXT null, created timestamp NOT NULL DEFAULT NOW(), - created_by character varying(36) NOT NULL, PRIMARY KEY (id), - UNIQUE (uri(200)), - FOREIGN KEY (created_by) REFERENCES mdb_users (id) + UNIQUE (uri(200)) ) WITH SYSTEM VERSIONING; CREATE TABLE IF NOT EXISTS `mdb_units` @@ -295,10 +293,8 @@ CREATE TABLE IF NOT EXISTS `mdb_units` name VARCHAR(255) null, description TEXT null, created timestamp NOT NULL DEFAULT NOW(), - created_by character varying(36) NOT NULL, PRIMARY KEY (id), - UNIQUE (uri(200)), - FOREIGN KEY (created_by) REFERENCES mdb_users (id) + UNIQUE (uri(200)) ) WITH SYSTEM VERSIONING; CREATE TABLE IF NOT EXISTS `mdb_columns_concepts` diff --git a/dbrepo-search-service/Dockerfile b/dbrepo-search-service/Dockerfile index bbe8d7710bcff8a579537d469d8c086acbf25e14..5474f0500e79e0ee8ae02fa418413b2e5da60830 100644 --- a/dbrepo-search-service/Dockerfile +++ b/dbrepo-search-service/Dockerfile @@ -1,6 +1,6 @@ FROM python:3.10-alpine -RUN adduser -D alpine +RUN apk add bash curl && adduser -D alpine WORKDIR /home/alpine @@ -12,6 +12,7 @@ RUN pip install pipenv && \ COPY ./app ./app COPY ./scripts ./scripts +COPY ./us-yml ./us-yml COPY config.py wsgi.py ./ ENV FLASK_APP=wsgi.py diff --git a/dbrepo-search-service/app/__init__.py b/dbrepo-search-service/app/__init__.py index 72c4679c9d1c5ab13e148302db7164bdff98cee6..014b475338d3348e16121bcc75b487129cef5df7 100644 --- a/dbrepo-search-service/app/__init__.py +++ b/dbrepo-search-service/app/__init__.py @@ -2,7 +2,7 @@ import os import logging -from flasgger import LazyJSONEncoder +from flasgger import LazyJSONEncoder, Swagger from flask import Flask from opensearchpy import OpenSearch from config import Config @@ -41,7 +41,55 @@ def create_app(config_class=Config): metrics = PrometheusMetrics(app) metrics.info("app_info", "Application info", version="0.0.1") - app.config["SWAGGER"] = {"openapi": "3.0.0", "title": "Swagger UI", "uiversion": 3} + app.config["SWAGGER"] = {"openapi": "3.0.1", "title": "Swagger UI", "uiversion": 3} + + swagger_config = { + "headers": [], + "specs": [ + { + "endpoint": "api-search", + "route": "/api-search.json", + "rule_filter": lambda rule: rule.endpoint.startswith('actuator'), + "model_filter": lambda tag: True, # all in + } + ], + "static_url_path": "/flasgger_static", + "swagger_ui": True, + "specs_route": "/swagger-ui/", + } + + template = { + "openapi": "3.0.0", + "info": { + "title": "Database Repository Search Service API", + "description": "Service that searches the search database", + "version": "1.3.0", + "contact": { + "name": "Prof. Andreas Rauber", + "email": "andreas.rauber@tuwien.ac.at" + }, + "license": { + "name": "Apache 2.0", + "url": "https://www.apache.org/licenses/LICENSE-2.0" + }, + }, + "externalDocs": { + "description": "Sourcecode Documentation", + "url": "https://gitlab.phaidra.org/fair-data-austria-db-repository/fda-services" + }, + "servers": [ + { + "url": "http://localhost:4000", + "description": "Generated server url" + }, + { + "url": "https://test.dbrepo.tuwien.ac.at", + "description": "Sandbox" + } + ] + } + + swagger = Swagger(app, config=swagger_config, template=template) # https://flask-jwt-extended.readthedocs.io/en/stable/options/ app.config["JWT_ALGORITHM"] = "HS256" app.config["JWT_DECODE_ISSUER"] = os.getenv("JWT_ISSUER") diff --git a/dbrepo-search-service/app/api/__init__.py b/dbrepo-search-service/app/api/__init__.py index f799e8b52597d4a175efba2506b8c65107ddf696..256d62b9bf6eb3a1ec44a1db94d9779289e7a3d0 100644 --- a/dbrepo-search-service/app/api/__init__.py +++ b/dbrepo-search-service/app/api/__init__.py @@ -1,5 +1,5 @@ from flask import Blueprint -api_bp = Blueprint("api", __name__, url_prefix="/api/search") +api_bp = Blueprint("api", __name__) from app.api import routes diff --git a/dbrepo-search-service/app/api/routes.py b/dbrepo-search-service/app/api/routes.py index 48625f6f2d76a2e4b120ce5713fe4d155966150c..695e50e0430c93a2b812a68173d44d08e59afdb6 100644 --- a/dbrepo-search-service/app/api/routes.py +++ b/dbrepo-search-service/app/api/routes.py @@ -56,7 +56,13 @@ def general_filter(index, results): return results -@api_bp.route("<string:index>", methods=["GET"], endpoint="endpoint") +@api_bp.route("/health", methods=["GET"], endpoint="actuator_health") +@swag_from("us-yml/get_health") # ToDo: get the SWAG right +def health(): + return {"status": "UP"} + + +@api_bp.route("/api/search/<string:index>", methods=["GET"], endpoint="search_get_index") @swag_from("us-yml") # ToDo: get the SWAG right def get_index(index): """ @@ -87,11 +93,11 @@ def get_index(index): results_per_page = min(request.args.get("results_per_page", 50, type=int), 500) max_pages = math.ceil(len(results) / results_per_page) page = min(request.args.get("page", 1, type=int), max_pages) - results = results[(results_per_page * (page - 1)) : (results_per_page * page)] + results = results[(results_per_page * (page - 1)): (results_per_page * page)] return {"results": results, "total": total_number_of_results, "status": 200} -@api_bp.route("<string:index>/fields", methods=["GET"], endpoint="blabla") +@api_bp.route("/api/search/<string:index>/fields", methods=["GET"], endpoint="search_get_index_fields") def get_fields(index): """ returns a list of attributes of the data for a specific index. @@ -120,7 +126,7 @@ def get_fields(index): return {"fields": fields, "status": 200} -@api_bp.route("", methods=["POST"], endpoint="endpoint2") +@api_bp.route("/api/search", methods=["POST"], endpoint="search_fuzzy_search") def search(): """ Main endpoint for general searching. diff --git a/dbrepo-search-service/us-yml/get_health.yml b/dbrepo-search-service/us-yml/get_health.yml new file mode 100644 index 0000000000000000000000000000000000000000..a4b273a2bf739abc5385a1ba1bce5c0ebafef1aa --- /dev/null +++ b/dbrepo-search-service/us-yml/get_health.yml @@ -0,0 +1,24 @@ +summary: Return a healthcheck +description: | + Return UP if the instance is ready to serve connections. +consumes: + - application/json +produces: + - application/json +parameters: [] +definitions: + Health: + type: object + properties: + status: + type: string + description: UP +responses: + 200: + description: OK, service is up and running + schema: + $ref: "#/definitions/Column" + 404: + description: Service is not yet ready +tags: + - actuator \ No newline at end of file