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.

312 lines
9.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": "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. "databaseConnectionString": "[concat('pgsql://', parameters('adminUserName'), '@', variables('databaseServerName'), ':', parameters('adminPassword'), '@', variables('databaseServerName'), '.postgres.database.azure.com:5432/', parameters('databaseName'))]",
  122. "databaseVersion": "9.6",
  123. "databaseServerName": "[concat(parameters('appName'),'-state')]",
  124. "setupScriptName": "[concat(parameters('appName'),'-setup')]",
  125. "appServicePlanName": "[concat(parameters('appName'),'-hosting')]",
  126. "analyticsName": "[concat(parameters('appName'),'-analytics')]",
  127. "dockerRegistryCredential": {
  128. "password": "[parameters('dockerRegistryPassword')]",
  129. "username": "[parameters('dockerRegistryUserName')]",
  130. "server": "[parameters('dockerRegistry')]"
  131. }
  132. },
  133. "resources": [
  134. {
  135. "type": "Microsoft.Insights/components",
  136. "apiVersion": "2015-05-01",
  137. "name": "[variables('analyticsName')]",
  138. "location": "[variables('location')]",
  139. "tags": {},
  140. "kind": "web",
  141. "properties": {
  142. "Application_Type": "web"
  143. }
  144. },
  145. {
  146. "apiVersion": "2017-08-01",
  147. "type": "Microsoft.Web/serverfarms",
  148. "kind": "linux",
  149. "name": "[variables('appServicePlanName')]",
  150. "location": "[variables('location')]",
  151. "properties": {
  152. "reserved": true
  153. },
  154. "dependsOn": [],
  155. "sku": {
  156. "name": "[parameters('appServiceSku')]"
  157. }
  158. },
  159. {
  160. "apiVersion": "2017-12-01",
  161. "type": "Microsoft.DBforPostgreSQL/servers",
  162. "location": "[variables('location')]",
  163. "name": "[variables('databaseServerName')]",
  164. "sku": {
  165. "name": "[variables('databaseSkuName')]",
  166. "tier": "[variables('databaseSkuTier')]",
  167. "family": "[variables('databaseSkuFamily')]",
  168. "capacity": "[parameters('databaseCores')]",
  169. "size": "[parameters('databaseSize')]"
  170. },
  171. "properties": {
  172. "version": "[variables('databaseVersion')]",
  173. "administratorLogin": "[parameters('adminUserName')]",
  174. "administratorLoginPassword": "[parameters('adminPassword')]",
  175. "storageMB": "[parameters('databaseSize')]"
  176. },
  177. "resources": [
  178. {
  179. "name": "allowAzure",
  180. "type": "firewallrules",
  181. "apiVersion": "2017-12-01",
  182. "location": "[variables('location')]",
  183. "properties": {
  184. "startIpAddress": "0.0.0.0",
  185. "endIpAddress": "0.0.0.0"
  186. },
  187. "dependsOn": [
  188. "[resourceId('Microsoft.DBforPostgreSQL/servers/', variables('databaseServerName'))]"
  189. ]
  190. },
  191. {
  192. "name": "[parameters('databaseName')]",
  193. "type": "databases",
  194. "apiVersion": "2017-12-01",
  195. "properties": {
  196. "charset": "utf8",
  197. "collation": "English_United States.1252"
  198. },
  199. "dependsOn": [
  200. "[resourceId('Microsoft.DBforPostgreSQL/servers/', variables('databaseServerName'))]"
  201. ]
  202. }
  203. ]
  204. },
  205. {
  206. "name": "[variables('setupScriptName')]",
  207. "type": "Microsoft.ContainerInstance/containerGroups",
  208. "apiVersion": "2018-10-01",
  209. "location": "[variables('location')]",
  210. "properties": {
  211. "imageRegistryCredentials": "[if(equals(parameters('dockerRegistry'), ''), json('null'), array(variables('dockerRegistryCredential')))]",
  212. "containers": [
  213. {
  214. "name": "createadmin",
  215. "properties": {
  216. "image": "[parameters('dockerImageName')]",
  217. "command": [
  218. "tools/create-admin.sh",
  219. "[parameters('adminUserName')]",
  220. "[parameters('adminContactEmail')]",
  221. "[parameters('adminPassword')]"
  222. ],
  223. "environmentVariables": [
  224. {
  225. "name": "DEBUG",
  226. "value": "False"
  227. },
  228. {
  229. "name": "SECRET_KEY",
  230. "value": "[parameters('secretKey')]"
  231. },
  232. {
  233. "name": "DATABASE_URL",
  234. "value": "[variables('databaseConnectionString')]"
  235. }
  236. ],
  237. "resources": {
  238. "requests": {
  239. "cpu": "1",
  240. "memoryInGb": "1.5"
  241. }
  242. }
  243. }
  244. }
  245. ],
  246. "osType": "Linux",
  247. "restartPolicy": "Never"
  248. },
  249. "dependsOn": [
  250. "[resourceId('Microsoft.DBforPostgreSQL/servers/', variables('databaseServerName'))]"
  251. ]
  252. },
  253. {
  254. "type": "Microsoft.Web/sites",
  255. "apiVersion": "2016-08-01",
  256. "name": "[parameters('appName')]",
  257. "kind": "app,linux,container",
  258. "location": "[variables('location')]",
  259. "dependsOn": [
  260. "[resourceId('Microsoft.DBforPostgreSQL/servers/', variables('databaseServerName'))]",
  261. "[resourceId('Microsoft.Insights/components', variables('analyticsName'))]",
  262. "[resourceId('Microsoft.Web/serverfarms', variables('appServicePlanName'))]"
  263. ],
  264. "properties": {
  265. "name": "[parameters('appName')]",
  266. "siteConfig": {
  267. "linuxFxVersion": "[concat('DOCKER|', parameters('dockerImageName'))]",
  268. "alwaysOn": true,
  269. "appSettings": [
  270. {
  271. "name": "WEBSITES_ENABLE_APP_SERVICE_STORAGE",
  272. "value": "false"
  273. },
  274. {
  275. "name": "DOCKER_REGISTRY_SERVER_URL",
  276. "value": "[parameters('dockerRegistry')]"
  277. },
  278. {
  279. "name": "DOCKER_REGISTRY_SERVER_USERNAME",
  280. "value": "[parameters('dockerRegistryUserName')]"
  281. },
  282. {
  283. "name": "DOCKER_REGISTRY_SERVER_PASSWORD",
  284. "value": "[parameters('dockerRegistryPassword')]"
  285. },
  286. {
  287. "name": "AZURE_APPINSIGHTS_IKEY",
  288. "value": "[reference(resourceId('Microsoft.Insights/components', variables('analyticsName')), '2014-04-01').InstrumentationKey]"
  289. },
  290. {
  291. "name": "GOOGLE_TRACKING_ID",
  292. "value": ""
  293. },
  294. {
  295. "name": "DEBUG",
  296. "value": "False"
  297. },
  298. {
  299. "name": "SECRET_KEY",
  300. "value": "[parameters('secretKey')]"
  301. },
  302. {
  303. "name": "DATABASE_URL",
  304. "value": "[variables('databaseConnectionString')]"
  305. }
  306. ]
  307. },
  308. "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('appServicePlanName'))]"
  309. }
  310. }
  311. ]
  312. }