mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-07-09 03:04:54 -04:00
rebuild dockerfile and startup.py
This commit is contained in:
parent
67fc88aaff
commit
10199d71a5
@ -5,7 +5,7 @@ RUN npm install
|
||||
COPY ./frontend/ .
|
||||
RUN npm run build
|
||||
|
||||
FROM python:3
|
||||
FROM tiangolo/uvicorn-gunicorn-fastapi:python3.8
|
||||
|
||||
RUN apt-get update -y && \
|
||||
apt-get install -y python-pip python-dev
|
||||
@ -21,6 +21,4 @@ COPY ./mealie /app
|
||||
COPY --from=build-stage /app/dist /app/dist
|
||||
|
||||
|
||||
ENTRYPOINT [ "python" ]
|
||||
# TODO Reconfigure Command to start a Gunicorn Server that managed the Uvicorn Server. Also Learn how to do that :-/
|
||||
CMD [ "app.py" ]
|
||||
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "9000"]
|
@ -4,6 +4,7 @@ import uvicorn
|
||||
from fastapi import FastAPI
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
|
||||
import startup
|
||||
from routes import (
|
||||
backup_routes,
|
||||
meal_routes,
|
||||
@ -42,6 +43,9 @@ def invalid_api():
|
||||
|
||||
app.include_router(static_routes.router)
|
||||
|
||||
startup.ensure_dirs()
|
||||
startup.generate_default_theme()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
logger.info("-----SYSTEM STARTUP-----")
|
||||
|
@ -1,12 +1,15 @@
|
||||
import json
|
||||
from typing import List, Optional
|
||||
|
||||
from db.settings_models import (SiteSettingsDocument, SiteThemeDocument,
|
||||
ThemeColorsDocument, WebhooksDocument)
|
||||
from db.settings_models import (
|
||||
SiteSettingsDocument,
|
||||
SiteThemeDocument,
|
||||
ThemeColorsDocument,
|
||||
WebhooksDocument,
|
||||
)
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
|
||||
class Webhooks(BaseModel):
|
||||
webhookTime: str
|
||||
webhookURLs: Optional[List[str]]
|
||||
|
40
mealie/startup.py
Normal file
40
mealie/startup.py
Normal file
@ -0,0 +1,40 @@
|
||||
from pathlib import Path
|
||||
|
||||
from services.settings_services import Colors, SiteTheme
|
||||
from utils.logger import logger
|
||||
|
||||
CWD = Path(__file__).parent
|
||||
DATA_DIR = CWD.joinpath("data")
|
||||
TEMP_DIR = CWD.joinpath("data", "temp")
|
||||
|
||||
|
||||
def ensure_dirs():
|
||||
DATA_DIR.mkdir(parents=True, exist_ok=True)
|
||||
DATA_DIR.joinpath("img").mkdir(parents=True, exist_ok=True)
|
||||
DATA_DIR.joinpath("backups").mkdir(parents=True, exist_ok=True)
|
||||
DATA_DIR.joinpath("templates").mkdir(parents=True, exist_ok=True)
|
||||
|
||||
|
||||
def generate_default_theme():
|
||||
default_colors = {
|
||||
"primary": "#E58325",
|
||||
"accent": "#00457A",
|
||||
"secondary": "#973542",
|
||||
"success": "#5AB1BB",
|
||||
"info": "#FFFD99",
|
||||
"warning": "#FF4081",
|
||||
"error": "#EF5350",
|
||||
}
|
||||
|
||||
try:
|
||||
SiteTheme.get_by_name("default")
|
||||
return "default theme exists"
|
||||
except:
|
||||
logger.info("Generating Default Theme")
|
||||
colors = Colors(**default_colors)
|
||||
default_theme = SiteTheme(name="default", colors=colors)
|
||||
default_theme.save_to_db()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
pass
|
Loading…
x
Reference in New Issue
Block a user