-
Notifications
You must be signed in to change notification settings - Fork 6
/
packer.json
163 lines (163 loc) · 5.18 KB
/
packer.json
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
{
"variables": {
"chain_snapshot_url": "https://nkn.org/ChainDB_light_latest.tar.gz",
"output_name": "nkn-commercial-{{timestamp}}",
"do_api_token": "",
"gc_project_id": "",
"gc_zone": "",
"gc_account_file": "",
"gc_license": "",
"aws_access_key": "",
"aws_secret_access_key": "",
"aws_region": "",
"azure_client_id": "",
"azure_client_secret": "",
"azure_subscription_id": "",
"azure_tenant_id": "",
"azure_resource_group_name": "",
"azure_storage_account": "",
"docker_repository": ""
},
"builders": [
{
"type": "digitalocean",
"api_token": "{{user `do_api_token`}}",
"image": "ubuntu-18-04-x64",
"region": "sfo2",
"snapshot_name": "{{user `output_name`}}",
"size": "s-1vcpu-1gb",
"ssh_username": "root"
},
{
"type": "googlecompute",
"account_file": "{{user `gc_account_file`}}",
"project_id": "{{user `gc_project_id`}}",
"zone": "{{user `gc_zone`}}",
"image_name": "{{user `output_name`}}",
"source_image_family": "ubuntu-2204-lts",
"disk_size": 25,
"ssh_username": "packer",
"image_licenses": ["{{user `gc_license`}}"]
},
{
"type": "amazon-ebs",
"access_key": "{{user `aws_access_key`}}",
"secret_key": "{{user `aws_secret_access_key`}}",
"region": "{{user `aws_region`}}",
"ami_name": "{{user `output_name`}}",
"instance_type": "t2.small",
"source_ami_filter": {
"filters": {
"virtualization-type": "hvm",
"name": "ubuntu/images/*ubuntu-bionic-18.04-amd64-server-*",
"root-device-type": "ebs"
},
"owners": ["099720109477"],
"most_recent": true
},
"launch_block_device_mappings": [
{
"device_name": "/dev/sda1",
"volume_size": 25,
"volume_type": "gp2",
"delete_on_termination": true
}
],
"ssh_username": "ubuntu"
},
{
"type": "azure-arm",
"client_id": "{{user `azure_client_id`}}",
"client_secret": "{{user `azure_client_secret`}}",
"subscription_id": "{{user `azure_subscription_id`}}",
"tenant_id": "{{user `azure_tenant_id`}}",
"resource_group_name": "{{user `azure_resource_group_name`}}",
"storage_account": "{{user `azure_storage_account`}}",
"capture_container_name": "images",
"capture_name_prefix": "packer",
"os_type": "Linux",
"image_publisher": "Canonical",
"image_offer": "UbuntuServer",
"image_sku": "18.04-LTS",
"location": "West US",
"vm_size": "Standard_B1s"
},
{
"type": "docker",
"image": "ubuntu:18.04",
"commit": true,
"changes": [
"WORKDIR /home/nkn/nkn-commercial",
"ENTRYPOINT /home/nkn/nkn-commercial/nkn-commercial"
]
}
],
"provisioners": [
{
"type": "shell",
"inline": [
"sleep 60",
"echo 'debconf debconf/frontend select Noninteractive' | sudo debconf-set-selections",
"sudo apt-get install -y -q apt-utils software-properties-common",
"sudo add-apt-repository -y ppa:longsleep/golang-backports",
"sudo apt-get update -y -q",
"sudo apt-get upgrade -y -q",
"sudo apt-get install -y -q golang-1.15 git supervisor psmisc zip unzip lsof jq make wget xxd",
"sudo mkdir -p /home/nkn/nkn-commercial/",
"sudo groupadd nkn",
"sudo useradd -g nkn -b /home -s /usr/sbin/nologin nkn",
"sudo chown -R nkn:nkn /home/nkn/",
"cd /home/nkn/nkn-commercial/ && sudo -u nkn curl -L -s -o linux-amd64.zip https://commercial.nkn.org/downloads/nkn-commercial/linux-amd64.zip && sudo -u nkn unzip linux-amd64.zip && sudo -u nkn mv linux-amd64/* . && sudo rm -rf linux-amd64.zip linux-amd64",
"cd /home/nkn/nkn-commercial/ && sudo ./nkn-commercial -d /home/nkn/nkn-commercial/ -u nkn install && sudo systemctl stop nkn-commercial"
]
},
{
"type": "shell",
"environment_vars": ["CHAIN="],
"inline": [
"sudo -u nkn mkdir -p /home/nkn/nkn-commercial/services/nkn-node/ && cd /home/nkn/nkn-commercial/services/nkn-node/ && sudo -u nkn curl -L -s {{user `chain_snapshot_url`}} | sudo -u nkn tar -zxf -"
],
"except": ["docker"]
},
{
"type": "shell",
"inline": [
"sudo rm -f /home/*/.ssh/authorized_keys",
"sudo rm -f /root/.ssh/authorized_keys"
]
},
{
"type": "shell",
"execute_command": "chmod +x {{ .Path }}; {{ .Vars }} sudo -E sh '{{ .Path }}'",
"inline": [
"/usr/sbin/waagent -force -deprovision+user && export HISTSIZE=0 && sync"
],
"inline_shebang": "/bin/sh -x",
"only": ["azure-arm"]
}
],
"post-processors": [
[
{
"type": "docker-tag",
"repository": "{{user `docker_repository`}}",
"tag": "{{timestamp}}",
"only": ["docker"]
},
{
"type": "docker-push",
"only": ["docker"]
},
{
"type": "docker-tag",
"repository": "{{user `docker_repository`}}",
"tag": "latest",
"only": ["docker"]
},
{
"type": "docker-push",
"only": ["docker"]
}
]
]
}