From c28693034fb475fad65fdda5f846ea1395d61f3a Mon Sep 17 00:00:00 2001 From: Viktar Makouski Date: Fri, 15 Nov 2024 15:48:34 +0300 Subject: [PATCH 1/4] first try --- packer/template.pkr.hcl | 51 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 packer/template.pkr.hcl diff --git a/packer/template.pkr.hcl b/packer/template.pkr.hcl new file mode 100644 index 00000000..973352fa --- /dev/null +++ b/packer/template.pkr.hcl @@ -0,0 +1,51 @@ +packer { + required_version = ">= 1.7.0" + required_plugins { + amazon = { + version = ">= 1.0.0" + source = "github.com/hashicorp/amazon" + } + } +} + +variable "aws_region" { + type = string + default = "us-west-2" +} + +source "amazon-ebs" "ubuntu" { + ami_name = "sbtc-signer-image-{{timestamp}}" + instance_type = "c6i.xlarge" + region = var.aws_region + source_ami_filter { + filters = { + name = "ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-*" + root-device-type = "ebs" + virtualization-type = "hvm" + } + owners = ["099720109477"] # Canonical + most_recent = true + } + ssh_username = "ubuntu" + ami_block_device_mappings { + device_name = "/dev/sda1" + volume_size = 100 + volume_type = "gp3" + delete_on_termination = true + } +} + +build { + sources = ["source.amazon-ebs.ubuntu"] + + provisioner "shell" { + inline = [ + "sudo apt-get update", + "sudo apt-get install -y docker.io docker-compose git", + "sudo usermod -aG docker ubuntu", + "git clone https://github.com/stacks-network/sbtc.git", + "cd sbtc", + "sudo docker-compose -f docker/docker-compose.yml --profile sbtc-signer up", + ] + } +} From 3452f0f7daa4e4efff9f60222c9ee8fd5383a803 Mon Sep 17 00:00:00 2001 From: Viktar Makouski Date: Fri, 15 Nov 2024 16:10:12 +0300 Subject: [PATCH 2/4] add some missing steps --- packer/template.pkr.hcl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packer/template.pkr.hcl b/packer/template.pkr.hcl index 973352fa..59c7b5da 100644 --- a/packer/template.pkr.hcl +++ b/packer/template.pkr.hcl @@ -45,6 +45,8 @@ build { "sudo usermod -aG docker ubuntu", "git clone https://github.com/stacks-network/sbtc.git", "cd sbtc", + "", + "curl -O https://archive.hiro.so/testnet/stacks-blockchain/testnet-stacks-blockchain-2.5.0.0.7-20240917.tar.gz", "sudo docker-compose -f docker/docker-compose.yml --profile sbtc-signer up", ] } From 421b89df40367968e35b336a7773fa69875284be Mon Sep 17 00:00:00 2001 From: Viktar Makouski Date: Fri, 15 Nov 2024 17:23:30 +0300 Subject: [PATCH 3/4] some missing steps --- packer/template.pkr.hcl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packer/template.pkr.hcl b/packer/template.pkr.hcl index 59c7b5da..dcbb1b60 100644 --- a/packer/template.pkr.hcl +++ b/packer/template.pkr.hcl @@ -45,7 +45,7 @@ build { "sudo usermod -aG docker ubuntu", "git clone https://github.com/stacks-network/sbtc.git", "cd sbtc", - "", + "sudo docker-compose -f docker/docker-compose.yml pull", "curl -O https://archive.hiro.so/testnet/stacks-blockchain/testnet-stacks-blockchain-2.5.0.0.7-20240917.tar.gz", "sudo docker-compose -f docker/docker-compose.yml --profile sbtc-signer up", ] From 92de63781c8a1490bed4abf8314e659cf14bb159 Mon Sep 17 00:00:00 2001 From: Viktar Makouski Date: Fri, 15 Nov 2024 17:24:16 +0300 Subject: [PATCH 4/4] run compose up in detached mode --- packer/template.pkr.hcl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packer/template.pkr.hcl b/packer/template.pkr.hcl index dcbb1b60..276ef40b 100644 --- a/packer/template.pkr.hcl +++ b/packer/template.pkr.hcl @@ -47,7 +47,7 @@ build { "cd sbtc", "sudo docker-compose -f docker/docker-compose.yml pull", "curl -O https://archive.hiro.so/testnet/stacks-blockchain/testnet-stacks-blockchain-2.5.0.0.7-20240917.tar.gz", - "sudo docker-compose -f docker/docker-compose.yml --profile sbtc-signer up", + "sudo docker-compose -f docker/docker-compose.yml --profile sbtc-signer up -d", ] } }