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.

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