Skip to content

Instantly share code, notes, and snippets.

@milancermak
Created December 23, 2022 21:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save milancermak/e98451f16ddf1dc412b78a3edcfbdcbb to your computer and use it in GitHub Desktop.
Save milancermak/e98451f16ddf1dc412b78a3edcfbdcbb to your computer and use it in GitHub Desktop.
Starknet devnet + Apibara <3 Terraform <3 DO
// https://slugs.do-api.dev/
resource "digitalocean_droplet" "sn_devnet" {
image = "docker-20-04"
name = "starknet-devnet"
region = "ams3"
size = "s-1vcpu-1gb"
ssh_keys = [
data.digitalocean_ssh_key.tf_ssh_key.id
]
connection {
host = self.ipv4_address
user = "root"
type = "ssh"
private_key = file(var.pvt_key)
timeout = "2m"
}
provisioner "file" {
source = "docker-compose.yml"
destination = "docker-compose.yml"
}
provisioner "remote-exec" {
inline = [
"export PATH=$PATH:/usr/bin",
"sudo apt update",
"sudo apt-get install -y docker-compose-plugin",
"sudo ufw allow 5050",
"sudo ufw allow 7171/tcp",
"sudo docker compose up --detach"
]
}
}
output "ip_address" {
value = digitalocean_droplet.sn_devnet.ipv4_address
}
version: '3'
services:
devnet:
image: shardlabs/starknet-devnet:latest
ports:
- 5050:5050
apibara:
image: apibara/starknet:4ec887d226eb654b2310edf81010e8e12dd08a7c
ports:
- 7171:7171
# apibara requires devnet to be available, which is not always the case
# when the containers first launch
# so restart it until it's working
depends_on:
- devnet
restart: always
command:
- "/usr/local/bin/apibara-starknet"
- "start"
- "--datadir=/data"
- "--poll-interval=1" # change this parameter to something lower for faster refreshing data
- "--custom-network=http://devnet:5050"
terraform {
required_providers {
digitalocean = {
source = "digitalocean/digitalocean"
version = "~> 2.0"
}
}
}
variable "do_token" {}
variable "pvt_key" {}
provider "digitalocean" {
token = var.do_token
}
data "digitalocean_ssh_key" "tf_ssh_key" {
name = "tf_ssh_key"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment