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.

240 lines
7.0 KiB

  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": "cwolff/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. "databaseConnectionString": "[concat('pgsql://', parameters('adminUserName'), '@', variables('databaseServerName'), ':', parameters('adminPassword'), '@', variables('databaseServerName'), '.postgres.database.azure.com:5432/', parameters('databaseName'))]",
  101. "databaseVersion": "9.6",
  102. "databaseServerName": "[concat(parameters('appName'),'-state')]",
  103. "setupScriptName": "[concat(parameters('appName'),'-setup')]",
  104. "appServicePlanName": "[concat(parameters('appName'),'-hosting')]",
  105. "env": [
  106. {
  107. "name": "WEBSITES_ENABLE_APP_SERVICE_STORAGE",
  108. "value": "false"
  109. },
  110. {
  111. "name": "DEBUG",
  112. "value": "False"
  113. },
  114. {
  115. "name": "SECRET_KEY",
  116. "value": "[parameters('secretKey')]"
  117. },
  118. {
  119. "name": "DATABASE_URL",
  120. "value": "[variables('databaseConnectionString')]"
  121. }
  122. ]
  123. },
  124. "resources": [
  125. {
  126. "apiVersion": "2017-08-01",
  127. "type": "Microsoft.Web/serverfarms",
  128. "kind": "linux",
  129. "name": "[variables('appServicePlanName')]",
  130. "location": "[variables('location')]",
  131. "properties": {
  132. "reserved": true
  133. },
  134. "dependsOn": [],
  135. "sku": {
  136. "name": "[parameters('appServiceSku')]"
  137. }
  138. },
  139. {
  140. "apiVersion": "2017-12-01",
  141. "type": "Microsoft.DBforPostgreSQL/servers",
  142. "location": "[variables('location')]",
  143. "name": "[variables('databaseServerName')]",
  144. "sku": {
  145. "name": "[variables('databaseSkuName')]",
  146. "tier": "[variables('databaseSkuTier')]",
  147. "family": "[variables('databaseSkuFamily')]",
  148. "capacity": "[parameters('databaseCores')]",
  149. "size": "[parameters('databaseSize')]"
  150. },
  151. "properties": {
  152. "version": "[variables('databaseVersion')]",
  153. "administratorLogin": "[parameters('adminUserName')]",
  154. "administratorLoginPassword": "[parameters('adminPassword')]",
  155. "storageMB": "[parameters('databaseSize')]"
  156. },
  157. "resources": [
  158. {
  159. "name": "allowAzure",
  160. "type": "firewallrules",
  161. "apiVersion": "2017-12-01",
  162. "location": "[variables('location')]",
  163. "properties": {
  164. "startIpAddress": "0.0.0.0",
  165. "endIpAddress": "0.0.0.0"
  166. },
  167. "dependsOn": [
  168. "[resourceId('Microsoft.DBforPostgreSQL/servers/', variables('databaseServerName'))]"
  169. ]
  170. },
  171. {
  172. "name": "[parameters('databaseName')]",
  173. "type": "databases",
  174. "apiVersion": "2017-12-01",
  175. "properties": {
  176. "charset": "utf8",
  177. "collation": "English_United States.1252"
  178. },
  179. "dependsOn": [
  180. "[resourceId('Microsoft.DBforPostgreSQL/servers/', variables('databaseServerName'))]"
  181. ]
  182. }
  183. ]
  184. },
  185. {
  186. "name": "[variables('setupScriptName')]",
  187. "type": "Microsoft.ContainerInstance/containerGroups",
  188. "apiVersion": "2018-10-01",
  189. "location": "[variables('location')]",
  190. "properties": {
  191. "containers": [
  192. {
  193. "name": "createadmin",
  194. "properties": {
  195. "image": "[parameters('dockerImageName')]",
  196. "command": [
  197. "tools/create-admin.sh",
  198. "[parameters('adminUserName')]",
  199. "[parameters('adminContactEmail')]",
  200. "[parameters('adminPassword')]"
  201. ],
  202. "environmentVariables": "[variables('env')]",
  203. "resources": {
  204. "requests": {
  205. "cpu": "1",
  206. "memoryInGb": "1.5"
  207. }
  208. }
  209. }
  210. }
  211. ],
  212. "osType": "Linux",
  213. "restartPolicy": "Never"
  214. },
  215. "dependsOn": [
  216. "[resourceId('Microsoft.DBforPostgreSQL/servers/', variables('databaseServerName'))]"
  217. ]
  218. },
  219. {
  220. "type": "Microsoft.Web/sites",
  221. "apiVersion": "2016-08-01",
  222. "name": "[parameters('appName')]",
  223. "kind": "app,linux,container",
  224. "location": "[variables('location')]",
  225. "dependsOn": [
  226. "[resourceId('Microsoft.DBforPostgreSQL/servers/', variables('databaseServerName'))]",
  227. "[resourceId('Microsoft.Web/serverfarms', variables('appServicePlanName'))]"
  228. ],
  229. "properties": {
  230. "name": "[parameters('appName')]",
  231. "siteConfig": {
  232. "linuxFxVersion": "[concat('DOCKER|', parameters('dockerImageName'))]",
  233. "alwaysOn": true,
  234. "appSettings": "[variables('env')]"
  235. },
  236. "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('appServicePlanName'))]"
  237. }
  238. }
  239. ]
  240. }