diff --git a/ct/nocobase.sh b/ct/nocobase.sh new file mode 100644 index 000000000..8acf1440e --- /dev/null +++ b/ct/nocobase.sh @@ -0,0 +1,77 @@ +#!/usr/bin/env bash +_cs_boot="${COMMUNITY_SCRIPTS_CORE_DIR:-$(dirname "${BASH_SOURCE[0]}")/../../core}/core/build.func" +source "$_cs_boot" 2>/dev/null || source <(curl -fsSL "${COMMUNITY_SCRIPTS_CORE_URL:-https://raw.githubusercontent.com/community-scripts/core/main}/core/build.func") +# Copyright (c) 2021-2026 community-scripts ORG +# Author: MickLesk (CanbiZ) +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://github.com/nocobase/nocobase + +APP="NocoBase" +var_tags="${var_tags:-no-code;low-code;database}" +var_cpu="${var_cpu:-2}" +var_ram="${var_ram:-2048}" +var_disk="${var_disk:-8}" +var_os="${var_os:-debian}" +var_version="${var_version:-13}" +var_arm64="${var_arm64:-yes}" +var_unprivileged="${var_unprivileged:-1}" + +export var_admin_email="${var_admin_email:-}" +export var_admin_pass="${var_admin_pass:-}" + +header_info "$APP" +variables +color +catch_errors + +function update_script() { + header_info + check_container_storage + check_container_resources + + if [[ ! -f /opt/nocobase/node_modules/@nocobase/app/package.json ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + + CURRENT=$(node -p "require('/opt/nocobase/node_modules/@nocobase/app/package.json').version") + RELEASE=$(npm view @nocobase/app version 2>/dev/null) + if [[ -z "$RELEASE" ]]; then + msg_error "Could not determine the latest NocoBase version from npm" + exit 1 + fi + if [[ "$RELEASE" == "$CURRENT" ]]; then + msg_ok "No update available: NocoBase (${CURRENT})" + exit + fi + + NODE_VERSION="22" NODE_MODULE="yarn" setup_nodejs + + msg_info "Stopping NocoBase" + systemctl stop nocobase + msg_ok "Stopped NocoBase" + + msg_info "Updating NocoBase from ${CURRENT} to ${RELEASE}" + cd /opt/nocobase + $STD npm pkg set "dependencies.@nocobase/app=${RELEASE}" + $STD yarn install --production + $STD yarn nocobase upgrade --skip-code-update + $STD yarn cache clean + msg_ok "Updated NocoBase from ${CURRENT} to ${RELEASE}" + + msg_info "Starting NocoBase" + systemctl start nocobase + msg_ok "Started NocoBase" + msg_ok "Updated successfully!" + exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}" +echo -e "${INFO}${YW}Access it using the following URL:${CL}" +echo -e "${GATEWAY}${BGN}http://${IP}:13000${CL}" +echo -e "${INFO}${YW}Root login: /opt/nocobase_data/.env (inside the container)${CL}" diff --git a/install/nocobase-install.sh b/install/nocobase-install.sh new file mode 100644 index 000000000..bd513c5da --- /dev/null +++ b/install/nocobase-install.sh @@ -0,0 +1,74 @@ +#!/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://github.com/nocobase/nocobase + +source /dev/stdin <<<"$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +NODE_VERSION="22" NODE_MODULE="yarn" setup_nodejs +PG_VERSION="17" setup_postgresql +PG_DB_NAME="nocobase" PG_DB_USER="nocobase" PG_DB_CREDS_FILE="/dev/null" setup_postgresql_db + +msg_info "Installing NocoBase" +NOCOBASE_VERSION="${var_appversion:-latest}" +cd /opt +$STD npx -y "create-nocobase-app@${NOCOBASE_VERSION#v}" nocobase --skip-dev-dependencies -d postgres +mkdir -p /opt/nocobase_data/storage +cat </opt/nocobase_data/.env +APP_ENV=production +APP_KEY=$(random_password 64) +APP_PORT=13000 +API_BASE_PATH=/api/ +STORAGE_PATH=/opt/nocobase_data/storage +DB_LOGGING=off +DB_DIALECT=postgres +DB_HOST=localhost +DB_PORT=5432 +DB_DATABASE=nocobase +DB_USER=nocobase +DB_PASSWORD=${PG_DB_PASS} +INIT_ROOT_EMAIL=${var_admin_email:-admin@nocobase.com} +INIT_ROOT_PASSWORD=${var_admin_pass:-$(random_password)} +INIT_ROOT_NICKNAME=Super Admin +INIT_ROOT_USERNAME=nocobase +EOF +chmod 600 /opt/nocobase_data/.env +rm -rf /opt/nocobase/storage +ln -sf /opt/nocobase_data/.env /opt/nocobase/.env +cd /opt/nocobase +$STD yarn install --production +$STD yarn nocobase install --lang=en-US +$STD yarn cache clean +msg_ok "Installed NocoBase" + +msg_info "Creating Service" +cat </etc/systemd/system/nocobase.service +[Unit] +Description=NocoBase +After=network.target postgresql.service +Wants=postgresql.service + +[Service] +Type=simple +WorkingDirectory=/opt/nocobase +ExecStart=/usr/bin/yarn start +Restart=always +RestartSec=5 + +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now nocobase +msg_ok "Created Service" + +motd_ssh +customize +cleanup_lxc