From 6aaeeeeaf50ab40ac585c662550cfb319569a161 Mon Sep 17 00:00:00 2001 From: Amol Date: Mon, 21 Apr 2025 04:40:00 +0530 Subject: [PATCH] Create azure-vm-setup.md --- docs/docs/self-host/guides/azure-vm-setup.md | 197 +++++++++++++++++++ 1 file changed, 197 insertions(+) create mode 100644 docs/docs/self-host/guides/azure-vm-setup.md diff --git a/docs/docs/self-host/guides/azure-vm-setup.md b/docs/docs/self-host/guides/azure-vm-setup.md new file mode 100644 index 000000000..eb333e893 --- /dev/null +++ b/docs/docs/self-host/guides/azure-vm-setup.md @@ -0,0 +1,197 @@ +--- +title: OpenSign Deployment Guide on Azure VM via command-line +--- + +# πŸš€ OpenSign Deployment Guide on Azure VM (Frontend + Backend + MongoDB + Caddy) + +## 🧱 Prerequisites + +- Azure CLI installed +- A domain you control (e.g., `yourdomain.com`) +- Subdomain pointing to your VM (e.g., `opensign.yourdomain.com`) +- SSH access + +--- + +## πŸ”§ Step 1: Create an Azure VM + +### 1.1 Create Resource Group +```bash +az group create --name OpenSignRG --location eastus +``` + +### 1.2 Create Ubuntu VM +```bash +az vm create \ + --resource-group OpenSignRG \ + --name opensign-vm \ + --image Ubuntu2404 \ + --admin-username azureuser \ + --generate-ssh-keys \ + --size Standard_B1ms +``` + +### 1.3 Get VM IP +```bash +az vm list-ip-addresses --name opensign-vm --resource-group OpenSignRG --output table +``` + +--- + +## πŸ” Step 2: Open Required Ports + +Azure’s default port-opening approach conflicts if you use the same priorities. So instead, **add rules with increasing priorities** manually: + +### 2.1 Get NSG name +```bash +az network nsg list --resource-group OpenSignRG --query "[].name" +``` + +Assume it’s `opensign-vmNSG`. Then: + +### 2.2 Add inbound port rules +```bash +az network nsg rule create \ + --resource-group OpenSignRG \ + --nsg-name opensign-vmNSG \ + --name Allow-HTTP \ + --priority 1001 \ + --direction Inbound \ + --protocol Tcp \ + --access Allow \ + --destination-port-ranges 80 + +az network nsg rule create \ + --resource-group OpenSignRG \ + --nsg-name opensign-vmNSG \ + --name Allow-HTTPS \ + --priority 1002 \ + --direction Inbound \ + --protocol Tcp \ + --access Allow \ + --destination-port-ranges 443 + +az network nsg rule create \ + --resource-group OpenSignRG \ + --nsg-name opensign-vmNSG \ + --name Allow-Caddy-Internal \ + --priority 1003 \ + --direction Inbound \ + --protocol Tcp \ + --access Allow \ + --destination-port-ranges 3001 +``` + +--- + +## 🌍 Step 3: Point Domain to VM + +In your DNS provider (e.g., GoDaddy, Cloudflare): + +- Add an **A record**: + - Name: `opensign` + - Value: `` + - TTL: 1 min or Auto + +Let it propagate (~5–10 mins). + +--- + +## πŸ“¦ Step 4: SSH into the VM + +```bash +ssh azureuser@ +``` + +--- + +## 🐳 Step 5: Install Docker + Compose V2 + +```bash +sudo apt update && sudo apt install docker.io -y + +# Install Compose V2 (CLI plugin) +mkdir -p ~/.docker/cli-plugins/ +curl -SL https://github.com/docker/compose/releases/download/v2.24.5/docker-compose-linux-x86_64 -o ~/.docker/cli-plugins/docker-compose +chmod +x ~/.docker/cli-plugins/docker-compose + +# Enable Docker +sudo systemctl enable docker +``` + +Verify: +```bash +docker compose version +``` + +--- + +## πŸ“ Step 6: Set Up Project and Volumes + +### 6.1 Create a working directory +```bash +mkdir opensign && cd opensign +``` + +### 6.2 Download files +```bash +export HOST_URL=https://opensign.yourdomain.com + +curl -O https://raw.githubusercontent.com/OpenSignLabs/OpenSign/main/docker-compose.yml +curl -O https://raw.githubusercontent.com/OpenSignLabs/OpenSign/main/Caddyfile +curl -O https://raw.githubusercontent.com/OpenSignLabs/OpenSign/main/.env.local_dev +mv .env.local_dev .env.prod +``` +Make sure that you update the SMTP settings by editing the .env.prod file in order to receive emails. +--- + + +## βš™οΈ Step 7: Start the Stack + +Now boot the containers using Compose V2: + +```bash +docker compose up -d --force-recreate +``` + +--- + +## βœ… Step 8: Verify Everything + +- `https://opensign.yourdomain.com` loads the app with HTTPS +- Caddy fetched SSL certs automatically +- Backend routes work at `/api/*` +- MongoDB persists data +- Uploaded files persist via `opensign-files` volume + +Test: + +```bash +docker exec -it OpenSignServer-container ls /usr/src/app/files +docker volume inspect opensign-files +``` + +--- + +## πŸ“¦ Step 9: Auto-start on Reboot (optional) + +```bash +crontab -e +``` + +Add: +```bash +@reboot cd /home/azureuser/opensign && docker compose up -d +``` + +--- + +## πŸ”„ Backups (optional) + +```bash +# Backup MongoDB volume +docker run --rm -v opensign_data-volume:/data -v $(pwd):/backup ubuntu tar czvf /backup/mongo-backup.tar.gz /data + +# Backup OpenSign files +docker run --rm -v opensign_opensign-files:/data -v $(pwd):/backup ubuntu tar czvf /backup/files-backup.tar.gz /data +```