2025-07-14 11:46:19 +02:00
#!/usr/bin/env bash
# Copyright (c) 2021-2025 community-scripts ORG
# Author: MickLesk (CanbiZ)
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
# Source: https://mealie.io
source /dev/stdin <<< " $FUNCTIONS_FILE_PATH "
color
verb_ip6
catch_errors
setting_up_container
network_check
update_os
msg_info "Installing Dependencies"
2025-10-15 22:29:48 +02:00
$STD apt install -y \
2025-07-14 11:46:19 +02:00
build-essential \
libpq-dev \
libwebp-dev \
libsasl2-dev \
libldap2-dev \
2025-12-01 18:29:51 +01:00
libldap-common \
libssl-dev \
libldap2 \
gosu \
iproute2
2025-07-14 11:46:19 +02:00
msg_ok "Installed Dependencies"
PYTHON_VERSION = "3.12" setup_uv
POSTGRES_VERSION = "16" setup_postgresql
2025-12-01 18:29:51 +01:00
NODE_MODULE = "yarn" NODE_VERSION = "24" setup_nodejs
2025-07-14 11:46:19 +02:00
fetch_and_deploy_gh_release "mealie" "mealie-recipes/mealie" "tarball" "latest" "/opt/mealie"
2025-12-01 18:29:51 +01:00
PG_DB_NAME = "mealie_db" PG_DB_USER = "mealie_user" PG_DB_GRANT_SUPERUSER = "true" setup_postgresql_db
2025-07-14 11:46:19 +02:00
2025-12-01 18:29:51 +01:00
msg_info "Installing Python Dependencies with uv"
cd /opt/mealie
$STD uv sync --frozen --extra pgsql
msg_ok "Installed Python Dependencies"
2025-07-14 11:46:19 +02:00
msg_info "Building Frontend"
2025-12-01 18:29:51 +01:00
MEALIE_VERSION = $( <$HOME /.mealie)
CONTAINER_IP = $( hostname -I | awk '{print $1}' )
2025-07-14 11:46:19 +02:00
export NUXT_TELEMETRY_DISABLED = 1
cd /opt/mealie/frontend
2025-12-01 18:29:51 +01:00
$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
2025-07-14 11:46:19 +02:00
$STD yarn install --prefer-offline --frozen-lockfile --non-interactive --production= false --network-timeout 1000000
$STD yarn generate
msg_ok "Built Frontend"
2025-12-01 18:29:51 +01:00
msg_info "Copying Built Frontend"
mkdir -p /opt/mealie/mealie/frontend
cp -r /opt/mealie/frontend/dist/* /opt/mealie/mealie/frontend/
2025-07-14 11:46:19 +02:00
msg_ok "Copied Frontend"
2025-12-01 18:29:51 +01:00
msg_info "Downloading NLTK Data"
mkdir -p /nltk_data/
2025-07-14 11:46:19 +02:00
cd /opt/mealie
2025-12-01 18:29:51 +01:00
$STD uv run python -m nltk.downloader -d /nltk_data averaged_perceptron_tagger_eng
msg_ok "Downloaded NLTK Data"
2025-07-14 11:46:19 +02:00
msg_info "Writing Environment File"
2025-12-01 18:29:51 +01:00
SECRET = $( openssl rand -hex 32)
mkdir -p /run/secrets
2025-07-14 11:46:19 +02:00
cat <<EOF >/opt/mealie/mealie.env
2025-12-01 18:29:51 +01:00
MEALIE_HOME = /opt/mealie
NLTK_DATA = /nltk_data
SECRET = ${ SECRET }
2025-07-14 11:46:19 +02:00
DB_ENGINE = postgres
POSTGRES_SERVER = localhost
POSTGRES_PORT = 5432
2025-12-01 18:29:51 +01:00
POSTGRES_USER = ${ PG_DB_USER }
POSTGRES_PASSWORD = ${ PG_DB_PASS }
POSTGRES_DB = ${ PG_DB_NAME }
2025-07-14 11:46:19 +02:00
PRODUCTION = true
2025-12-01 18:29:51 +01:00
HOST = 0.0.0.0
PORT = 9000
BASE_URL = http://${ CONTAINER_IP } :9000
2025-07-14 11:46:19 +02:00
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
2025-12-01 18:29:51 +01:00
exec uv run mealie
2025-07-14 11:46:19 +02:00
EOF
chmod +x /opt/mealie/start.sh
msg_ok "Created Start Script"
msg_info "Creating Systemd Service"
2025-12-01 18:29:51 +01:00
cat <<'EOF' >/etc/systemd/system/mealie.service
2025-07-14 11:46:19 +02:00
[ Unit]
2025-12-01 18:29:51 +01:00
Description = Mealie Recipe Manager
2025-07-14 11:46:19 +02:00
After = network.target postgresql.service
2025-12-01 18:29:51 +01:00
Wants = postgresql.service
2025-07-14 11:46:19 +02:00
[ Service]
2025-12-01 18:29:51 +01:00
Type = simple
2025-07-14 11:46:19 +02:00
User = root
WorkingDirectory = /opt/mealie
ExecStart = /opt/mealie/start.sh
2025-12-01 18:29:51 +01:00
Restart = on-failure
RestartSec = 5
2025-07-14 11:46:19 +02:00
[ Install]
WantedBy = multi-user.target
EOF
systemctl enable -q --now mealie
2025-12-01 18:29:51 +01:00
msg_ok "Created and Started Service"
2025-07-14 11:46:19 +02:00
motd_ssh
customize
2025-11-22 17:27:13 +01:00
cleanup_lxc