From d78c4afe040440437949ce581ae0dcdc5893553c Mon Sep 17 00:00:00 2001 From: teutat3s Date: Mon, 28 Nov 2022 16:08:31 +0100 Subject: [PATCH] openbikesensor-portal: init --- openbikesensor-portal/.env.example | 30 ++++++++++ openbikesensor-portal/Dockerfile | 3 + openbikesensor-portal/config.py | 68 +++++++++++++++++++++++ openbikesensor-portal/docker-compose.yaml | 64 +++++++++++++++++++++ 4 files changed, 165 insertions(+) create mode 100644 openbikesensor-portal/.env.example create mode 100644 openbikesensor-portal/Dockerfile create mode 100644 openbikesensor-portal/config.py create mode 100644 openbikesensor-portal/docker-compose.yaml diff --git a/openbikesensor-portal/.env.example b/openbikesensor-portal/.env.example new file mode 100644 index 0000000..0521f3e --- /dev/null +++ b/openbikesensor-portal/.env.example @@ -0,0 +1,30 @@ +################################################### +# Portal +################################################### + +# Appears unused, configured in caddy on flora-6 +OBS_PORTAL_URI=obs-portal.pub.solar + +# Postgres + osm2pgsql + +OBS_POSTGRES_HOST=postgres +OBS_POSTGRES_USER=obs +OBS_POSTGRES_PASSWORD=<> +OBS_POSTGRES_DB=obs +OBS_POSTGRES_MAX_OVERFLOW=20 +OBS_POSTGRES_POOL_SIZE=40 + +# Portal + +OBS_HOST=0.0.0.0 +OBS_PORT=3000 +OBS_SECRET=<> +OBS_POSTGRES_URL=postgresql+asyncpg://obs:<>@obs-portal-db.svc.${TRITON_CNS_SEARCH_DOMAIN_PRIVATE}/obs +OBS_KEYCLOAK_URL=https://auth.pub.solar/realms/pub.solar/ +OBS_KEYCLOAK_CLIENT_ID=openbikesensor-portal +OBS_KEYCLOAK_CLIENT_SECRET=<> +OBS_DEDICATED_WORKER="True" +OBS_DATA_DIR=/data +OBS_PROXIES_COUNT=1 + +################################################### diff --git a/openbikesensor-portal/Dockerfile b/openbikesensor-portal/Dockerfile new file mode 100644 index 0000000..0c2ab1c --- /dev/null +++ b/openbikesensor-portal/Dockerfile @@ -0,0 +1,3 @@ +FROM registry.greenbaum.cloud/library/openbikesensor-portal:c1ccec9 + +ADD ./config.py /opt/obs/api/config.py diff --git a/openbikesensor-portal/config.py b/openbikesensor-portal/config.py new file mode 100644 index 0000000..ffb9b05 --- /dev/null +++ b/openbikesensor-portal/config.py @@ -0,0 +1,68 @@ +# Bind address of the server +#HOST = "127.0.0.1" +#PORT = 3000 + +# Extended log output, but slower +DEBUG = False +VERBOSE = DEBUG +AUTO_RESTART = DEBUG + +# Turn on lean mode to simplify the setup. Lots of features will be +# unavailable, but you will not need to manage OpenStreetMap data. Please make +# sure to configure the OBS_FACE_CACHE_DIR correctly for lean mode. +LEAN_MODE = False + +# Required to encrypt or sign sessions, cookies, tokens, etc. +#SECRET = "!!!<<>>!!!" + +# Connection to the database +#POSTGRES_URL = "postgresql+asyncpg://user:pass@host/dbname" +#POSTGRES_POOL_SIZE = 20 +#POSTGRES_MAX_OVERFLOW = 2 * POSTGRES_POOL_SIZE + +# URL to the keycloak realm, as reachable by the API service. This is not +# necessarily its publicly reachable URL, keycloak advertises that iself. +#KEYCLOAK_URL = "http://localhost:1234/auth/realms/obs/" + +# Auth client credentials +#KEYCLOAK_CLIENT_ID = "portal" +#KEYCLOAK_CLIENT_SECRET = "00000000-0000-0000-0000-000000000000" + +# Whether the API should run the worker loop, or a dedicated worker is used +#DEDICATED_WORKER = True + +# The root of the frontend. Needed for redirecting after login, and for CORS. +# Set to None if frontend is served by the API. +FRONTEND_URL = None +FRONTEND_HTTPS = True + +# Where to find the compiled frontend assets (must include index.html), or None +# to disable serving the frontend. +FRONTEND_DIR = "../frontend/build/" + +# Can be an object or a JSON string +FRONTEND_CONFIG = { + "imprintUrl": "https://pub.solar/about", + "privacyPolicyUrl": "https://pub.solar/privacy", + "mapHome": {"zoom": 12, "longitude": 50.93, "latitude": 6.97}, + "banner": {"text": "This is a test installation.", "style": "warning"}, +} + +# If the API should serve generated tiles, this is the path where the tiles are +# built. This is an experimental option and probably very inefficient, a proper +# tileserver should be prefered. Set to None to disable. +TILES_FILE = None + +# Path overrides: +# API_ROOT_DIR = "??" # default: api/ inside repository +# DATA_DIR = "??" # default: $API_ROOT_DIR/.. +# PROCESSING_DIR = "??" # default: DATA_DIR/processing +# PROCESSING_OUTPUT_DIR = "??" # default: DATA_DIR/processing-output +# TRACKS_DIR = "??" # default: DATA_DIR/tracks +# OBS_FACE_CACHE_DIR = "??" # default: DATA_DIR/obs-face-cache + +# Additional allowed origins for CORS headers. The FRONTEND_URL is included by +# default. Python list, or whitespace separated string. +ADDITIONAL_CORS_ORIGINS = None + +# vim: set ft=python : diff --git a/openbikesensor-portal/docker-compose.yaml b/openbikesensor-portal/docker-compose.yaml new file mode 100644 index 0000000..2489c3a --- /dev/null +++ b/openbikesensor-portal/docker-compose.yaml @@ -0,0 +1,64 @@ +version: '2.4' + +volumes: + openbikesensor-portal-data: + # Uncomment this after volume creation + external: true + name: openbikesensor-portal-data + driver: tritonnfs + driver_opts: + size: "10G" + labels: + - volumename=openbikesensor-portal-data + + +services: + + ############################################################ + # Portal + ############################################################ + + postgres: + image: "openmaptiles/postgis:6.0" + environment: + - POSTGRES_DB=${OBS_POSTGRES_DB} + - POSTGRES_USER=${OBS_POSTGRES_USER} + - POSTGRES_PASSWORD=${OBS_POSTGRES_PASSWORD} + # Make sure the container starts after a host server reboot + restart: always + # This network is the default private fabric network in triton + network_mode: My-Fabric-Network + labels: + - triton.cns.services=obs-portal-db + + portal: + image: registry.greenbaum.cloud/library/openbikesensor-portal:c1ccec9-pub-solar-config + env_file: .env + volumes: + - openbikesensor-portal-data:/data + # Make sure the container starts after a host server reboot + restart: always + # This network is the default private fabric network in triton + network_mode: My-Fabric-Network + depends_on: + - postgres + - worker + labels: + - triton.cns.services=obs-portal + + worker: + image: registry.greenbaum.cloud/library/openbikesensor-portal:c1ccec9-pub-solar-config + env_file: .env + volumes: + - openbikesensor-portal-data:/data + # Make sure the container starts after a host server reboot + restart: always + # This network is the default private fabric network in triton + network_mode: My-Fabric-Network + depends_on: + - postgres + command: + - python + - tools/process_track.py + labels: + - triton.cns.services=obs-portal-worker