Skip to content

Instantly share code, notes, and snippets.

@noelbundick
Last active June 3, 2018 17:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save noelbundick/9fa6e53a300e98e3af36d2a6ceea7f62 to your computer and use it in GitHub Desktop.
Save noelbundick/9fa6e53a300e98e3af36d2a6ceea7f62 to your computer and use it in GitHub Desktop.
aci-minecraft
# Zero to Minecraft in the space of a tweet! (https://twitter.com/acanthamoeba/status/890253868835102720)
# Well... almost! It doesn't seem to run well with just 1 CPU anymore
az group create -n m -l westus && az container create -g m --image itzg/minecraft-server -n m --ip-address public --port 25565 -e EULA=true --cpu 2
# One-time setup
# =====================================
# Generate a new storage account name that's hopefully not taken!
AZURE_STORAGE_ACCOUNT=minecraft$RANDOM
# Create a resource group to hold your resources
az group create -n minecraft-rg -l westus
# Create a storage account to persist the world data
# Note: This isn't done in the ARM template because Azure file shares can't currently be created via ARM (https://feedback.azure.com/forums/281804-azure-resource-manager/suggestions/9306108-let-me-define-preconfigured-blob-containers-table)
az storage account create -n $AZURE_STORAGE_ACCOUNT -g minecraft-rg --sku Standard_LRS
# Create a file share to mount into the container
# Since creating a share is a data-plane operation, we need the connection string to call into the Azure Storage API's
export AZURE_STORAGE_CONNECTION_STRING=`az storage account show-connection-string -n $AZURE_STORAGE_ACCOUNT -g minecraft-rg -o tsv`
az storage share create -n minecraft-data
# Run this to play!
# =====================================
# Launch Minecraft server inside a container
az group deployment create -g minecraft-rg --template-uri https://aka.ms/aci-mcserver-template
# Cleanup
# =====================================
# Delete the entire resource group to clean up
az group delete -n minecraft-rg
# Create a resource group to hold your resources
az group create -n minecraft-rg -l westus
# Run a Minecraft server inside a container
az container create -g minecraft-rg --image=itzg/minecraft-server -n minecraft-server --ip-address public --port 25565 -e EULA=TRUE --cpu 2
# Delete the entire resource group to clean up
az group delete -n minecraft-rg
MIT License
Copyright (c) 2018 Noel Bundick
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"storageAccountName": {
"type": "string"
}
},
"variables": {
"containerName": "minecraft-server"
},
"resources": [
{
"name": "[variables('containerName')]",
"type": "Microsoft.ContainerInstance/containerGroups",
"apiVersion": "2017-08-01-preview",
"location": "[resourceGroup().location]",
"properties": {
"containers": [{
"name": "[variables('containerName')]",
"properties": {
"image": "itzg/minecraft-server",
"resources": {
"requests": {
"cpu": 2,
"memoryInGb": 1.5
}
},
"environmentVariables": [
{
"name": "EULA",
"value": "TRUE"
}
],
"ports": [
{
"port": 25565
}
],
"volumeMounts": [{
"name": "data",
"mountPath": "/data"
}]
}
}],
"osType": "Linux",
"ipAddress": {
"type": "Public",
"ports": [
{
"protocol": "TCP",
"port": 25565
}
]
},
"volumes": [{
"name": "data",
"azureFile": {
"shareName": "minecraft-data",
"storageAccountName": "[parameters('storageAccountName')]",
"storageAccountKey": "[listKeys(resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName')),'2016-01-01').keys[0].value]"
}
}]
}
}
],
"outputs": {
"serverAddress": {
"type": "string",
"value": "[reference(concat('Microsoft.ContainerInstance/containerGroups/', variables('containerName')), '2017-08-01-preview').ipAddress.ip]"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment