Files
ProxmoxVE/install/mealie-install.sh
T
CanbiZ (MickLesk) 76b839b04c several scripts: let uv see the project before syncing it | refactor some scripts that use uv (#17436)
* Let uv see the project before syncing it

uv refuses to run when a project pins a required-version it does not
match, in either direction: RomM pins ==0.12.13, which fails against
both the 0.10.3 a container was built with and the 0.12.17 latest
installs.

UV_PROJECT_DIR points setup_uv at the project so it reads that pin. It
is a prefix like PYTHON_VERSION and UV_VERSION, and the call sits
directly under fetch_and_deploy: the project is on disk by then, and
the deploy has closed its message block, which setup_uv needs since it
opens one of its own. That is also the only call needed - nothing
between the old early call and the deploy uses uv or Python, so the two
collapse into one.

Two things found along the way:

UV_PYTHON was set as a command prefix on setup_uv in 14 places. setup_uv
reads PYTHON_VERSION, never UV_PYTHON, and a prefix assignment does not
outlive the call, so those pins did nothing. They now use
PYTHON_VERSION, which installs the interpreter they were asking for.

Five update scripts had no setup_uv at all while their install
counterpart pinned a Python version. They now carry the same pin.

immich is left out: it runs uv through sudo -u inside a retry loop.

* yubal: drop the uv 0.7.19 pin

The pin came in with the script and was never explained. uv 0.7.19 is
from 2025-07-02; yubal's uv.lock has carried revision 3 since at least
2025-12-27, and older uv refuses a newer lockfile revision. The script
runs uv sync --frozen, so there is no fallback.

yubal declares no required-version of its own, so latest is what it
gets - and if it ever pins one, that pin is now honoured.
2026-09-22 16:06:15 +02:00

139 lines
3.7 KiB
Bash

#!/usr/bin/env bash
# Copyright (c) 2021-2026 community-scripts ORG
# Author: MickLesk (CanbiZ)
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
# Source: https://mealie.io | Github: https://github.com/mealie-recipes/mealie
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
catch_errors
setting_up_container
network_check
update_os
msg_info "Installing Dependencies"
$STD apt install -y \
build-essential \
libpq-dev \
libwebp-dev \
libsasl2-dev \
libldap2-dev \
libldap-common \
libssl-dev \
libldap2 \
gosu \
iproute2
msg_ok "Installed Dependencies"
PG_VERSION="16" setup_postgresql
fetch_and_deploy_gh_release "mealie" "mealie-recipes/mealie" "tarball"
PYTHON_VERSION="3.12" UV_PROJECT_DIR="/opt/mealie" setup_uv
PG_DB_NAME="mealie_db" PG_DB_USER="mealie_user" PG_DB_GRANT_SUPERUSER="true" setup_postgresql_db
if [[ -f /opt/mealie/frontend/pnpm-lock.yaml ]]; then
FRONTEND_PKG="pnpm"
NODE_MODULE="pnpm@11" NODE_VERSION="24" setup_nodejs
else
FRONTEND_PKG="yarn"
NODE_MODULE="yarn" NODE_VERSION="24" setup_nodejs
fi
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)
export NUXT_TELEMETRY_DISABLED=1
cd /opt/mealie/frontend
SITE_SETTINGS=$(find /opt/mealie/frontend -name "site-settings.vue" -path "*/admin/*" | head -1)
$STD sed -i "s|https://github.com/mealie-recipes/mealie/commit/|https://github.com/mealie-recipes/mealie/releases/tag/|g" "$SITE_SETTINGS"
$STD sed -i "s|value: data.buildId,|value: \"v${MEALIE_VERSION}\",|g" "$SITE_SETTINGS"
$STD sed -i "s|value: data.production ? i18n.t(\"about.production\") : i18n.t(\"about.development\"),|value: \"bare-metal\",|g" "$SITE_SETTINGS"
if [[ "${FRONTEND_PKG}" == "pnpm" ]]; then
$STD pnpm install --prefer-offline --frozen-lockfile
$STD pnpm generate
$STD pnpm store prune
else
$STD yarn install --prefer-offline --frozen-lockfile --non-interactive --production=false --network-timeout 1000000
$STD yarn generate
$STD yarn cache clean
fi
msg_ok "Built Frontend"
msg_info "Copying Built Frontend"
if [[ -n "$(ls -A /opt/mealie/frontend/.output/public 2>/dev/null)" ]]; then
FRONTEND_SRC="/opt/mealie/frontend/.output/public"
elif [[ -n "$(ls -A /opt/mealie/frontend/dist 2>/dev/null)" ]]; then
FRONTEND_SRC="/opt/mealie/frontend/dist"
else
msg_error "Frontend build output not found"
exit
fi
mkdir -p /opt/mealie/mealie/frontend
cp -r "${FRONTEND_SRC}/." /opt/mealie/mealie/frontend/
msg_ok "Copied Frontend"
setup_nltk "averaged_perceptron_tagger_eng" "/nltk_data"
msg_info "Writing Environment File"
SECRET=$(openssl rand -hex 32)
mkdir -p /run/secrets
cat <<EOF >/opt/mealie/mealie.env
MEALIE_HOME=/opt/mealie
NLTK_DATA=/nltk_data
SECRET=${SECRET}
DB_ENGINE=postgres
POSTGRES_SERVER=localhost
POSTGRES_PORT=5432
POSTGRES_USER=${PG_DB_USER}
POSTGRES_PASSWORD=${PG_DB_PASS}
POSTGRES_DB=${PG_DB_NAME}
PRODUCTION=true
HOST=0.0.0.0
PORT=9000
BASE_URL=http://${LOCAL_IP}:9000
EOF
msg_ok "Wrote Environment File"
msg_info "Creating Start Script"
cat <<'EOF' >/opt/mealie/start.sh
#!/bin/bash
set -a
source /opt/mealie/mealie.env
set +a
exec uv run mealie
EOF
chmod +x /opt/mealie/start.sh
msg_ok "Created Start Script"
msg_info "Creating Systemd Service"
cat <<'EOF' >/etc/systemd/system/mealie.service
[Unit]
Description=Mealie Recipe Manager
After=network.target postgresql.service
Wants=postgresql.service
[Service]
Type=simple
User=root
WorkingDirectory=/opt/mealie
ExecStart=/opt/mealie/start.sh
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
EOF
systemctl enable -q --now mealie
msg_ok "Created and Started Service"
motd_ssh
customize
cleanup_lxc