-
Notifications
You must be signed in to change notification settings - Fork 1
/
local.tf
70 lines (70 loc) · 3.57 KB
/
local.tf
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
locals {
client_config_amd64_cmd = try(<<-EOT
set -eu
# vars
unset DOCKER_HOST
export DOCKER_TLS_VERIFY=1
export DOCKER_CERT_PATH='${pathexpand(var.docker_cert_path)}'
# cleanup first
docker context use default || echo "ignoring error..."
docker context rm multiarch-builder-amd64 || echo "ignoring error..."
%{if !var.create_arm64~}
docker context rm multiarch-builder-arm64 || echo "ignoring error..."
%{endif~}
docker buildx use default || echo "ignoring error..."
docker buildx create --leave --name multiarch-builder --node multiarch-builder-amd64 || echo "ignoring error..."
# config
echo "about to set up client config for amd64 instance..."
docker context create \
--docker host=tcp://${aws_spot_instance_request.multiarch_builder_amd64[0].public_dns}:2376,ca="${pathexpand(var.docker_cert_path)}/ca.pem",cert="${pathexpand(var.docker_cert_path)}/cert.pem",key="${pathexpand(var.docker_cert_path)}/key.pem" \
--description "Remote amd64 builder for multiarch-builder instance" \
multiarch-builder-amd64
## use context and wait for initial startup
echo "about to set up docker context 'multiarch-builder-amd64'..."
docker context use multiarch-builder-amd64
timeout 120 bash -c "until docker info &>/dev/null; do sleep 1; echo 'waiting for multiarch-builder-amd64 connection...'; done" || { echo "timeout waiting for remote"; exit 1; }
## set buildx builder amd64 instance
echo "about to set up buildx node 'multiarch-builder-amd64'..."
docker buildx create --use --bootstrap --append --name multiarch-builder \
--driver docker-container \
--driver-opt="network=host" \
--platform linux/amd64 \
--node=multiarch-builder-amd64 \
multiarch-builder-amd64
EOT
, "")
client_config_arm64_cmd = try(<<-EOT
set -eu
# vars
unset DOCKER_HOST
export DOCKER_TLS_VERIFY=1
export DOCKER_CERT_PATH='${pathexpand(var.docker_cert_path)}'
# cleanup first
docker context use default || echo "ignoring error..."
docker context rm multiarch-builder-arm64 || echo "ignoring error..."
%{if !var.create_amd64~}
docker context rm multiarch-builder-amd64 || echo "ignoring error..."
%{endif~}
docker buildx use default || echo "ignoring error..."
docker buildx create --leave --name multiarch-builder --node multiarch-builder-arm64 || echo "ignoring error..."
# config
echo "about to set up client config for arm64 instance..."
docker context create \
--docker host=tcp://${aws_spot_instance_request.multiarch_builder_arm64[0].public_dns}:2376,ca="${pathexpand(var.docker_cert_path)}/ca.pem",cert="${pathexpand(var.docker_cert_path)}/cert.pem",key="${pathexpand(var.docker_cert_path)}/key.pem" \
--description "Remote arm64 builder for multiarch-builder instance" \
multiarch-builder-arm64
## use context and wait for initial startup
echo "about to set up docker context 'multiarch-builder-arm64'..."
docker context use multiarch-builder-arm64
timeout 120 bash -c "until docker info &>/dev/null; do sleep 1; echo 'waiting for multiarch-builder-arm64 connection...'; done" || { echo "timeout waiting for remote"; exit 1; }
## set buildx builder arm64 instance
echo "about to set up buildx node 'multiarch-builder-arm64'..."
docker buildx create --use --bootstrap --append --name multiarch-builder \
--driver docker-container \
--driver-opt="network=host" \
--platform linux/arm64 \
--node=multiarch-builder-arm64 \
multiarch-builder-arm64
EOT
, "")
}