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.

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