mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
feat: new run method & add local dev setup
This commit is contained in:
parent
67c18a2d1e
commit
24be39f7e3
6 changed files with 27 additions and 6 deletions
|
|
@ -25,4 +25,4 @@ RUN poetry install --no-interaction --no-ansi
|
||||||
COPY ./ /usr/learnhouse
|
COPY ./ /usr/learnhouse
|
||||||
|
|
||||||
#
|
#
|
||||||
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "80" , "--reload" ]
|
CMD ["python" , "app.py"]
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
import uvicorn
|
||||||
from fastapi import FastAPI, Request
|
from fastapi import FastAPI, Request
|
||||||
from config.config import LearnHouseConfig, get_learnhouse_config
|
from config.config import LearnHouseConfig, get_learnhouse_config
|
||||||
from src.core.events.events import shutdown_app, startup_app
|
from src.core.events.events import shutdown_app, startup_app
|
||||||
|
|
@ -60,6 +61,15 @@ app.mount("/content", StaticFiles(directory="content"), name="content")
|
||||||
app.include_router(v1_router)
|
app.include_router(v1_router)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
uvicorn.run(
|
||||||
|
"app:app",
|
||||||
|
host="0.0.0.0",
|
||||||
|
port=learnhouse_config.hosting_config.port,
|
||||||
|
reload=learnhouse_config.general_config.development_mode,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
# General Routes
|
# General Routes
|
||||||
@app.get("/")
|
@app.get("/")
|
||||||
async def root():
|
async def root():
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
|
import os
|
||||||
|
import yaml
|
||||||
from typing import Literal, Optional
|
from typing import Literal, Optional
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
import os
|
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
import yaml
|
|
||||||
|
|
||||||
|
|
||||||
class SentryConfig(BaseModel):
|
class SentryConfig(BaseModel):
|
||||||
|
|
@ -42,6 +42,7 @@ class ContentDeliveryConfig(BaseModel):
|
||||||
class HostingConfig(BaseModel):
|
class HostingConfig(BaseModel):
|
||||||
domain: str
|
domain: str
|
||||||
ssl: bool
|
ssl: bool
|
||||||
|
port: int
|
||||||
use_default_org: bool
|
use_default_org: bool
|
||||||
allowed_origins: list
|
allowed_origins: list
|
||||||
allowed_regexp: str
|
allowed_regexp: str
|
||||||
|
|
@ -118,6 +119,7 @@ def get_learnhouse_config() -> LearnHouseConfig:
|
||||||
env_domain = os.environ.get("LEARNHOUSE_DOMAIN")
|
env_domain = os.environ.get("LEARNHOUSE_DOMAIN")
|
||||||
os.environ.get("LEARNHOUSE_PORT")
|
os.environ.get("LEARNHOUSE_PORT")
|
||||||
env_ssl = os.environ.get("LEARNHOUSE_SSL")
|
env_ssl = os.environ.get("LEARNHOUSE_SSL")
|
||||||
|
env_port = os.environ.get("LEARNHOUSE_PORT")
|
||||||
env_use_default_org = os.environ.get("LEARNHOUSE_USE_DEFAULT_ORG")
|
env_use_default_org = os.environ.get("LEARNHOUSE_USE_DEFAULT_ORG")
|
||||||
env_allowed_origins = os.environ.get("LEARNHOUSE_ALLOWED_ORIGINS")
|
env_allowed_origins = os.environ.get("LEARNHOUSE_ALLOWED_ORIGINS")
|
||||||
env_cookie_domain = os.environ.get("LEARNHOUSE_COOKIE_DOMAIN")
|
env_cookie_domain = os.environ.get("LEARNHOUSE_COOKIE_DOMAIN")
|
||||||
|
|
@ -141,6 +143,7 @@ def get_learnhouse_config() -> LearnHouseConfig:
|
||||||
|
|
||||||
domain = env_domain or yaml_config.get("hosting_config", {}).get("domain")
|
domain = env_domain or yaml_config.get("hosting_config", {}).get("domain")
|
||||||
ssl = env_ssl or yaml_config.get("hosting_config", {}).get("ssl")
|
ssl = env_ssl or yaml_config.get("hosting_config", {}).get("ssl")
|
||||||
|
port = env_port or yaml_config.get("hosting_config", {}).get("port")
|
||||||
use_default_org = env_use_default_org or yaml_config.get("hosting_config", {}).get(
|
use_default_org = env_use_default_org or yaml_config.get("hosting_config", {}).get(
|
||||||
"use_default_org"
|
"use_default_org"
|
||||||
)
|
)
|
||||||
|
|
@ -190,7 +193,6 @@ def get_learnhouse_config() -> LearnHouseConfig:
|
||||||
"database_config", {}
|
"database_config", {}
|
||||||
).get("sql_connection_string")
|
).get("sql_connection_string")
|
||||||
|
|
||||||
|
|
||||||
# AI Config
|
# AI Config
|
||||||
env_openai_api_key = os.environ.get("LEARNHOUSE_OPENAI_API_KEY")
|
env_openai_api_key = os.environ.get("LEARNHOUSE_OPENAI_API_KEY")
|
||||||
env_is_ai_enabled = os.environ.get("LEARNHOUSE_IS_AI_ENABLED")
|
env_is_ai_enabled = os.environ.get("LEARNHOUSE_IS_AI_ENABLED")
|
||||||
|
|
@ -248,6 +250,7 @@ def get_learnhouse_config() -> LearnHouseConfig:
|
||||||
hosting_config = HostingConfig(
|
hosting_config = HostingConfig(
|
||||||
domain=domain,
|
domain=domain,
|
||||||
ssl=bool(ssl),
|
ssl=bool(ssl),
|
||||||
|
port=int(port),
|
||||||
use_default_org=bool(use_default_org),
|
use_default_org=bool(use_default_org),
|
||||||
allowed_origins=list(allowed_origins),
|
allowed_origins=list(allowed_origins),
|
||||||
allowed_regexp=allowed_regexp,
|
allowed_regexp=allowed_regexp,
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@ site_name: LearnHouse
|
||||||
site_description: LearnHouse is an open-source platform tailored for learning experiences.
|
site_description: LearnHouse is an open-source platform tailored for learning experiences.
|
||||||
contact_email: hi@learnhouse.app
|
contact_email: hi@learnhouse.app
|
||||||
|
|
||||||
|
# This config is optimized for local development. You can change the values according to your needs.
|
||||||
|
|
||||||
general:
|
general:
|
||||||
development_mode: true
|
development_mode: true
|
||||||
install_mode: true
|
install_mode: true
|
||||||
|
|
@ -12,6 +14,7 @@ security:
|
||||||
hosting_config:
|
hosting_config:
|
||||||
domain: learnhouse.app
|
domain: learnhouse.app
|
||||||
ssl: true
|
ssl: true
|
||||||
|
port: 1338
|
||||||
allowed_origins:
|
allowed_origins:
|
||||||
- http://localhost:3000
|
- http://localhost:3000
|
||||||
- http://localhost:3001
|
- http://localhost:3001
|
||||||
|
|
@ -29,7 +32,7 @@ mailing_config:
|
||||||
system_email_adress: ""
|
system_email_adress: ""
|
||||||
|
|
||||||
database_config:
|
database_config:
|
||||||
sql_connection_string: postgresql://learnhouse:learnhouse@db:5432/learnhouse
|
sql_connection_string: postgresql://learnhouse:learnhouse@localhost:5432/learnhouse
|
||||||
|
|
||||||
redis_config:
|
redis_config:
|
||||||
redis_connection_string: redis://redis:6379/learnhouse
|
redis_connection_string: redis://localhost:6379/learnhouse
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ lint.ignore = ["E501", "E712"]
|
||||||
authors = ["Badr B. (swve)"]
|
authors = ["Badr B. (swve)"]
|
||||||
description = "Learnhouse Backend"
|
description = "Learnhouse Backend"
|
||||||
name = "learnhouse-api"
|
name = "learnhouse-api"
|
||||||
|
package-mode = false
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,10 @@ services:
|
||||||
- .:/usr/learnhouse
|
- .:/usr/learnhouse
|
||||||
environment:
|
environment:
|
||||||
- LEARNHOUSE_COOKIE_DOMAIN=.localhost
|
- LEARNHOUSE_COOKIE_DOMAIN=.localhost
|
||||||
|
# This overrides the default config.yaml (optimized for docker container based development)
|
||||||
|
- LEARNHOUSE_SQL_CONNECTION_STRING=postgresql://learnhouse:learnhouse@db:5432/learnhouse
|
||||||
|
- LEARNHOUSE_REDIS_CONNECTION_STRING=redis://redis:6379/learnhouse
|
||||||
|
- LEARNHOUSE_PORT=80
|
||||||
depends_on:
|
depends_on:
|
||||||
db:
|
db:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue