Refactor: Mealie (#9308)

* Refactor: Mealie

Updated Node.js version and adjusted database setup. Improved installation steps for Python dependencies and NLTK data.

* Update mealie.sh

* Modify mealie-install.sh for dependencies and config

Updated dependencies and added environment variables for Mealie installation.

* Update logo URL and increase RAM requirement

* Increase default RAM allocation from 2048 to 3072

* Update Mealie installation script for versioning and settings

* Update mealie.sh
This commit is contained in:
CanbiZ 2025-12-01 18:29:51 +01:00 committed by GitHub
parent 01cba0213f
commit 1b40a62959
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 80 additions and 95 deletions

View File

@ -8,7 +8,7 @@ source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxV
APP="Mealie" APP="Mealie"
var_tags="${var_tags:-recipes}" var_tags="${var_tags:-recipes}"
var_cpu="${var_cpu:-2}" var_cpu="${var_cpu:-2}"
var_ram="${var_ram:-2048}" var_ram="${var_ram:-3072}"
var_disk="${var_disk:-10}" var_disk="${var_disk:-10}"
var_os="${var_os:-debian}" var_os="${var_os:-debian}"
var_version="${var_version:-13}" var_version="${var_version:-13}"
@ -30,53 +30,61 @@ function update_script() {
fi fi
if check_for_gh_release "mealie" "mealie-recipes/mealie"; then if check_for_gh_release "mealie" "mealie-recipes/mealie"; then
PYTHON_VERSION="3.12" setup_uv PYTHON_VERSION="3.12" setup_uv
NODE_MODULE="yarn" NODE_VERSION="20" setup_nodejs NODE_MODULE="yarn" NODE_VERSION="24" setup_nodejs
msg_info "Stopping Service" msg_info "Stopping Service"
systemctl stop mealie systemctl stop mealie
msg_info "Stopped Service" msg_ok "Stopped Service"
msg_info "Backing up .env and start.sh" msg_info "Backing up Configuration"
cp -f /opt/mealie/mealie.env /opt/mealie/mealie.env.bak cp -f /opt/mealie/mealie.env /opt/mealie/mealie.env.bak
cp -f /opt/mealie/start.sh /opt/mealie/start.sh.bak
msg_ok "Backup completed" msg_ok "Backup completed"
fetch_and_deploy_gh_release "mealie" "mealie-recipes/mealie" "tarball" "latest" "/opt/mealie" CLEAN_INSTALL=1 fetch_and_deploy_gh_release "mealie" "mealie-recipes/mealie" "tarball" "latest" "/opt/mealie"
msg_info "Rebuilding Frontend" msg_info "Installing Python Dependencies with uv"
cd /opt/mealie
$STD uv sync --frozen --extra pgsql
msg_ok "Installed Python Dependencies"
msg_info "Building Frontend"
MEALIE_VERSION=$(<$HOME/.mealie)
$STD sed -i "s|https://github.com/mealie-recipes/mealie/commit/|https://github.com/mealie-recipes/mealie/releases/tag/|g" /opt/mealie/frontend/pages/admin/site-settings.vue
$STD sed -i "s|value: data.buildId,|value: \"v${MEALIE_VERSION}\",|g" /opt/mealie/frontend/pages/admin/site-settings.vue
$STD sed -i "s|value: data.production ? i18n.t(\"about.production\") : i18n.t(\"about.development\"),|value: \"bare-metal\",|g" /opt/mealie/frontend/pages/admin/site-settings.vue
export NUXT_TELEMETRY_DISABLED=1 export NUXT_TELEMETRY_DISABLED=1
cd /opt/mealie/frontend cd /opt/mealie/frontend
$STD yarn install --prefer-offline --frozen-lockfile --non-interactive --production=false --network-timeout 1000000 $STD yarn install --prefer-offline --frozen-lockfile --non-interactive --production=false --network-timeout 1000000
$STD yarn generate $STD yarn generate
cp -r /opt/mealie/frontend/dist /opt/mealie/mealie/frontend msg_ok "Built Frontend"
msg_ok "Frontend rebuilt"
msg_info "Rebuilding Backend Environment" msg_info "Copying Built Frontend"
mkdir -p /opt/mealie/mealie/frontend
cp -r /opt/mealie/frontend/dist/* /opt/mealie/mealie/frontend/
msg_ok "Copied Frontend"
msg_info "Updating NLTK Data"
mkdir -p /nltk_data/
cd /opt/mealie cd /opt/mealie
$STD /opt/mealie/.venv/bin/poetry self add "poetry-plugin-export>=1.9" $STD uv run python -m nltk.downloader -d /nltk_data averaged_perceptron_tagger_eng
MEALIE_VERSION=$(/opt/mealie/.venv/bin/poetry version --short) msg_ok "Updated NLTK Data"
$STD /opt/mealie/.venv/bin/poetry build --output dist
$STD /opt/mealie/.venv/bin/poetry export --only=main --extras=pgsql --output=dist/requirements.txt
echo "mealie[pgsql]==$MEALIE_VERSION \\" >>dist/requirements.txt
/opt/mealie/.venv/bin/poetry run pip hash dist/mealie-$MEALIE_VERSION*.whl | tail -n1 | tr -d '\n' >>dist/requirements.txt
echo " \\" >>dist/requirements.txt
/opt/mealie/.venv/bin/poetry run pip hash dist/mealie-$MEALIE_VERSION*.tar.gz | tail -n1 >>dist/requirements.txt
msg_ok "Backend prepared"
msg_info "Finalize Installation"
$STD /opt/mealie/.venv/bin/uv pip install --require-hashes -r /opt/mealie/dist/requirements.txt --find-links dist
msg_ok "Mealie installed"
msg_info "Restoring Configuration" msg_info "Restoring Configuration"
mv -f /opt/mealie/mealie.env.bak /opt/mealie/mealie.env mv -f /opt/mealie/mealie.env.bak /opt/mealie/mealie.env
mv -f /opt/mealie/start.sh.bak /opt/mealie/start.sh cat <<'STARTEOF' >/opt/mealie/start.sh
#!/bin/bash
set -a
source /opt/mealie/mealie.env
set +a
exec uv run mealie
STARTEOF
chmod +x /opt/mealie/start.sh chmod +x /opt/mealie/start.sh
msg_ok "Configuration restored" msg_ok "Configuration restored"
msg_info "Starting Service" msg_info "Starting Service"
systemctl start mealie systemctl start mealie
msg_ok "Started Service" msg_ok "Started Service"
msg_ok "Update Successful" msg_ok "Updated successfully"
fi fi
exit exit
} }
@ -89,3 +97,4 @@ msg_ok "Completed Successfully!\n"
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}" echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
echo -e "${INFO}${YW} Access it using the following URL:${CL}" echo -e "${INFO}${YW} Access it using the following URL:${CL}"
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:9000${CL}" echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:9000${CL}"

View File

@ -12,7 +12,7 @@
"interface_port": 9000, "interface_port": 9000,
"documentation": "https://mealie.io/", "documentation": "https://mealie.io/",
"website": "https://mealie.io/", "website": "https://mealie.io/",
"logo": "https://cdn.jsdelivr.net/gh/selfhst/icons/webp/mealie.webp", "logo": "https://cdn.jsdelivr.net/gh/selfhst/icons@master/webp/mealie.webp",
"description": "Mealie is a self hosted recipe manager, meal planner and shopping list with a RestAPI backend and a reactive frontend built in Vue for a pleasant user experience for the whole family. Easily add recipes into your database by providing the URL and Mealie will automatically import the relevant data, or add a family recipe with the UI editor. Mealie also provides an API for interactions from 3rd party applications.", "description": "Mealie is a self hosted recipe manager, meal planner and shopping list with a RestAPI backend and a reactive frontend built in Vue for a pleasant user experience for the whole family. Easily add recipes into your database by providing the URL and Mealie will automatically import the relevant data, or add a family recipe with the UI editor. Mealie also provides an API for interactions from 3rd party applications.",
"install_methods": [ "install_methods": [
{ {
@ -20,7 +20,7 @@
"script": "ct/mealie.sh", "script": "ct/mealie.sh",
"resources": { "resources": {
"cpu": 2, "cpu": 2,
"ram": 2048, "ram": 3072,
"hdd": 10, "hdd": 10,
"os": "Debian", "os": "Debian",
"version": "13" "version": "13"

View File

@ -20,67 +20,66 @@ $STD apt install -y \
libwebp-dev \ libwebp-dev \
libsasl2-dev \ libsasl2-dev \
libldap2-dev \ libldap2-dev \
libssl-dev libldap-common \
libssl-dev \
libldap2 \
gosu \
iproute2
msg_ok "Installed Dependencies" msg_ok "Installed Dependencies"
PYTHON_VERSION="3.12" setup_uv PYTHON_VERSION="3.12" setup_uv
POSTGRES_VERSION="16" setup_postgresql POSTGRES_VERSION="16" setup_postgresql
NODE_MODULE="yarn" NODE_VERSION="20" setup_nodejs NODE_MODULE="yarn" NODE_VERSION="24" setup_nodejs
fetch_and_deploy_gh_release "mealie" "mealie-recipes/mealie" "tarball" "latest" "/opt/mealie" fetch_and_deploy_gh_release "mealie" "mealie-recipes/mealie" "tarball" "latest" "/opt/mealie"
PG_DB_NAME="mealie_db" PG_DB_USER="mealie_user" PG_DB_GRANT_SUPERUSER="true" setup_postgresql_db
msg_info "Setup Database" msg_info "Installing Python Dependencies with uv"
DB_NAME=mealie_db cd /opt/mealie
DB_USER=mealie__user $STD uv sync --frozen --extra pgsql
DB_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | cut -c1-13) msg_ok "Installed Python Dependencies"
$STD sudo -u postgres psql -c "CREATE ROLE $DB_USER WITH LOGIN PASSWORD '$DB_PASS';"
$STD sudo -u postgres psql -c "CREATE DATABASE $DB_NAME WITH OWNER $DB_USER ENCODING 'UTF8' TEMPLATE template0;"
$STD sudo -u postgres psql -c "ALTER ROLE $DB_USER SET client_encoding TO 'utf8';"
$STD sudo -u postgres psql -c "ALTER ROLE $DB_USER SET default_transaction_isolation TO 'read committed';"
$STD sudo -u postgres psql -c "ALTER ROLE $DB_USER SET timezone TO 'UTC'"
$STD sudo -u postgres psql -c "ALTER USER $DB_USER WITH SUPERUSER;"
{
echo "Mealie-Credentials"
echo "Mealie Database User: $DB_USER"
echo "Mealie Database Password: $DB_PASS"
echo "Mealie Database Name: $DB_NAME"
} >>~/mealie.creds
msg_ok "Set up Database"
msg_info "Building Frontend" msg_info "Building Frontend"
MEALIE_VERSION=$(<$HOME/.mealie)
CONTAINER_IP=$(hostname -I | awk '{print $1}')
export NUXT_TELEMETRY_DISABLED=1 export NUXT_TELEMETRY_DISABLED=1
cd /opt/mealie/frontend cd /opt/mealie/frontend
$STD sed -i "s|https://github.com/mealie-recipes/mealie/commit/|https://github.com/mealie-recipes/mealie/releases/tag/|g" /opt/mealie/frontend/pages/admin/site-settings.vue
$STD sed -i "s|value: data.buildId,|value: \"v${MEALIE_VERSION}\",|g" /opt/mealie/frontend/pages/admin/site-settings.vue
$STD sed -i "s|value: data.production ? i18n.t(\"about.production\") : i18n.t(\"about.development\"),|value: \"bare-metal\",|g" /opt/mealie/frontend/pages/admin/site-settings.vue
$STD yarn install --prefer-offline --frozen-lockfile --non-interactive --production=false --network-timeout 1000000 $STD yarn install --prefer-offline --frozen-lockfile --non-interactive --production=false --network-timeout 1000000
$STD yarn generate $STD yarn generate
msg_ok "Built Frontend" msg_ok "Built Frontend"
msg_info "Copying Built Frontend into Backend Package" msg_info "Copying Built Frontend"
cp -r /opt/mealie/frontend/dist /opt/mealie/mealie/frontend mkdir -p /opt/mealie/mealie/frontend
cp -r /opt/mealie/frontend/dist/* /opt/mealie/mealie/frontend/
msg_ok "Copied Frontend" msg_ok "Copied Frontend"
msg_info "Preparing Backend (Poetry)" msg_info "Downloading NLTK Data"
$STD uv venv /opt/mealie/.venv mkdir -p /nltk_data/
$STD /opt/mealie/.venv/bin/python -m ensurepip --upgrade
$STD /opt/mealie/.venv/bin/python -m pip install --upgrade pip
$STD /opt/mealie/.venv/bin/pip install uv
cd /opt/mealie cd /opt/mealie
$STD /opt/mealie/.venv/bin/uv pip install poetry==2.0.1 $STD uv run python -m nltk.downloader -d /nltk_data averaged_perceptron_tagger_eng
$STD /opt/mealie/.venv/bin/poetry self add "poetry-plugin-export>=1.9" msg_ok "Downloaded NLTK Data"
msg_ok "Prepared Poetry"
msg_info "Writing Environment File" msg_info "Writing Environment File"
SECRET=$(openssl rand -hex 32)
mkdir -p /run/secrets
cat <<EOF >/opt/mealie/mealie.env cat <<EOF >/opt/mealie/mealie.env
HOST=0.0.0.0 MEALIE_HOME=/opt/mealie
PORT=9000 NLTK_DATA=/nltk_data
SECRET=${SECRET}
DB_ENGINE=postgres DB_ENGINE=postgres
POSTGRES_SERVER=localhost POSTGRES_SERVER=localhost
POSTGRES_PORT=5432 POSTGRES_PORT=5432
POSTGRES_USER=${DB_USER} POSTGRES_USER=${PG_DB_USER}
POSTGRES_PASSWORD=${DB_PASS} POSTGRES_PASSWORD=${PG_DB_PASS}
POSTGRES_DB=${DB_NAME} POSTGRES_DB=${PG_DB_NAME}
NLTK_DATA=/nltk_data
PRODUCTION=true PRODUCTION=true
STATIC_FILES=/opt/mealie/frontend/dist HOST=0.0.0.0
PORT=9000
BASE_URL=http://${CONTAINER_IP}:9000
EOF EOF
msg_ok "Wrote Environment File" msg_ok "Wrote Environment File"
@ -90,54 +89,31 @@ cat <<'EOF' >/opt/mealie/start.sh
set -a set -a
source /opt/mealie/mealie.env source /opt/mealie/mealie.env
set +a set +a
exec /opt/mealie/.venv/bin/mealie exec uv run mealie
EOF EOF
chmod +x /opt/mealie/start.sh chmod +x /opt/mealie/start.sh
msg_ok "Created Start Script" msg_ok "Created Start Script"
msg_info "Building Mealie Backend Wheel"
cd /opt/mealie
$STD /opt/mealie/.venv/bin/poetry build --output dist
MEALIE_VERSION=$(/opt/mealie/.venv/bin/poetry version --short)
$STD /opt/mealie/.venv/bin/poetry export --only=main --extras=pgsql --output=dist/requirements.txt
echo "mealie[pgsql]==$MEALIE_VERSION \\" >>dist/requirements.txt
/opt/mealie/.venv/bin/poetry run pip hash dist/mealie-$MEALIE_VERSION*.whl | tail -n1 | tr -d '\n' >>dist/requirements.txt
echo " \\" >>dist/requirements.txt
/opt/mealie/.venv/bin/poetry run pip hash dist/mealie-$MEALIE_VERSION*.tar.gz | tail -n1 >>dist/requirements.txt
msg_ok "Built Wheel + Requirements"
msg_info "Installing Mealie via uv"
cd /opt/mealie
$STD /opt/mealie/.venv/bin/uv pip install --require-hashes -r /opt/mealie/dist/requirements.txt --find-links dist
msg_ok "Installed Mealie"
msg_info "Downloading NLTK Data"
mkdir -p /nltk_data/
$STD /opt/mealie/.venv/bin/python -m nltk.downloader -d /nltk_data averaged_perceptron_tagger_eng
msg_ok "Downloaded NLTK Data"
msg_info "Set Symbolic Links for Mealie"
ln -sf /opt/mealie/.venv/bin/mealie /usr/local/bin/mealie
ln -sf /opt/mealie/.venv/bin/poetry /usr/local/bin/poetry
msg_ok "Set Symbolic Links"
msg_info "Creating Systemd Service" msg_info "Creating Systemd Service"
cat <<EOF >/etc/systemd/system/mealie.service cat <<'EOF' >/etc/systemd/system/mealie.service
[Unit] [Unit]
Description=Mealie Backend Server Description=Mealie Recipe Manager
After=network.target postgresql.service After=network.target postgresql.service
Wants=postgresql.service
[Service] [Service]
Type=simple
User=root User=root
WorkingDirectory=/opt/mealie WorkingDirectory=/opt/mealie
ExecStart=/opt/mealie/start.sh ExecStart=/opt/mealie/start.sh
Restart=always Restart=on-failure
RestartSec=5
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target
EOF EOF
systemctl enable -q --now mealie systemctl enable -q --now mealie
msg_ok "Created Service" msg_ok "Created and Started Service"
motd_ssh motd_ssh
customize customize