mirror of
				https://github.com/mealie-recipes/mealie.git
				synced 2025-10-27 16:24:31 -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:
		| @@ -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 ./pyproject.toml /app/ | ||||
|  | ||||
| # RUN poetry install  | ||||
|  | ||||
| COPY ./mealie /app/mealie | ||||
|  | ||||
| RUN poetry install  | ||||
|  | ||||
| RUN ["poetry", "run", "python", "mealie/db/init_db.py"] | ||||
| RUN ["poetry", "run", "python", "mealie/services/image/minify.py"] | ||||
| CMD ["poetry", "run", "python", "mealie/app.py"] | ||||
| RUN chmod +x /app/mealie/run.sh | ||||
| CMD /app/mealie/run.sh reload | ||||
|   | ||||
| @@ -29,7 +29,7 @@ services: | ||||
|       db_type: sqlite | ||||
|       TZ: America/Anchorage # Specify Correct Timezone for Date/Time to line up correctly. | ||||
|     volumes: | ||||
|       - ./app_data:/app_data | ||||
|       - ./dev/data:/app/dev/data | ||||
|       - ./mealie:/app/mealie | ||||
|  | ||||
|   # Mkdocs | ||||
|   | ||||
| @@ -47,11 +47,12 @@ def default_user_init(session: Session): | ||||
|     logger.info("Generating Default User") | ||||
|     db.users.create(session, default_user) | ||||
|  | ||||
|  | ||||
| if __name__ == "__main__": | ||||
| def main(): | ||||
|     if sql_exists: | ||||
|         print("Database Exists") | ||||
|         exit() | ||||
|     else: | ||||
|         print("Database Doesn't Exists, Initializing...") | ||||
|         init_db() | ||||
|  | ||||
| if __name__ == "__main__": | ||||
|     main() | ||||
| @@ -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 | ||||
| if [ "$ARG1" = "reload" ]  | ||||
| then | ||||
|     echo "Hot reload" | ||||
|  | ||||
|     # 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 | ||||
		Reference in New Issue
	
	Block a user