From 2495469338d99f4c96b0855061b4cd7c453d7671 Mon Sep 17 00:00:00 2001 From: "push-app-to-main[bot]" <203845782+push-app-to-main[bot]@users.noreply.github.com> Date: Tue, 21 Apr 2026 15:21:29 +0200 Subject: [PATCH] anchor (#13895) Co-authored-by: push-app-to-main[bot] <203845782+push-app-to-main[bot]@users.noreply.github.com> Co-authored-by: Tobias <96661824+CrazyWolf13@users.noreply.github.com> --- ct/anchor.sh | 83 ++++++++++++++++++++++++++++++++ install/anchor-install.sh | 99 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 182 insertions(+) create mode 100644 ct/anchor.sh create mode 100644 install/anchor-install.sh diff --git a/ct/anchor.sh b/ct/anchor.sh new file mode 100644 index 000000000..6d8ea36cb --- /dev/null +++ b/ct/anchor.sh @@ -0,0 +1,83 @@ +#!/usr/bin/env bash +source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/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/ZhFahim/anchor + +APP="Anchor" +var_tags="${var_tags:-notes;productivity;sync}" +var_cpu="${var_cpu:-2}" +var_ram="${var_ram:-2048}" +var_disk="${var_disk:-10}" +var_os="${var_os:-debian}" +var_version="${var_version:-13}" +var_unprivileged="${var_unprivileged:-1}" + +header_info "$APP" +variables +color +catch_errors + +function update_script() { + header_info + check_container_storage + check_container_resources + + if [[ ! -f ~/.anchor ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + + if check_for_gh_release "anchor" "ZhFahim/anchor"; then + msg_info "Stopping Services" + systemctl stop anchor-web anchor-server + msg_ok "Stopped Services" + + msg_info "Backing up Configuration" + cp /opt/anchor/.env /opt/anchor.env.bak + msg_ok "Backed up Configuration" + + CLEAN_INSTALL=1 fetch_and_deploy_gh_release "anchor" "ZhFahim/anchor" "tarball" + + msg_info "Building Server" + cd /opt/anchor/server + $STD pnpm install --frozen-lockfile + $STD pnpm prisma generate + $STD pnpm build + [[ -d src/generated ]] && mkdir -p dist/src && cp -R src/generated dist/src/ + msg_ok "Built Server" + + msg_info "Building Web Interface" + cd /opt/anchor/web + $STD pnpm install --frozen-lockfile + SERVER_URL=http://127.0.0.1:3001 $STD pnpm build + cp -r .next/static .next/standalone/.next/static + cp -r public .next/standalone/public + msg_ok "Built Web Interface" + + cp /opt/anchor.env.bak /opt/anchor/.env + rm -f /opt/anchor.env.bak + + msg_info "Running Database Migrations" + cd /opt/anchor/server + set -a && source /opt/anchor/.env && set +a + $STD pnpm prisma migrate deploy + msg_ok "Ran Database Migrations" + + msg_info "Starting Services" + systemctl start anchor-server anchor-web + msg_ok "Started Services" + msg_ok "Updated ${APP}" + fi + 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 "${TAB}${GATEWAY}${BGN}http://${IP}:3000${CL}" diff --git a/install/anchor-install.sh b/install/anchor-install.sh new file mode 100644 index 000000000..e1407cfa4 --- /dev/null +++ b/install/anchor-install.sh @@ -0,0 +1,99 @@ +#!/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/ZhFahim/anchor + +source /dev/stdin <<<"$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +NODE_VERSION="24" NODE_MODULE="pnpm" setup_nodejs +PG_VERSION="17" setup_postgresql +PG_DB_NAME="anchor" PG_DB_USER="anchor" setup_postgresql_db + +fetch_and_deploy_gh_release "anchor" "ZhFahim/anchor" "tarball" + +msg_info "Building Server" +cd /opt/anchor/server +$STD pnpm install --frozen-lockfile +$STD pnpm prisma generate +$STD pnpm build +[[ -d src/generated ]] && mkdir -p dist/src && cp -R src/generated dist/src/ +msg_ok "Built Server" + +msg_info "Building Web Interface" +cd /opt/anchor/web +$STD pnpm install --frozen-lockfile +SERVER_URL=http://127.0.0.1:3001 $STD pnpm build +cp -r .next/static .next/standalone/.next/static +cp -r public .next/standalone/public +msg_ok "Built Web Interface" + +msg_info "Configuring Application" +JWT_SECRET=$(openssl rand -base64 32) +cat </opt/anchor/.env +APP_URL=http://${LOCAL_IP}:3000 +JWT_SECRET=${JWT_SECRET} +DATABASE_URL=postgresql://anchor:${PG_DB_PASS}@localhost:5432/anchor +PG_HOST=localhost +PG_USER=anchor +PG_PASSWORD=${PG_DB_PASS} +PG_DATABASE=anchor +PG_PORT=5432 +EOF +msg_ok "Configured Application" + +msg_info "Running Database Migrations" +cd /opt/anchor/server +set -a && source /opt/anchor/.env && set +a +$STD pnpm prisma migrate deploy +msg_ok "Ran Database Migrations" + +msg_info "Creating Services" +cat </etc/systemd/system/anchor-server.service +[Unit] +Description=Anchor API Server +After=network.target postgresql.service + +[Service] +Type=simple +User=root +WorkingDirectory=/opt/anchor/server +EnvironmentFile=/opt/anchor/.env +ExecStart=/usr/bin/node dist/src/main.js +Restart=on-failure +RestartSec=5 + +[Install] +WantedBy=multi-user.target +EOF +cat </etc/systemd/system/anchor-web.service +[Unit] +Description=Anchor Web Interface +After=network.target anchor-server.service + +[Service] +Type=simple +User=root +WorkingDirectory=/opt/anchor/web/.next/standalone +EnvironmentFile=/opt/anchor/.env +Environment=PORT=3000 HOSTNAME=0.0.0.0 NODE_ENV=production +ExecStart=/usr/bin/node server.js +Restart=on-failure +RestartSec=5 + +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now anchor-server anchor-web +msg_ok "Created Services" + +motd_ssh +customize +cleanup_lxc