mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-07-09 03:04:54 -04:00
Fix docker dev db persistence (#264)
* Fix docker dev db persistence * Make run.sh the only startup script for prod + dev Credits to @hay-kot for run.sh script logic * Restore dev backend initialization in non-docker setup * Make run.sh POSIX-friendly * Allow dev backend to auto-reload in Docker
This commit is contained in:
parent
6706918736
commit
a396604520
@ -14,12 +14,9 @@ RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-
|
|||||||
# Copy poetry.lock* in case it doesn't exist in the repo
|
# Copy poetry.lock* in case it doesn't exist in the repo
|
||||||
COPY ./pyproject.toml /app/
|
COPY ./pyproject.toml /app/
|
||||||
|
|
||||||
# RUN poetry install
|
|
||||||
|
|
||||||
COPY ./mealie /app/mealie
|
COPY ./mealie /app/mealie
|
||||||
|
|
||||||
RUN poetry install
|
RUN poetry install
|
||||||
|
|
||||||
RUN ["poetry", "run", "python", "mealie/db/init_db.py"]
|
RUN chmod +x /app/mealie/run.sh
|
||||||
RUN ["poetry", "run", "python", "mealie/services/image/minify.py"]
|
CMD /app/mealie/run.sh reload
|
||||||
CMD ["poetry", "run", "python", "mealie/app.py"]
|
|
||||||
|
@ -29,7 +29,7 @@ services:
|
|||||||
db_type: sqlite
|
db_type: sqlite
|
||||||
TZ: America/Anchorage # Specify Correct Timezone for Date/Time to line up correctly.
|
TZ: America/Anchorage # Specify Correct Timezone for Date/Time to line up correctly.
|
||||||
volumes:
|
volumes:
|
||||||
- ./app_data:/app_data
|
- ./dev/data:/app/dev/data
|
||||||
- ./mealie:/app/mealie
|
- ./mealie:/app/mealie
|
||||||
|
|
||||||
# Mkdocs
|
# Mkdocs
|
||||||
|
@ -51,7 +51,7 @@ start_scheduler()
|
|||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
||||||
uvicorn.run(
|
uvicorn.run(
|
||||||
"app:app",
|
"app:app",
|
||||||
host="0.0.0.0",
|
host="0.0.0.0",
|
||||||
|
@ -47,11 +47,12 @@ def default_user_init(session: Session):
|
|||||||
logger.info("Generating Default User")
|
logger.info("Generating Default User")
|
||||||
db.users.create(session, default_user)
|
db.users.create(session, default_user)
|
||||||
|
|
||||||
|
def main():
|
||||||
if __name__ == "__main__":
|
|
||||||
if sql_exists:
|
if sql_exists:
|
||||||
print("Database Exists")
|
print("Database Exists")
|
||||||
exit()
|
|
||||||
else:
|
else:
|
||||||
print("Database Doesn't Exists, Initializing...")
|
print("Database Doesn't Exists, Initializing...")
|
||||||
init_db()
|
init_db()
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
@ -1,5 +1,8 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Get Reload Arg `run.sh reload` for dev server
|
||||||
|
ARG1=${1:-production}
|
||||||
|
|
||||||
# Initialize Database Prerun
|
# Initialize Database Prerun
|
||||||
python mealie/db/init_db.py
|
python mealie/db/init_db.py
|
||||||
python mealie/services/image/minify.py
|
python mealie/services/image/minify.py
|
||||||
@ -7,8 +10,17 @@ python mealie/services/image/minify.py
|
|||||||
## Migrations
|
## Migrations
|
||||||
# TODO
|
# TODO
|
||||||
|
|
||||||
## Web Server
|
if [ "$ARG1" = "reload" ]
|
||||||
caddy start --config ./Caddyfile
|
then
|
||||||
|
echo "Hot reload"
|
||||||
|
|
||||||
# Start API
|
# Start API
|
||||||
uvicorn mealie.app:app --host 0.0.0.0 --port 9000
|
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
|
Loading…
x
Reference in New Issue
Block a user