Skip to content

Commit 92f3ec1

Browse files
committed
Add mithril terraform deployment
1 parent 69cb367 commit 92f3ec1

File tree

6 files changed

+175
-1
lines changed

6 files changed

+175
-1
lines changed

mithril-infra/assets/docker/docker-compose-aggregator.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ services:
5050
- PROTOCOL_PARAMETERS__M=100
5151
- PROTOCOL_PARAMETERS__PHI_F=0.65
5252
- RUN_INTERVAL=60000
53-
- URL_SNAPSHOT_MANIFEST=https://storage.googleapis.com/cardano-${NETWORK}/snapshots.json
53+
- URL_SNAPSHOT_MANIFEST=https://storage.googleapis.com/${SNAPSHOT_BUCKET_NAME}/snapshots.json
5454
- SNAPSHOT_STORE_TYPE=local
5555
- SNAPSHOT_UPLOADER_TYPE=local
5656
- DATA_STORES_DIRECTORY=/mithril-aggregator/mithril/stores
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
2+
resource "null_resource" "mithril_aggregator" {
3+
depends_on = [
4+
null_resource.mithril_reverse_proxy
5+
]
6+
7+
triggers = {
8+
image_id = var.mithril_image_id
9+
}
10+
11+
connection {
12+
type = "ssh"
13+
user = "curry"
14+
private_key = local.google_service_account_private_key
15+
host = google_compute_address.mithril-external-address.address
16+
}
17+
18+
provisioner "remote-exec" {
19+
inline = [
20+
"mkdir -p /home/curry/data/${var.cardano_network}",
21+
"mkdir -p /home/curry/data/${var.cardano_network}/mithril-aggregator/cardano/db",
22+
"mkdir -p /home/curry/data/${var.cardano_network}/mithril-aggregator/cardano/ipc",
23+
"mkdir -p /home/curry/data/${var.cardano_network}/mithril-aggregator/mithril/stores",
24+
"mkdir -p /home/curry/data/${var.cardano_network}/mithril-aggregator/mithril/snapshots"
25+
]
26+
}
27+
28+
provisioner "remote-exec" {
29+
inline = [
30+
"export NETWORK=${var.cardano_network}",
31+
"export IMAGE_ID=${var.mithril_image_id}",
32+
"export AGGREGATOR_HOST=${local.mithril_aggregator_host}",
33+
"export GOOGLE_APPLICATION_CREDENTIALS_JSON='${var.google_application_credentials_json}'",
34+
"export GENESIS_VERIFICATION_KEY=$(wget -q -O - ${var.mithril_genesis_verification_key_url})",
35+
"export GENESIS_SECRET_KEY='${var.mithril_genesis_secret_key}'",
36+
"export CURRENT_UID=$(id -u)",
37+
"export DOCKER_GID=$(getent group docker | cut -d: -f3)",
38+
"docker-compose -f /home/curry/docker/docker-compose-aggregator.yaml --profile all up -d",
39+
]
40+
}
41+
}

mithril-infra/mithril.bootstrap.tf

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
resource "null_resource" "mithril_bootstrap" {
2+
3+
/*depends_on = [
4+
null_resource.vm_startup
5+
]*/
6+
7+
connection {
8+
type = "ssh"
9+
user = "curry"
10+
private_key = local.google_service_account_private_key
11+
host = google_compute_address.mithril-external-address.address
12+
}
13+
14+
triggers = {
15+
image_id = var.mithril_image_id
16+
}
17+
18+
provisioner "file" {
19+
source = "assets/docker"
20+
destination = "/home/curry"
21+
}
22+
23+
provisioner "file" {
24+
source = "assets/tools"
25+
destination = "/home/curry"
26+
}
27+
28+
provisioner "remote-exec" {
29+
inline = [
30+
<<-EOT
31+
# Wait for VM startup script to complete
32+
while ! test -f "/startup-ready.txt"; do
33+
sleep 2
34+
echo "Waiting for startup script to complete..."
35+
done
36+
echo "Startup script complete!"
37+
EOT
38+
,
39+
"chmod u+x /home/curry/tools/*.sh",
40+
"rm -rf /home/curry/docker/cardano-configurations && git clone https://github.com/input-output-hk/cardano-configurations.git /home/curry/docker/cardano-configurations"
41+
]
42+
}
43+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
resource "null_resource" "mithril_monitoring" {
3+
depends_on = [
4+
null_resource.mithril_reverse_proxy
5+
]
6+
7+
connection {
8+
type = "ssh"
9+
user = "curry"
10+
private_key = local.google_service_account_private_key
11+
host = google_compute_address.mithril-external-address.address
12+
}
13+
14+
provisioner "remote-exec" {
15+
inline = [
16+
"docker-compose -f /home/curry/docker/docker-compose-monitoring.yaml --profile all up -d",
17+
]
18+
}
19+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
resource "null_resource" "mithril_reverse_proxy" {
2+
depends_on = [
3+
null_resource.mithril_bootstrap
4+
]
5+
6+
triggers = {
7+
image_id = var.mithril_image_id
8+
}
9+
10+
connection {
11+
type = "ssh"
12+
user = "curry"
13+
private_key = local.google_service_account_private_key
14+
host = google_compute_address.mithril-external-address.address
15+
}
16+
17+
provisioner "remote-exec" {
18+
inline = [
19+
"chmod 600 /home/curry/docker/traefik/acme.json",
20+
]
21+
}
22+
23+
provisioner "remote-exec" {
24+
inline = [
25+
"docker network inspect mithril_network >/dev/null 2>&1 || docker network create mithril_network",
26+
"export CURRENT_UID=$(id -u)",
27+
"export DOCKER_GID=$(getent group docker | cut -d: -f3)",
28+
"docker-compose -f /home/curry/docker/docker-compose-reverse-proxy.yaml --profile all up -d",
29+
]
30+
}
31+
}

mithril-infra/mithril.signer.tf

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
resource "null_resource" "mithril_signer" {
2+
for_each = var.mithril_signers
3+
4+
depends_on = [
5+
null_resource.mithril_aggregator
6+
]
7+
8+
triggers = {
9+
image_id = var.mithril_image_id
10+
}
11+
12+
connection {
13+
type = "ssh"
14+
user = "curry"
15+
private_key = local.google_service_account_private_key
16+
host = google_compute_address.mithril-external-address.address
17+
}
18+
19+
provisioner "remote-exec" {
20+
inline = [
21+
"mkdir -p /home/curry/data/${var.cardano_network}",
22+
"mkdir -p /home/curry/data/${var.cardano_network}/mithril-signer-${each.key}/cardano/db",
23+
"mkdir -p /home/curry/data/${var.cardano_network}/mithril-signer-${each.key}/cardano/ipc",
24+
"mkdir -p /home/curry/data/${var.cardano_network}/mithril-signer-${each.key}/mithril/stores",
25+
"mkdir -p /home/curry/data/${var.cardano_network}/mithril-signer-${each.key}/mithril/snapshots"
26+
]
27+
}
28+
29+
provisioner "remote-exec" {
30+
inline = [
31+
"export SIGNER_ID=${each.key}",
32+
"export PARTY_ID=${each.value.pool_id}",
33+
"export NETWORK=${var.cardano_network}",
34+
"export IMAGE_ID=${var.mithril_image_id}",
35+
"export CURRENT_UID=$(id -u)",
36+
"export DOCKER_GID=$(getent group docker | cut -d: -f3)",
37+
"docker-compose -p $SIGNER_ID -f /home/curry/docker/docker-compose-signer-unverified.yaml --profile all up -d",
38+
]
39+
}
40+
}

0 commit comments

Comments
 (0)