You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

326 lines
10 KiB

5 years ago
  1. {
  2. "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  3. "contentVersion": "1.0.0.0",
  4. "parameters": {
  5. "appName": {
  6. "type": "string",
  7. "minLength": 1,
  8. "metadata": {
  9. "description": "The name for the webapp. Must be globally unique."
  10. }
  11. },
  12. "secretKey": {
  13. "type": "securestring",
  14. "minLength": 16,
  15. "metadata": {
  16. "description": "The value to use as the Django secret key."
  17. }
  18. },
  19. "adminUserName": {
  20. "type": "string",
  21. "minLength": 1,
  22. "metadata": {
  23. "description": "The user name for the admin account."
  24. }
  25. },
  26. "adminContactEmail": {
  27. "type": "string",
  28. "minLength": 1,
  29. "metadata": {
  30. "description": "The contact email address for the admin account."
  31. }
  32. },
  33. "adminPassword": {
  34. "type": "securestring",
  35. "minLength": 16,
  36. "metadata": {
  37. "description": "The password for the admin account."
  38. }
  39. },
  40. "appServiceSku": {
  41. "type": "string",
  42. "defaultValue": "B2",
  43. "allowedValues": [
  44. "B1",
  45. "B2",
  46. "B3",
  47. "S1",
  48. "S2",
  49. "S3"
  50. ],
  51. "metadata": {
  52. "description": "The SKU of the webapp hosting tier."
  53. }
  54. },
  55. "databaseCores": {
  56. "type": "int",
  57. "defaultValue": 2,
  58. "allowedValues": [
  59. 2,
  60. 4,
  61. 8,
  62. 16,
  63. 32,
  64. 64
  65. ],
  66. "metadata": {
  67. "description": "The number of vCores to provision for the PostgreSQL server."
  68. }
  69. },
  70. "databaseSize": {
  71. "type": "int",
  72. "minValue": 51200,
  73. "defaultValue": 51200,
  74. "metadata": {
  75. "description": "The storage capacity to provision for the PostgreSQL server."
  76. }
  77. },
  78. "databaseName": {
  79. "type": "string",
  80. "minLength": 1,
  81. "defaultValue": "doccano",
  82. "metadata": {
  83. "description": "The name of the database to provision on the PostgreSQL server."
  84. }
  85. },
  86. "dockerImageName": {
  87. "type": "string",
  88. "minLength": 1,
  89. "defaultValue": "chakkiworks/doccano:latest",
  90. "metadata": {
  91. "description": "The Docker image to deploy."
  92. }
  93. },
  94. "dockerRegistry": {
  95. "type": "string",
  96. "defaultValue": "",
  97. "metadata": {
  98. "description": "The registry of the Docker image."
  99. }
  100. },
  101. "dockerRegistryUserName": {
  102. "type": "string",
  103. "defaultValue": "",
  104. "metadata": {
  105. "description": "The user name for the Docker registry."
  106. }
  107. },
  108. "dockerRegistryPassword": {
  109. "type": "securestring",
  110. "defaultValue": "",
  111. "metadata": {
  112. "description": "The password for the Docker registry."
  113. }
  114. }
  115. },
  116. "variables": {
  117. "location": "[resourceGroup().location]",
  118. "databaseSkuTier": "GeneralPurpose",
  119. "databaseSkuFamily": "Gen5",
  120. "databaseSkuName": "[concat('GP_', variables('databaseSkuFamily'), '_', parameters('databaseCores'))]",
  121. "databaseVersion": "9.6",
  122. "databaseServerPort": 5432,
  123. "databaseServerName": "[concat(parameters('appName'),'-state')]",
  124. "databaseUserCredentials" : "[concat(uriComponent(concat(parameters('adminUserName'), '@', variables('databaseServerName'))), ':', parameters('adminPassword'))]",
  125. "databaseFqdn" : "[concat( variables('databaseServerName'), '.postgres.database.azure.com:', variables('databaseServerPort'))]",
  126. "databaseConnectionString": "[concat('pgsql://', variables('databaseUserCredentials'), '@', variables('databaseFqdn'), '/', parameters('databaseName'))]",
  127. "setupScriptName": "[concat(parameters('appName'),'-setup')]",
  128. "appServicePlanName": "[concat(parameters('appName'),'-hosting')]",
  129. "analyticsName": "[concat(parameters('appName'),'-analytics')]",
  130. "dockerRegistryCredential": {
  131. "password": "[parameters('dockerRegistryPassword')]",
  132. "username": "[parameters('dockerRegistryUserName')]",
  133. "server": "[parameters('dockerRegistry')]"
  134. },
  135. "appFqdn": "[concat(parameters('appName'),'.azurewebsites.net')]"
  136. },
  137. "resources": [
  138. {
  139. "type": "Microsoft.Insights/components",
  140. "apiVersion": "2015-05-01",
  141. "name": "[variables('analyticsName')]",
  142. "location": "[variables('location')]",
  143. "tags": {},
  144. "kind": "web",
  145. "properties": {
  146. "Application_Type": "web"
  147. }
  148. },
  149. {
  150. "apiVersion": "2017-08-01",
  151. "type": "Microsoft.Web/serverfarms",
  152. "kind": "linux",
  153. "name": "[variables('appServicePlanName')]",
  154. "location": "[variables('location')]",
  155. "properties": {
  156. "reserved": true
  157. },
  158. "dependsOn": [],
  159. "sku": {
  160. "name": "[parameters('appServiceSku')]"
  161. }
  162. },
  163. {
  164. "apiVersion": "2017-12-01",
  165. "type": "Microsoft.DBforPostgreSQL/servers",
  166. "location": "[variables('location')]",
  167. "name": "[variables('databaseServerName')]",
  168. "sku": {
  169. "name": "[variables('databaseSkuName')]",
  170. "tier": "[variables('databaseSkuTier')]",
  171. "family": "[variables('databaseSkuFamily')]",
  172. "capacity": "[parameters('databaseCores')]",
  173. "size": "[parameters('databaseSize')]"
  174. },
  175. "properties": {
  176. "version": "[variables('databaseVersion')]",
  177. "administratorLogin": "[parameters('adminUserName')]",
  178. "administratorLoginPassword": "[parameters('adminPassword')]",
  179. "storageMB": "[parameters('databaseSize')]"
  180. },
  181. "resources": [
  182. {
  183. "name": "allowAzure",
  184. "type": "firewallrules",
  185. "apiVersion": "2017-12-01",
  186. "location": "[variables('location')]",
  187. "properties": {
  188. "startIpAddress": "0.0.0.0",
  189. "endIpAddress": "0.0.0.0"
  190. },
  191. "dependsOn": [
  192. "[resourceId('Microsoft.DBforPostgreSQL/servers/', variables('databaseServerName'))]"
  193. ]
  194. },
  195. {
  196. "name": "[parameters('databaseName')]",
  197. "type": "databases",
  198. "apiVersion": "2017-12-01",
  199. "properties": {
  200. "charset": "utf8",
  201. "collation": "English_United States.1252"
  202. },
  203. "dependsOn": [
  204. "[resourceId('Microsoft.DBforPostgreSQL/servers/', variables('databaseServerName'))]"
  205. ]
  206. }
  207. ]
  208. },
  209. {
  210. "name": "[variables('setupScriptName')]",
  211. "type": "Microsoft.ContainerInstance/containerGroups",
  212. "apiVersion": "2018-10-01",
  213. "location": "[variables('location')]",
  214. "properties": {
  215. "imageRegistryCredentials": "[if(equals(parameters('dockerRegistry'), ''), json('null'), array(variables('dockerRegistryCredential')))]",
  216. "containers": [
  217. {
  218. "name": "createadmin",
  219. "properties": {
  220. "image": "[parameters('dockerImageName')]",
  221. "command": [
  222. "tools/create-admin.sh",
  223. "[parameters('adminUserName')]",
  224. "[parameters('adminContactEmail')]",
  225. "[parameters('adminPassword')]"
  226. ],
  227. "environmentVariables": [
  228. {
  229. "name": "DEBUG",
  230. "value": "False"
  231. },
  232. {
  233. "name": "SECRET_KEY",
  234. "value": "[parameters('secretKey')]"
  235. },
  236. {
  237. "name": "DATABASE_URL",
  238. "value": "[variables('databaseConnectionString')]"
  239. }
  240. ],
  241. "resources": {
  242. "requests": {
  243. "cpu": "1",
  244. "memoryInGb": "1.5"
  245. }
  246. }
  247. }
  248. }
  249. ],
  250. "osType": "Linux",
  251. "restartPolicy": "Never"
  252. },
  253. "dependsOn": [
  254. "[resourceId('Microsoft.DBforPostgreSQL/servers/', variables('databaseServerName'))]"
  255. ]
  256. },
  257. {
  258. "type": "Microsoft.Web/sites",
  259. "apiVersion": "2016-08-01",
  260. "name": "[parameters('appName')]",
  261. "kind": "app,linux,container",
  262. "location": "[variables('location')]",
  263. "dependsOn": [
  264. "[resourceId('Microsoft.DBforPostgreSQL/servers/', variables('databaseServerName'))]",
  265. "[resourceId('Microsoft.Insights/components', variables('analyticsName'))]",
  266. "[resourceId('Microsoft.Web/serverfarms', variables('appServicePlanName'))]"
  267. ],
  268. "properties": {
  269. "name": "[parameters('appName')]",
  270. "siteConfig": {
  271. "linuxFxVersion": "[concat('DOCKER|', parameters('dockerImageName'))]",
  272. "alwaysOn": true,
  273. "appSettings": [
  274. {
  275. "name": "WEBSITES_ENABLE_APP_SERVICE_STORAGE",
  276. "value": "false"
  277. },
  278. {
  279. "name": "DOCKER_REGISTRY_SERVER_URL",
  280. "value": "[parameters('dockerRegistry')]"
  281. },
  282. {
  283. "name": "DOCKER_REGISTRY_SERVER_USERNAME",
  284. "value": "[parameters('dockerRegistryUserName')]"
  285. },
  286. {
  287. "name": "DOCKER_REGISTRY_SERVER_PASSWORD",
  288. "value": "[parameters('dockerRegistryPassword')]"
  289. },
  290. {
  291. "name": "AZURE_APPINSIGHTS_IKEY",
  292. "value": "[reference(resourceId('Microsoft.Insights/components', variables('analyticsName')), '2014-04-01').InstrumentationKey]"
  293. },
  294. {
  295. "name": "GOOGLE_TRACKING_ID",
  296. "value": ""
  297. },
  298. {
  299. "name": "DEBUG",
  300. "value": "False"
  301. },
  302. {
  303. "name": "SECRET_KEY",
  304. "value": "[parameters('secretKey')]"
  305. },
  306. {
  307. "name": "DATABASE_URL",
  308. "value": "[variables('databaseConnectionString')]"
  309. }
  310. ]
  311. },
  312. "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('appServicePlanName'))]"
  313. }
  314. }
  315. ],
  316. "outputs": {
  317. "appServer": {
  318. "type": "string",
  319. "value": "[concat(variables('appFqdn'))]"
  320. },
  321. "databaseServer": {
  322. "type": "string",
  323. "value": "[variables('databaseFqdn')]"
  324. }
  325. }
  326. }