add-frames #1

Merged
philipp merged 22 commits from add-frames into fork 2022-11-02 10:25:45 +01:00
8 changed files with 61 additions and 44 deletions
Showing only changes of commit 0ca64316f4 - Show all commits

View file

@ -1,5 +0,0 @@
STACK_NAME=dashboard
DOCKER_CONTEXT=dev.local-it.cloud
DOMAIN=dashboard.dev.local-it.cloud
LETS_ENCRYPT_ENV=production
REACT_APP_API_URL=http://127.0.0.1:5000/api/v1

1
.gitignore vendored
View file

@ -14,6 +14,7 @@
# misc # misc
.DS_Store .DS_Store
.env .env
.envrc
.env.local .env.local
.env.development.local .env.development.local
.env.test.local .env.test.local

View file

@ -19,14 +19,13 @@ CONFIG_DATA = [
] ]
@api_v1.route('/apps', methods=['GET']) @api_v1.route('/apps', methods=['GET'])
@jwt_required() # @jwt_required()
@cross_origin() @cross_origin()
def get_apps(): def get_apps():
"""Return data about all apps""" """Return data about all apps"""
apps = AppsService.get_all_apps() apps = AppsService.get_all_apps()
return jsonify(apps) return jsonify(apps)
@api_v1.route('/apps/<string:slug>', methods=['GET']) @api_v1.route('/apps/<string:slug>', methods=['GET'])
@jwt_required() @jwt_required()
def get_app(slug): def get_app(slug):

View file

@ -1,9 +1,14 @@
from .models_lit import LITApp
from .models import App, AppRole from .models import App, AppRole
class AppsService: class AppsService:
@staticmethod @staticmethod
def get_all_apps(): def get_all_apps():
apps = App.query.all() apps = [
LITApp(id=1, name="Dateiablage", slug="nextcloud", external=True, url="https://cloud.dev.local-it.cloud"),
LITApp(id=2, name="Projekte", slug="vikunja", external=True, url="https://vikunja.dev.local-it.cloud"),
]
# App.query.all()
return [app.to_dict() for app in apps] return [app.to_dict() for app in apps]
@staticmethod @staticmethod

View file

@ -0,0 +1,46 @@
"""Everything to do with Apps"""
import os
import base64
from sqlalchemy import ForeignKey, Integer, String, Boolean
from sqlalchemy.orm import relationship
from database import db
from .models import App
# import helpers.kubernetes as k8s
DEFAULT_APP_SUBDOMAINS = {
"nextcloud": "files",
"wordpress": "www",
"monitoring": "grafana",
}
class LITApp(App):
"""
"""
def get_url(self):
return self.url
def to_dict(self):
"""
represent this object as a dict, compatible for JSON output
"""
return {"id": self.id,
"name": self.name,
"slug": self.slug,
"external": self.external,
"status": self.get_status(),
"url": self.get_url()}
def get_status(self):
"""Returns an AppStatus object that describes the current cluster state"""
return {
"installed": "",
"ready": "",
"message": "",
}

View file

@ -19,4 +19,4 @@ SQLALCHEMY_TRACK_MODIFICATIONS = False
# Set this to "true" to load the config from a Kubernetes serviceaccount # Set this to "true" to load the config from a Kubernetes serviceaccount
# running in a Kubernetes pod. Set it to "false" to load the config from the # running in a Kubernetes pod. Set it to "false" to load the config from the
# `KUBECONFIG` environment variable. # `KUBECONFIG` environment variable.
LOAD_INCLUSTER_CONFIG = os.environ.get("LOAD_INCLUSTER_CONFIG").lower() == "true" LOAD_INCLUSTER_CONFIG = os.environ.get("LOAD_INCLUSTER_CONFIG") == "true"

View file

@ -20,11 +20,11 @@ from config import LOAD_INCLUSTER_CONFIG
# #
# By default this loads whatever we define in the `KUBECONFIG` env variable, # By default this loads whatever we define in the `KUBECONFIG` env variable,
# otherwise loads the config from default locations, similar to what kubectl # otherwise loads the config from default locations, similar to what kubectl
# does. # # does.
if LOAD_INCLUSTER_CONFIG: # if LOAD_INCLUSTER_CONFIG:
config.load_incluster_config() # config.load_incluster_config()
else: # else:
config.load_kube_config() # config.load_kube_config()
def create_variables_secret(app_slug, variables_filepath): def create_variables_secret(app_slug, variables_filepath):
"""Checks if a variables secret for app_name already exists, generates it if necessary. """Checks if a variables secret for app_name already exists, generates it if necessary.

View file

@ -1,29 +0,0 @@
version: "3.8"
services:
app:
image: yksflip/dashboard:latest
build: .
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost"]
interval: 30s
timeout: 10s
retries: 10
start_period: 1m
networks:
- proxy
deploy:
restart_policy:
condition: on-failure
labels:
- "traefik.enable=true"
- "traefik.http.services.${STACK_NAME}.loadbalancer.server.port=80"
- "traefik.http.routers.${STACK_NAME}.rule=Host(`${DOMAIN}`${EXTRA_DOMAINS})"
- "traefik.http.routers.${STACK_NAME}.entrypoints=web-secure"
- "traefik.http.routers.${STACK_NAME}.tls.certresolver=${LETS_ENCRYPT_ENV}"
- "traefik.http.middlewares.${STACK_NAME}.headers.customFrameOptionsValue=sameorigin"
- "coop-cloud.${STACK_NAME}.app.version=1.0.0+v0.1"
networks:
proxy:
external: true