Skip to content

Instantly share code, notes, and snippets.

@ArionMiles
Last active June 5, 2020 13:45
Show Gist options
  • Save ArionMiles/a820bbc9892434492f3b667668387109 to your computer and use it in GitHub Desktop.
Save ArionMiles/a820bbc9892434492f3b667668387109 to your computer and use it in GitHub Desktop.
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"name": {
"defaultValue": null,
"type": "string",
"minLength": 5,
"maxLength": 63,
"metadata": {
"description": "Unique name for the deployment, used for Hasura and DNS label."
}
},
"postgresHost (ServerName)": {
"type": "string",
"defaultValue": null,
"metadata": {
"description": "Server name (hostname) for the Postgres server. Typically like pg-server-name.postgres.database.azure.com"
}
},
"postgresPort": {
"type": "int",
"defaultValue": 5432,
"metadata": {
"description": "Port for the Postgres server."
}
},
"postgresUsername (ServerAdminLoginName)": {
"type": "string",
"defaultValue": null,
"metadata": {
"description": "Username for Postgres. Typically like hasura@pg-server-name"
}
},
"postgresPassword": {
"type": "securestring",
"defaultValue": null,
"metadata": {
"description": "Password for Postgres user."
}
},
"postgresDatabaseName": {
"type": "string",
"defaultValue": null,
"metadata": {
"description": "Name of the database to connect."
}
},
"hasuraAdminSecret": {
"type": "securestring",
"defaultValue": null,
"metadata": {
"description": "Administrator password for Hasura console."
}
},
"hasuraAddress": {
"type": "string",
"defaultValue": null,
"metadata": {
"description": "Domain used by caddy for generating SSL certificates and over which Hasura console is served. Should be a URL."
}
}
},
"variables": {
"pgHost": "[parameters('postgresHost (ServerName)')]",
"pgPort": "[parameters('postgresPort')]",
"pgUser": "[parameters('postgresUsername (ServerAdminLoginName)')]",
"pgPassword": "[parameters('postgresPassword')]",
"dbName": "[parameters('postgresDatabaseName')]",
"containerGroupName": "[concat(parameters('name'), '-container-group')]",
"containerName": "hasura-graphql-engine",
"containerImage": "hasura/graphql-engine:latest",
"adminSecret": "[parameters('hasuraAdminSecret')]",
"hasuraPort": 8080,
"hasuraURL": "[parameters('hasuraAddress')]"
},
"resources": [
{
"type": "Microsoft.ContainerInstance/containerGroups",
"name": "[variables('containerGroupName')]",
"apiVersion": "2018-10-01",
"location": "[resourceGroup().location]",
"properties": {
"containers": [
{
"name": "[variables('containerName')]",
"properties": {
"image": "[variables('containerImage')]",
"ports": [
{
"protocol": "TCP",
"port": "[variables('hasuraPort')]"
}
],
"command": [
"graphql-engine",
"--host",
"[variables('pgHost')]",
"--port",
"[variables('pgPort')]",
"--user",
"[variables('pgUser')]",
"--password",
"[variables('pgPassword')]",
"--dbname",
"[variables('dbName')]",
"serve",
"--server-port",
"[variables('hasuraPort')]",
"--enable-console",
"--admin-secret",
"[variables('adminSecret')]"
],
"resources": {
"requests": {
"memoryInGB": 1,
"cpu": 1
}
}
}
},
{
"name": "caddy-ssl-server",
"properties": {
"image": "caddy:latest",
"command": [
"caddy",
"reverse-proxy",
"--from",
"[variables('hasuraURL')]",
"--to",
"[concat('localhost:', variables('hasuraPort'))]"
],
"ports": [
{
"protocol": "TCP",
"port": 443
},
{
"protocol": "TCP",
"port": 80
}
],
"environmentVariables": [],
"resources": {
"requests": {
"memoryInGB": 1,
"cpu": 1
}
},
"volumeMounts": [
{
"name": "data",
"mountPath": "/data"
},
{
"name": "config",
"mountPath": "/config"
}
]
}
}
],
"volumes": [
{
"name": "data",
"emptyDir": {}
},
{
"name": "config",
"emptyDir": {}
}
],
"restartPolicy": "Always",
"ipAddress": {
"ports": [
{
"protocol": "TCP",
"port": 443
},
{
"protocol": "TCP",
"port": 8080
},
{
"protocol": "TCP",
"port": 80
}
],
"type": "Public",
"dnsNameLabel": "[parameters('name')]"
},
"osType": "Linux"
}
}
],
"outputs": {
"fqdn": {
"value": "[reference(resourceId('Microsoft.ContainerInstance/containerGroups', variables('containerGroupName'))).ipAddress.fqdn]",
"type": "string"
},
"ipaddress": {
"value": "[reference(resourceId('Microsoft.ContainerInstance/containerGroups', variables('containerGroupName'))).ipAddress.ip]",
"type": "string"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment