Skip to content

Commit 9bdc0e0

Browse files
Merge pull request #10 from Developer-DAO/infra-code
Docker Compose updates, OpenTofu code for VPC and ECS
2 parents 21ba8d4 + 1e5ca6b commit 9bdc0e0

File tree

12 files changed

+490
-0
lines changed

12 files changed

+490
-0
lines changed

.gitignore

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
11
/target
22
.env
33
~/.config/nvim-data/undodir/
4+
5+
# Terraform state
6+
*.tfstate
7+
*.tfstate.*
8+
crash.log
9+
*.tfvars
10+
*.tfvars.json
11+
drift.log
12+
.terraform/
13+
.terraform.lock.hcl
14+
15+
# Local execution plan files
16+
plan.out
17+
18+
# Sensitive files
19+
*.pem
20+
*.key

docker-compose.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,26 @@ services:
1414
extra_hosts:
1515
- "host.docker.internal:host-gateway"
1616

17+
ethereum:
18+
image: ethereum/client-go:stable
19+
ports:
20+
- "8545:8545"
21+
- "30303:30303"
22+
command: --http --http.addr 0.0.0.0 --http.port 8545 --http.api eth,net,web3 --syncmode snap
23+
24+
dd_rpc:
25+
image: ghcr.io/developer-dao/rpc:latest
26+
ports:
27+
- "8080:80"
28+
environment:
29+
- DATABASE_URL=postgresql://ddrpcdev:ddrpc123@postgres:5432/ddrpc
30+
- ETHEREUM_ENDPOINT=http://ethereum:8545
31+
32+
- SMTP_PASSWORD=TEST
33+
- JWT_KEY=0cd8a9ca80c521ce59f4663bfc5379b7a4acc11c34d8852dfc9a71b6dba00985
34+
depends_on:
35+
- postgres
36+
- ethereum
37+
1738
volumes:
1839
postgres_data:

infra/bootstrap/userdata.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Runs on an Ubuntu 24.04 instance
2+
3+
# Add Docker's official GPG key:
4+
sudo apt-get update
5+
sudo apt-get install ca-certificates curl build-essential -y
6+
sudo install -m 0755 -d /etc/apt/keyrings
7+
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
8+
sudo chmod a+r /etc/apt/keyrings/docker.asc
9+
10+
# Add the repository to Apt sources:
11+
echo \
12+
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
13+
$(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | \
14+
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
15+
sudo apt-get update
16+
17+
# Install Docker components
18+
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
19+
20+
# Install Rust - this approach is interactive and will lock user data
21+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
22+
source $HOME/.cargo/env
23+
24+
# Get Github PAT to download image from private repo
25+
export CR_PAT=""
26+
echo $CR_PAT | docker login ghcr.io -u USERNAME --password-stdin
27+
28+
# Pull RPC image
29+
docker pull ghcr.io/developer-dao/rpc:latest
30+
31+
# Clone repo
32+
git clone [email protected]:Developer-DAO/rpc.git /opt/rpc
33+
cd /opt/rpc
34+
35+
# Set up project
36+
#cargo build
37+
#cargo install openssl sqlx-cli
38+
39+
docker compose up -d

infra/opentofu/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# OpenTofu
2+
This folder contains OpenTofu code that represents the AWS infrastructure as code (IaC).
3+
4+
## Download OpenTofu
5+
6+
## Basic Operations
7+
8+
## Apply Order
9+
In order to build these resources in a new AWS account, run applies in each folder following the order below:
10+
1. `vpc`
11+
2. `rds`
12+
3. `ecs`
13+
4. `github-runners`

infra/opentofu/ecs/backend.tf

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
terraform {
2+
# backend "s3" { # TODO: Migrate to S3 when AWS account and S3 bucket is set up
3+
# bucket = "dd-rpc-terraform-state"
4+
# key = "ecs/terraform.tfstate"
5+
# region = var.region
6+
# encrypt = true
7+
# }
8+
backend "local" {}
9+
10+
required_version = ">= 1.0.0"
11+
required_providers {
12+
aws = {
13+
source = "hashicorp/aws"
14+
version = "~> 5.0"
15+
}
16+
}
17+
}
18+
19+
provider "aws" {
20+
region = var.region
21+
}
22+

infra/opentofu/ecs/locals.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
locals {
2+
name = "rpc"
3+
tags = {
4+
TofuManaged = "true"
5+
TofuState = "ecs"
6+
Environment = "dev"
7+
}
8+
}

0 commit comments

Comments
 (0)