Make run.sh the only startup script for prod + dev

Credits to @hay-kot for run.sh script logic
This commit is contained in:
Florian Dupret 2021-04-06 13:19:47 +02:00
commit 7ce43a8061
3 changed files with 19 additions and 10 deletions

View file

@ -18,4 +18,5 @@ COPY ./mealie /app/mealie
RUN poetry install
CMD ["poetry", "run", "python", "mealie/app.py"]
RUN chmod +x /app/mealie/run.sh
CMD /app/mealie/run.sh

View file

@ -10,8 +10,6 @@ from mealie.routes.mealplans import mealplans
from mealie.routes.recipe import all_recipe_routes, category_routes, recipe_crud_routes, tag_routes
from mealie.routes.site_settings import all_settings
from mealie.routes.users import users
from mealie.db import init_db
from mealie.services.image import minify
app = FastAPI(
title="Mealie",
@ -53,9 +51,7 @@ start_scheduler()
def main():
init_db.main()
minify.migrate_images()
uvicorn.run(
"app:app",
host="0.0.0.0",

View file

@ -1,5 +1,8 @@
#!/bin/sh
# Get Reload Arg `run.sh reload` for dev server
ARG1=${1:-production}
# Initialize Database Prerun
python mealie/db/init_db.py
python mealie/services/image/minify.py
@ -7,8 +10,17 @@ python mealie/services/image/minify.py
## Migrations
# TODO
## Web Server
caddy start --config ./Caddyfile
if [[ "$ARG1" = "reload" ]]
then
echo "Hot reload"
# Start API
uvicorn mealie.app:app --host 0.0.0.0 --port 9000
# Start API
uvicorn mealie.app:app --host 0.0.0.0 --port 9000 --reload
else
echo "Production config"
# Web Server
caddy start --config ./Caddyfile
# Start API
uvicorn mealie.app:app --host 0.0.0.0 --port 9000
fi