-
Notifications
You must be signed in to change notification settings - Fork 0
/
devenv-cloud-config.yaml
220 lines (188 loc) · 7.88 KB
/
devenv-cloud-config.yaml
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
#cloud-config
groups:
- docker
system_info:
default_user:
groups: [docker]
apt:
sources:
docker.list:
source: deb https://download.docker.com/linux/ubuntu $RELEASE stable
keyid: 9DC858229FC7DD38854AE2D88D81803C0EBFCD88
kubernetes.list:
source: deb https://apt.kubernetes.io/ kubernetes-xenial main
keyid: 7F92E05B31093BEF5A3C2D38FEEA9169307EA071
# prebuilt-mpr should have "just" but doesn't seem to include arm :(
# prebuilt.list:
# source: deb https://proget.makedeb.org prebuilt-mpr $RELEASE
# key: |
# -----BEGIN PGP PUBLIC KEY BLOCK-----
# Version: BCPG C# v1.8.1.0
# mQINBGJslcEBEACWT0Kphz3bmIO7s3BRW8Rw2m36YI0lDQmdkZy9F6Aa8+Ov9b6+
# 44hAvPYfm0fjOiGxq264v9Av5/26vcrDYsPKupaQs6EjT0NjcZ2A47KLpeJGzbzt
# 74KP+YyKm/oqW8Md8jb8GBRq0dnFoLOOA6bvHzP7TzANAKFIEZQ0m4GO/AI6Y9ap
# 09Q+g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H+gGO+G2vC3vMFVcPLN0JWbHEkD
# Tyiht2rMcIaEGXqzigc/S9czkOzsUuFdlWlBslBxJ6/yJYj5kvpSyGRJIe0dKZMp
# yYDQQmO0+OuA75BUveDK9v9msA25NX8Ynus7tNh1LdlSnaJv6JYEIEhWDVBEkPmQ
# TKGNsT2a5xrLry8pS3XJYThitIc8G7/ngzVOejsZ94G4OmYuCQxK97Hf/aHu
# =Vi1D
# -----END PGP PUBLIC KEY BLOCK-----
package_update: true
package_upgrade: true
packages:
- jq
- curl
- software-properties-common
- apt-transport-https
- ca-certificates
- gnupg-agent
- software-properties-common
- docker-ce
- docker-ce-cli
- containerd.io
- make
- gcc
- tzdata
- kubectl
write_files:
- path: /etc/profile
content: |
export PATH=$PATH:$HOME/go/bin:/usr/local/go/bin
append: true
- path: /etc/nsswitch.conf
content: |
hosts: files dns
- path: /usr/local/bin/pkgccaas
permissions: '0755'
content: |
#!/usr/bin/env sh
# TODO:
# - download pkgccaas script from git instead of embedding it in yaml?
# - same for pkgk8s, or combine the two?
usage() {
echo "Usage: pkgccaas -l <label> -a <address> [-m <META-INF directory>]"
}
error_exit() {
echo "${1:-"Unknown Error"}" 1>&2
exit 1
}
while getopts "hl:a:m:" opt; do
case "$opt" in
h)
usage
exit 0
;;
l)
label=${OPTARG}
;;
m)
metainf=${OPTARG}
;;
a)
address=${OPTARG}
;;
*)
usage
exit 1
;;
esac
done
shift $((OPTIND-1))
if [ -z "$label" ] || [ -z "$address" ]; then
usage
exit 1
fi
metadir=$(basename "$metainf")
if [ -n "$metainf" ]; then
if [ "META-INF" != "$metadir" ]; then
error_exit "Invalid chaincode META-INF directory $metadir: directory name must be 'META-INF'"
elif [ ! -d "$metainf" ]; then
error_exit "Cannot find directory $metadir"
fi
fi
prefix=$(basename "$0")
tempdir=$(mktemp -d -t "$prefix.XXXXXXXX") || error_exit "Error creating temporary directory"
if [ -n "$DEBUG" ]; then
echo "label = $label"
echo "address = $address"
echo "tempdir = $tempdir"
echo "metainf = $metainf"
fi
mkdir -p "$tempdir/src"
cat > "$tempdir/src/connection.json" << CONNECTION-EOF
{
"address": "${address}",
"dial_timeout": "10s",
"tls_required": false
}
CONNECTION-EOF
if [ -n "$metainf" ]; then
cp -a "$metainf" "$tempdir/src/"
fi
mkdir -p "$tempdir/pkg"
cat << METADATA-EOF > "$tempdir/pkg/metadata.json"
{
"type": "ccaas",
"label": "$label"
}
METADATA-EOF
tar -C "$tempdir/src" -czf "$tempdir/pkg/code.tar.gz" .
tar -C "$tempdir/pkg" -czf "$label.tgz" metadata.json code.tar.gz
rm -Rf "$tempdir"
- path: /usr/local/bin/setup-fabric
permissions: '0755'
content: |
#!/usr/bin/env sh
# Hacky script to setup Fabric without needing to rely on published
# binaries, since those don't exist for arm machines.
#
# TODO:
# - download setup script from git instead of embedding it in yaml?
# - add arguments for fabric version?
# - make it less hacky?!
mkdir -p "$HOME/go/src/github.com/hyperledger"
git clone --depth 1 --branch release-2.4 https://github.com/hyperledger/fabric.git "$HOME/go/src/github.com/hyperledger/fabric"
cd "$HOME/go/src/github.com/hyperledger/fabric"
CGO_ENABLED=0 make orderer
CGO_ENABLED=0 make tools
CGO_ENABLED=0 make ccaasbuilder
cd -
mkdir -p "$HOME/go/bin"
cp "$HOME/go/src/github.com/hyperledger/fabric/build/bin/"* "$HOME/go/bin"
git clone --depth 1 --branch main https://github.com/hyperledger/fabric-samples.git "$HOME/fabric-samples"
mkdir -p "$HOME/fabric-samples/config"
cp "$HOME/go/src/github.com/hyperledger/fabric/sampleconfig/"*.yaml "$HOME/fabric-samples/config"
mkdir -p "$HOME/fabric-builders"
ln -s "$HOME/go/src/github.com/hyperledger/fabric/release/linux-arm64/builders/ccaas" "$HOME/fabric-builders/ccaas"
mkdir -p "$HOME/fabric-builders/k8s/bin"
wget -qO- https://github.com/hyperledger-labs/fabric-builder-k8s/releases/download/v0.8.0/fabric-builder-k8s-v0.8.0-$(go env GOOS)-$(go env GOARCH).tgz | tar -C "$HOME/fabric-builders/k8s/bin" -xzf -
# TODO: just replace the external builders completely?
yq e 'del(.vm.endpoint) | (.chaincode.externalBuilders[] | select(.name == "ccaas_builder") | .path) = ("${HOME}/fabric-builders/ccaas" | envsubst(ne)) | .chaincode.externalBuilders += { "name": "k8s_builder", "path": "${HOME}/fabric-builders/k8s" | envsubst(ne), "propagateEnvironment": [ "CORE_PEER_ID", "KUBECONFIG_PATH" ] }' -i "$HOME/fabric-samples/config/core.yaml"
# TODO don't have permission to do this! Move to write-file or use a home bin directory?
# wget -qO- https://raw.githubusercontent.com/hyperledgendary/package-k8s-chaincode-action/main/pkgk8scc.sh > /usr/local/bin/pkgk8scc && chmod 0755 /usr/local/bin/pkgk8scc
runcmd:
- wget -P /tmp/ https://go.dev/dl/go1.18.7.linux-arm64.tar.gz
- tar -C /usr/local -xzf /tmp/go1.18.7.linux-arm64.tar.gz
- rm /tmp/go1.18.7.linux-arm64.tar.gz
- GOPATH=/usr/local/go HOME=/root /usr/local/go/bin/go install sigs.k8s.io/[email protected]
# Note: Cannot install later version of k9s this way due to https://github.com/derailed/k9s/issues/1484
- GOPATH=/usr/local/go HOME=/root /usr/local/go/bin/go install github.com/derailed/[email protected]
- GOPATH=/usr/local/go HOME=/root /usr/local/go/bin/go install github.com/mikefarah/yq/[email protected]
- curl --proto '=https' --tlsv1.2 -sSf https://just.systems/install.sh | bash -s -- --to /usr/local/bin
- su -c "wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash" ubuntu