-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstance.yml
More file actions
65 lines (61 loc) · 2.17 KB
/
instance.yml
File metadata and controls
65 lines (61 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
imports:
- path: firewall.jinja
resources:
- type: compute.v1.instance
name: minecraft-vm
properties:
zone: us-central1-f
machineType: https://www.googleapis.com/compute/v1/projects/PROJECT_ID/zones/us-central1-f/machineTypes/g1-small
serviceAccounts:
- scopes:
- "https://www.googleapis.com/auth/logging.write"
disks:
- deviceName: boot
type: PERSISTENT
boot: true
autoDelete: true
initializeParams:
sourceImage: https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/family/debian-9
networkInterfaces:
- network: https://www.googleapis.com/compute/v1/projects/PROJECT_ID/global/networks/default
# Access Config required to give the instance a public IP address
accessConfigs:
- name: External NAT
type: ONE_TO_ONE_NAT
networkTier: STANDARD
metadata:
items:
- key: startup-script
value: |
#!/bin/bash
# install dbus for the shutdown util
sudo apt-get install dbus -y
# install docker repo and docker-ce
which docker
if [ $? -ne 0 ]; then
echo "install docker dependencies"
sudo apt-get update
sudo apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
gnupg2 \
software-properties-common
echo "install docker repository"
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/debian \
$(lsb_release -cs) \
stable"
echo "install docker-ce"
sudo apt-get update
sudo apt-get install docker-ce -y
fi
# start container
sudo docker start mc
if [ $? -ne 0 ]; then
sudo docker run -d -it -e EULA=TRUE -e ENABLE_RCON=true -e RCON_PASSWORD=PLACEHOLDER_PASSWORD -p 25565:25565 -p 25575:25575 --name mc --log-driver=gcplogs itzg/minecraft-server
fi
- name: firewall
type: firewall.jinja
properties: