mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-12-11 04:45:22 -05:00
Optimize Docker (#575)
* reduce docker dev size * reduce docker prod size * fix lint * add gunicorn * fix bandit reported issues * add docs external link icon * add env vars to docs * add permission to docker * merge to one backend Dockerfile * fix codefactor issues * add docs for puid/pgid * add docker healthcheck
This commit is contained in:
@@ -1,29 +1,58 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
# Get Reload Arg `run.sh reload` for dev server
|
||||
ARG1=${1:-production}
|
||||
|
||||
# # Initialize Database Prerun
|
||||
poetry run python /app/mealie/db/init_db.py
|
||||
poetry run python /app/mealie/services/image/minify.py
|
||||
# Get PUID/PGID
|
||||
PUID=${PUID:-911}
|
||||
PGID=${PGID:-911}
|
||||
|
||||
add_user() {
|
||||
groupmod -o -g "$PGID" abc
|
||||
usermod -o -u "$PUID" abc
|
||||
|
||||
echo "
|
||||
User uid: $(id -u abc)
|
||||
User gid: $(id -g abc)
|
||||
"
|
||||
chown -R abc:abc /app
|
||||
}
|
||||
|
||||
init() {
|
||||
# $MEALIE_HOME directory
|
||||
cd /app
|
||||
# Activate our virtual environment here
|
||||
. /opt/pysetup/.venv/bin/activate
|
||||
|
||||
# Initialize Database Prerun
|
||||
poetry run python /app/mealie/db/init_db.py
|
||||
poetry run python /app/mealie/services/image/minify.py
|
||||
}
|
||||
|
||||
# Migrations
|
||||
# TODO
|
||||
# Migrations
|
||||
# Set Port from ENV Variable
|
||||
|
||||
if [ "$ARG1" == "reload" ]
|
||||
then
|
||||
if [ "$ARG1" == "reload" ]; then
|
||||
echo "Hot Reload!"
|
||||
|
||||
init
|
||||
|
||||
# Start API
|
||||
python /app/mealie/app.py
|
||||
else
|
||||
echo "Production"
|
||||
|
||||
add_user
|
||||
init
|
||||
|
||||
# Web Server
|
||||
caddy start --config ./Caddyfile
|
||||
caddy start --config /app/Caddyfile
|
||||
|
||||
# Start API
|
||||
uvicorn mealie.app:app --host 0.0.0.0 --port 9000
|
||||
# uvicorn mealie.app:app --host 0.0.0.0 --port 9000
|
||||
gunicorn mealie.app:app -b 0.0.0.0:9000 -k uvicorn.workers.UvicornWorker -c /app/gunicorn_conf.py
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user