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.

287 lines
8.7 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. },
  95. "variables": {
  96. "location": "[resourceGroup().location]",
  97. "databaseSkuTier": "GeneralPurpose",
  98. "databaseSkuFamily": "Gen5",
  99. "databaseSkuName": "[concat('GP_', variables('databaseSkuFamily'), '_', parameters('databaseCores'))]",
  100. "databaseVersion": "9.6",
  101. "databaseServerPort": 5432,
  102. "databaseServerName": "[concat(parameters('appName'),'-state')]",
  103. "databaseUserCredentials" : "[concat(uriComponent(concat(parameters('adminUserName'), '@', variables('databaseServerName'))), ':', parameters('adminPassword'))]",
  104. "databaseFqdn" : "[concat( variables('databaseServerName'), '.postgres.database.azure.com:', variables('databaseServerPort'))]",
  105. "databaseConnectionString": "[concat('pgsql://', variables('databaseUserCredentials'), '@', variables('databaseFqdn'), '/', parameters('databaseName'))]",
  106. "setupScriptName": "[concat(parameters('appName'),'-setup')]",
  107. "appServicePlanName": "[concat(parameters('appName'),'-hosting')]",
  108. "appFqdn": "[concat(parameters('appName'),'.azurewebsites.net')]",
  109. "analyticsName": "[concat(parameters('appName'),'-analytics')]"
  110. },
  111. "resources": [
  112. {
  113. "type": "Microsoft.Insights/components",
  114. "apiVersion": "2015-05-01",
  115. "name": "[variables('analyticsName')]",
  116. "location": "[variables('location')]",
  117. "tags": {},
  118. "kind": "web",
  119. "properties": {
  120. "Application_Type": "web"
  121. }
  122. },
  123. {
  124. "apiVersion": "2017-08-01",
  125. "type": "Microsoft.Web/serverfarms",
  126. "kind": "linux",
  127. "name": "[variables('appServicePlanName')]",
  128. "location": "[variables('location')]",
  129. "properties": {
  130. "reserved": true
  131. },
  132. "dependsOn": [],
  133. "sku": {
  134. "name": "[parameters('appServiceSku')]"
  135. }
  136. },
  137. {
  138. "apiVersion": "2017-12-01",
  139. "type": "Microsoft.DBforPostgreSQL/servers",
  140. "location": "[variables('location')]",
  141. "name": "[variables('databaseServerName')]",
  142. "sku": {
  143. "name": "[variables('databaseSkuName')]",
  144. "tier": "[variables('databaseSkuTier')]",
  145. "family": "[variables('databaseSkuFamily')]",
  146. "capacity": "[parameters('databaseCores')]",
  147. "size": "[parameters('databaseSize')]"
  148. },
  149. "properties": {
  150. "version": "[variables('databaseVersion')]",
  151. "administratorLogin": "[parameters('adminUserName')]",
  152. "administratorLoginPassword": "[parameters('adminPassword')]",
  153. "storageMB": "[parameters('databaseSize')]"
  154. },
  155. "resources": [
  156. {
  157. "name": "allowAzure",
  158. "type": "firewallrules",
  159. "apiVersion": "2017-12-01",
  160. "location": "[variables('location')]",
  161. "properties": {
  162. "startIpAddress": "0.0.0.0",
  163. "endIpAddress": "0.0.0.0"
  164. },
  165. "dependsOn": [
  166. "[resourceId('Microsoft.DBforPostgreSQL/servers/', variables('databaseServerName'))]"
  167. ]
  168. },
  169. {
  170. "name": "[parameters('databaseName')]",
  171. "type": "databases",
  172. "apiVersion": "2017-12-01",
  173. "properties": {
  174. "charset": "utf8",
  175. "collation": "English_United States.1252"
  176. },
  177. "dependsOn": [
  178. "[resourceId('Microsoft.DBforPostgreSQL/servers/', variables('databaseServerName'))]"
  179. ]
  180. }
  181. ]
  182. },
  183. {
  184. "name": "[variables('setupScriptName')]",
  185. "type": "Microsoft.ContainerInstance/containerGroups",
  186. "apiVersion": "2018-10-01",
  187. "location": "[variables('location')]",
  188. "properties": {
  189. "containers": [
  190. {
  191. "name": "createadmin",
  192. "properties": {
  193. "image": "[parameters('dockerImageName')]",
  194. "command": [
  195. "tools/create-admin.sh",
  196. "[parameters('adminUserName')]",
  197. "[parameters('adminContactEmail')]",
  198. "[parameters('adminPassword')]"
  199. ],
  200. "environmentVariables": [
  201. {
  202. "name": "DEBUG",
  203. "value": "False"
  204. },
  205. {
  206. "name": "SECRET_KEY",
  207. "value": "[parameters('secretKey')]"
  208. },
  209. {
  210. "name": "DATABASE_URL",
  211. "value": "[variables('databaseConnectionString')]"
  212. }
  213. ],
  214. "resources": {
  215. "requests": {
  216. "cpu": "1",
  217. "memoryInGb": "1.5"
  218. }
  219. }
  220. }
  221. }
  222. ],
  223. "osType": "Linux",
  224. "restartPolicy": "Never"
  225. },
  226. "dependsOn": [
  227. "[resourceId('Microsoft.DBforPostgreSQL/servers/', variables('databaseServerName'))]"
  228. ]
  229. },
  230. {
  231. "type": "Microsoft.Web/sites",
  232. "apiVersion": "2016-08-01",
  233. "name": "[parameters('appName')]",
  234. "kind": "app,linux,container",
  235. "location": "[variables('location')]",
  236. "dependsOn": [
  237. "[resourceId('Microsoft.DBforPostgreSQL/servers/', variables('databaseServerName'))]",
  238. "[resourceId('Microsoft.Insights/components', variables('analyticsName'))]",
  239. "[resourceId('Microsoft.Web/serverfarms', variables('appServicePlanName'))]"
  240. ],
  241. "properties": {
  242. "name": "[parameters('appName')]",
  243. "siteConfig": {
  244. "linuxFxVersion": "[concat('DOCKER|', parameters('dockerImageName'))]",
  245. "alwaysOn": true,
  246. "appSettings": [
  247. {
  248. "name": "WEBSITES_ENABLE_APP_SERVICE_STORAGE",
  249. "value": "false"
  250. },
  251. {
  252. "name": "AZURE_APPINSIGHTS_IKEY",
  253. "value": "[reference(resourceId('Microsoft.Insights/components', variables('analyticsName')), '2014-04-01').InstrumentationKey]"
  254. },
  255. {
  256. "name": "GOOGLE_TRACKING_ID",
  257. "value": ""
  258. },
  259. {
  260. "name": "DEBUG",
  261. "value": "False"
  262. },
  263. {
  264. "name": "SECRET_KEY",
  265. "value": "[parameters('secretKey')]"
  266. },
  267. {
  268. "name": "DATABASE_URL",
  269. "value": "[variables('databaseConnectionString')]"
  270. }
  271. ]
  272. },
  273. "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('appServicePlanName'))]"
  274. }
  275. }
  276. ],
  277. "outputs": {
  278. "appServer": {
  279. "type": "string",
  280. "value": "[concat(variables('appFqdn'))]"
  281. },
  282. "databaseServer": {
  283. "type": "string",
  284. "value": "[variables('databaseFqdn')]"
  285. }
  286. }
  287. }