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.

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