Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
DATABASE_URL=postgres://ddrpcdev:ddrpc123@host.docker.internal:5432/ddrpc
SMTP_USERNAME=test@asdlfknason.com
SMTP_PASSWORD=test!
SMTP_PASSWORD=test!!
ETHEREUM_ENDPOINT=http://host.docker.internal:8545
JWT_KEY=<JWT>
59 changes: 59 additions & 0 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Build and Deploy dd-rpc to ECS

on:
push:
branches:
- main
- dev
- ecs-cd

jobs:
build-and-deploy:
runs-on: ubuntu-latest
defaults:
run:
working-directory: infra/opentofu/ecs
env:
AWS_REGION: us-east-2
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push dd-rpc image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: true
tags: ghcr.io/developer-dao/rpc:${{ github.sha }}

- name: Set up Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: 1.8.5

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}

- name: Terraform Init
run: terraform init

- name: Terraform Plan
run: terraform plan -var="rpc_image=ghcr.io/developer-dao/rpc:${{ github.sha }}"

- name: Terraform Apply
run: terraform apply -auto-approve -var="rpc_image=ghcr.io/developer-dao/rpc:${{ github.sha }}"
43 changes: 0 additions & 43 deletions .github/workflows/docker-build.yml

This file was deleted.

13 changes: 6 additions & 7 deletions infra/opentofu/ecs/backend.tf
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
terraform {
# backend "s3" { # TODO: Migrate to S3 when AWS account and S3 bucket is set up
# bucket = "dd-rpc-terraform-state"
# key = "ecs/terraform.tfstate"
# region = var.region
# encrypt = true
# }
backend "local" {}
backend "s3" {
bucket = "dd-test-rpc-terraform-state"
key = "ecs/terraform.tfstate"
region = "us-east-2"
encrypt = true
}

required_version = ">= 1.0.0"
required_providers {
Expand Down
8 changes: 5 additions & 3 deletions infra/opentofu/ecs/main.tf
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# Reference VPC outputs from the vpc folder's state
# TODO: Migrate to S3 when AWS account and S3 bucket is set up
data "terraform_remote_state" "vpc" {
backend = "local"
backend = "s3"
config = {
path = "../vpc/terraform.tfstate"
bucket = "dd-test-rpc-terraform-state"
key = "vpc/terraform.tfstate"
region = "us-east-2"
}
}

Expand Down Expand Up @@ -85,7 +87,7 @@ module "ecs" {
cpu = 512
memory = 1024
essential = true
image = "ghcr.io/developer-dao/rpc:latest"
image = var.rpc_image
port_mappings = [
{
name = "dd-rpc"
Expand Down
6 changes: 6 additions & 0 deletions infra/opentofu/ecs/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,10 @@ variable "region" {
description = "The AWS region to deploy the VPC in."
default = "us-east-2"
type = string
}

variable "rpc_image" {
description = "The image tag or URI for the dd-rpc container."
type = string
default = "ghcr.io/developer-dao/rpc:latest"
}
13 changes: 6 additions & 7 deletions infra/opentofu/vpc/backend.tf
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
terraform {
# backend "s3" { # TODO: Migrate to S3 when AWS account and S3 bucket is set up
# bucket = "dd-rpc-terraform-state"
# key = "vpc/terraform.tfstate"
# region = var.region
# encrypt = true
# }
backend "local" {}
backend "s3" {
bucket = "dd-test-rpc-terraform-state"
key = "vpc/terraform.tfstate"
region = "us-east-2"
encrypt = true
}

required_version = ">= 1.0.0"
required_providers {
Expand Down