|
| 1 | +--- |
| 2 | +title: OpenSign Deployment Guide on Azure VM via command-line |
| 3 | +--- |
| 4 | + |
| 5 | +# 🚀 OpenSign Deployment Guide on Azure VM (Frontend + Backend + MongoDB + Caddy) |
| 6 | + |
| 7 | +## 🧱 Prerequisites |
| 8 | + |
| 9 | +- Azure CLI installed |
| 10 | +- A domain you control (e.g., `yourdomain.com`) |
| 11 | +- Subdomain pointing to your VM (e.g., `opensign.yourdomain.com`) |
| 12 | +- SSH access |
| 13 | + |
| 14 | +--- |
| 15 | + |
| 16 | +## 🔧 Step 1: Create an Azure VM |
| 17 | + |
| 18 | +### 1.1 Create Resource Group |
| 19 | +```bash |
| 20 | +az group create --name OpenSignRG --location eastus |
| 21 | +``` |
| 22 | + |
| 23 | +### 1.2 Create Ubuntu VM |
| 24 | +```bash |
| 25 | +az vm create \ |
| 26 | + --resource-group OpenSignRG \ |
| 27 | + --name opensign-vm \ |
| 28 | + --image Ubuntu2404 \ |
| 29 | + --admin-username azureuser \ |
| 30 | + --generate-ssh-keys \ |
| 31 | + --size Standard_B1ms |
| 32 | +``` |
| 33 | + |
| 34 | +### 1.3 Get VM IP |
| 35 | +```bash |
| 36 | +az vm list-ip-addresses --name opensign-vm --resource-group OpenSignRG --output table |
| 37 | +``` |
| 38 | + |
| 39 | +--- |
| 40 | + |
| 41 | +## 🔐 Step 2: Open Required Ports |
| 42 | + |
| 43 | +Azure’s default port-opening approach conflicts if you use the same priorities. So instead, **add rules with increasing priorities** manually: |
| 44 | + |
| 45 | +### 2.1 Get NSG name |
| 46 | +```bash |
| 47 | +az network nsg list --resource-group OpenSignRG --query "[].name" |
| 48 | +``` |
| 49 | + |
| 50 | +Assume it’s `opensign-vmNSG`. Then: |
| 51 | + |
| 52 | +### 2.2 Add inbound port rules |
| 53 | +```bash |
| 54 | +az network nsg rule create \ |
| 55 | + --resource-group OpenSignRG \ |
| 56 | + --nsg-name opensign-vmNSG \ |
| 57 | + --name Allow-HTTP \ |
| 58 | + --priority 1001 \ |
| 59 | + --direction Inbound \ |
| 60 | + --protocol Tcp \ |
| 61 | + --access Allow \ |
| 62 | + --destination-port-ranges 80 |
| 63 | + |
| 64 | +az network nsg rule create \ |
| 65 | + --resource-group OpenSignRG \ |
| 66 | + --nsg-name opensign-vmNSG \ |
| 67 | + --name Allow-HTTPS \ |
| 68 | + --priority 1002 \ |
| 69 | + --direction Inbound \ |
| 70 | + --protocol Tcp \ |
| 71 | + --access Allow \ |
| 72 | + --destination-port-ranges 443 |
| 73 | + |
| 74 | +az network nsg rule create \ |
| 75 | + --resource-group OpenSignRG \ |
| 76 | + --nsg-name opensign-vmNSG \ |
| 77 | + --name Allow-Caddy-Internal \ |
| 78 | + --priority 1003 \ |
| 79 | + --direction Inbound \ |
| 80 | + --protocol Tcp \ |
| 81 | + --access Allow \ |
| 82 | + --destination-port-ranges 3001 |
| 83 | +``` |
| 84 | + |
| 85 | +--- |
| 86 | + |
| 87 | +## 🌍 Step 3: Point Domain to VM |
| 88 | + |
| 89 | +In your DNS provider (e.g., GoDaddy, Cloudflare): |
| 90 | + |
| 91 | +- Add an **A record**: |
| 92 | + - Name: `opensign` |
| 93 | + - Value: `<your VM public IP>` |
| 94 | + - TTL: 1 min or Auto |
| 95 | + |
| 96 | +Let it propagate (~5–10 mins). |
| 97 | + |
| 98 | +--- |
| 99 | + |
| 100 | +## 📦 Step 4: SSH into the VM |
| 101 | + |
| 102 | +```bash |
| 103 | +ssh azureuser@<your-vm-ip> |
| 104 | +``` |
| 105 | + |
| 106 | +--- |
| 107 | + |
| 108 | +## 🐳 Step 5: Install Docker + Compose V2 |
| 109 | + |
| 110 | +```bash |
| 111 | +sudo apt update && sudo apt install docker.io -y |
| 112 | + |
| 113 | +# Install Compose V2 (CLI plugin) |
| 114 | +mkdir -p ~/.docker/cli-plugins/ |
| 115 | +curl -SL https://github.com/docker/compose/releases/download/v2.24.5/docker-compose-linux-x86_64 -o ~/.docker/cli-plugins/docker-compose |
| 116 | +chmod +x ~/.docker/cli-plugins/docker-compose |
| 117 | + |
| 118 | +# Enable Docker |
| 119 | +sudo systemctl enable docker |
| 120 | +``` |
| 121 | + |
| 122 | +Verify: |
| 123 | +```bash |
| 124 | +docker compose version |
| 125 | +``` |
| 126 | + |
| 127 | +--- |
| 128 | + |
| 129 | +## 📁 Step 6: Set Up Project and Volumes |
| 130 | + |
| 131 | +### 6.1 Create a working directory |
| 132 | +```bash |
| 133 | +mkdir opensign && cd opensign |
| 134 | +``` |
| 135 | + |
| 136 | +### 6.2 Download files |
| 137 | +```bash |
| 138 | +export HOST_URL=https://opensign.yourdomain.com |
| 139 | + |
| 140 | +curl -O https://raw.githubusercontent.com/OpenSignLabs/OpenSign/main/docker-compose.yml |
| 141 | +curl -O https://raw.githubusercontent.com/OpenSignLabs/OpenSign/main/Caddyfile |
| 142 | +curl -O https://raw.githubusercontent.com/OpenSignLabs/OpenSign/main/.env.local_dev |
| 143 | +mv .env.local_dev .env.prod |
| 144 | +``` |
| 145 | +Make sure that you update the SMTP settings by editing the .env.prod file in order to receive emails. |
| 146 | +--- |
| 147 | + |
| 148 | + |
| 149 | +## ⚙️ Step 7: Start the Stack |
| 150 | + |
| 151 | +Now boot the containers using Compose V2: |
| 152 | + |
| 153 | +```bash |
| 154 | +docker compose up -d --force-recreate |
| 155 | +``` |
| 156 | + |
| 157 | +--- |
| 158 | + |
| 159 | +## ✅ Step 8: Verify Everything |
| 160 | + |
| 161 | +- `https://opensign.yourdomain.com` loads the app with HTTPS |
| 162 | +- Caddy fetched SSL certs automatically |
| 163 | +- Backend routes work at `/api/*` |
| 164 | +- MongoDB persists data |
| 165 | +- Uploaded files persist via `opensign-files` volume |
| 166 | + |
| 167 | +Test: |
| 168 | + |
| 169 | +```bash |
| 170 | +docker exec -it OpenSignServer-container ls /usr/src/app/files |
| 171 | +docker volume inspect opensign-files |
| 172 | +``` |
| 173 | + |
| 174 | +--- |
| 175 | + |
| 176 | +## 📦 Step 9: Auto-start on Reboot (optional) |
| 177 | + |
| 178 | +```bash |
| 179 | +crontab -e |
| 180 | +``` |
| 181 | + |
| 182 | +Add: |
| 183 | +```bash |
| 184 | +@reboot cd /home/azureuser/opensign && docker compose up -d |
| 185 | +``` |
| 186 | + |
| 187 | +--- |
| 188 | + |
| 189 | +## 🔄 Backups (optional) |
| 190 | + |
| 191 | +```bash |
| 192 | +# Backup MongoDB volume |
| 193 | +docker run --rm -v opensign_data-volume:/data -v $(pwd):/backup ubuntu tar czvf /backup/mongo-backup.tar.gz /data |
| 194 | + |
| 195 | +# Backup OpenSign files |
| 196 | +docker run --rm -v opensign_opensign-files:/data -v $(pwd):/backup ubuntu tar czvf /backup/files-backup.tar.gz /data |
| 197 | +``` |
0 commit comments