From 1632b0097b079f362dd006535e0cd85a9e846b1a Mon Sep 17 00:00:00 2001 From: "push-app-to-main[bot]" <203845782+push-app-to-main[bot]@users.noreply.github.com> Date: Fri, 13 Nov 2026 09:23:08 +0000 Subject: [PATCH] Add colanode (ct) --- ct/colanode.sh | 79 +++++++++++++++++++++++ install/colanode-install.sh | 122 ++++++++++++++++++++++++++++++++++++ 2 files changed, 201 insertions(+) create mode 100644 ct/colanode.sh create mode 100644 install/colanode-install.sh diff --git a/ct/colanode.sh b/ct/colanode.sh new file mode 100644 index 000000000..9ff4c6e85 --- /dev/null +++ b/ct/colanode.sh @@ -0,0 +1,79 @@ +#!/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://colanode.com/ + +APP="Colanode" +var_tags="${var_tags:-collaboration;notes;chat}" +var_cpu="${var_cpu:-4}" +var_ram="${var_ram:-4096}" +var_disk="${var_disk:-16}" +var_os="${var_os:-debian}" +var_version="${var_version:-13}" +#var_arm64="${var_arm64:-no}" # unset = ask the user; set yes/no only when verified +var_unprivileged="${var_unprivileged:-1}" + +header_info "$APP" +variables +color +catch_errors + +function update_script() { + header_info + check_container_storage + check_container_resources + + if [[ ! -d /opt/colanode ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + + if check_for_gh_release "colanode" "colanode/colanode"; then + msg_info "Stopping Services" + systemctl stop colanode-server + msg_ok "Stopped Services" + + create_backup /opt/colanode/.env + + CLEAN_INSTALL=1 fetch_and_deploy_gh_release "colanode" "colanode/colanode" "tarball" + + msg_info "Rebuilding Application" + cd /opt/colanode + export NODE_OPTIONS="--max-old-space-size=4096" + $STD npm install + $STD npm run build -w @colanode/core + $STD npm run build -w @colanode/crdt + $STD npm run build -w @colanode/server + $STD npm run build -w @colanode/client + $STD npm run build -w @colanode/ui + $STD npm run build -w @colanode/web + cp -r /opt/colanode/apps/web/dist/. /var/www/colanode/ + $STD npm prune --production + unset NODE_OPTIONS + msg_ok "Rebuilt Application" + + restore_backup + + msg_info "Starting Services" + systemctl start colanode-server + msg_ok "Started Services" + msg_ok "Updated successfully!" + 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 URLs:${CL}" +echo -e "${GATEWAY}${BGN}https://${IP}:4000${CL} (Web UI)" +echo -e "${INFO}${YW} Before using: import the self-signed cert into your browser:${CL}" +echo -e "${GATEWAY}${BGN}https://${IP}:4000/colanode.crt${CL}" +echo -e "${INFO}${YW} Server URL to use inside the app:${CL}" +echo -e "${GATEWAY}${BGN}https://${IP}:4000/config${CL}" diff --git a/install/colanode-install.sh b/install/colanode-install.sh new file mode 100644 index 000000000..109656f08 --- /dev/null +++ b/install/colanode-install.sh @@ -0,0 +1,122 @@ +#!/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://colanode.com/ + +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 \ + redis-server \ + nginx +msg_ok "Installed Dependencies" + +PG_VERSION="17" PG_MODULES="pgvector" setup_postgresql +PG_DB_NAME="colanode_db" PG_DB_USER="colanode" PG_DB_EXTENSIONS="vector" setup_postgresql_db +NODE_VERSION="22" setup_nodejs + +fetch_and_deploy_gh_release "colanode" "colanode/colanode" "tarball" + +msg_info "Building Application" +cd /opt/colanode +export NODE_OPTIONS="--max-old-space-size=4096" +$STD npm install +$STD npm run build -w @colanode/core +$STD npm run build -w @colanode/crdt +$STD npm run build -w @colanode/server +$STD npm run build -w @colanode/client +$STD npm run build -w @colanode/ui +$STD npm run build -w @colanode/web +$STD npm prune --production +unset NODE_OPTIONS +msg_ok "Built Application" + +msg_info "Configuring Application" +mkdir -p /var/lib/colanode/storage /var/www/colanode +cp -r /opt/colanode/apps/web/dist/. /var/www/colanode/ +cat </opt/colanode/.env +POSTGRES_URL=postgresql://${PG_DB_USER}:${PG_DB_PASS}@127.0.0.1:5432/${PG_DB_NAME} +REDIS_URL=redis://127.0.0.1:6379 +NODE_ENV=production +EOF +msg_ok "Configured Application" + +msg_info "Configuring Nginx" +create_self_signed_cert "colanode" +# Make cert available for browser import (required for Service Worker to work) +cp /etc/ssl/colanode/colanode.crt /var/www/colanode/colanode.crt +cat </etc/nginx/sites-available/colanode +server { + listen 4000 ssl; + server_name _; + root /var/www/colanode; + index index.html; + + ssl_certificate /etc/ssl/colanode/colanode.crt; + ssl_certificate_key /etc/ssl/colanode/colanode.key; + + # Required for SharedArrayBuffer / OPFS SQLite (WASM) + add_header Cross-Origin-Opener-Policy "same-origin" always; + add_header Cross-Origin-Embedder-Policy "require-corp" always; + + # Proxy API and WebSocket traffic to the Node.js server + location ~ ^/(config|client)(/.*)?$ { + proxy_pass http://127.0.0.1:3000; + proxy_http_version 1.1; + proxy_set_header Upgrade \$http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_set_header Host \$host; + proxy_set_header X-Real-IP \$remote_addr; + proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto \$scheme; + } + + # Serve self-signed cert for browser import + location = /colanode.crt { + default_type application/x-x509-ca-cert; + } + + location / { + try_files \$uri \$uri/ /index.html; + } +} +EOF +ln -sf /etc/nginx/sites-available/colanode /etc/nginx/sites-enabled/colanode +rm -f /etc/nginx/sites-enabled/default +systemctl reload nginx +msg_ok "Configured Nginx" + +msg_info "Creating Service" +cat </etc/systemd/system/colanode-server.service +[Unit] +Description=Colanode Server +After=network.target postgresql.service redis-server.service +Requires=postgresql.service redis-server.service + +[Service] +Type=simple +User=root +WorkingDirectory=/opt/colanode +EnvironmentFile=/opt/colanode/.env +ExecStart=/usr/bin/node apps/server/dist/index.js +Restart=on-failure +RestartSec=5 + +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now colanode-server +msg_ok "Created Service" + +motd_ssh +customize +cleanup_lxc