/birdie-stack

Deploy Remix applications to AWS servers (not serverless) using containers on ECS.

Primary LanguageTypeScriptMIT LicenseMIT

Birdie Stack

PRs Welcome GitHub

The Birdie Stack is focused on hosting a Remix application on AWS (Amazon Web Services) with minimal cost.

Logo

Table of contents


Features

  • Deploy using containers to AWS ECS with the choice of:
    • Simple mode for cheap single instance deployments ideal for hobby projects (default).
    • Production deployment that can scale instances across the region (simple=false) in private subnets for stronger security.
  • PostgreSQL RDS instance in a private subnet.

Getting Started

pnpm create remix@latest --template safinn/birdie-stack
  • Terraform is required to manage and deploy the infrastructure-as-code with configured AWS credentials.
  • Basti is used to setup the bastion server giving access to the private RDS instance.

Having all these tools installed and ready to go will get you started fast.

Infrastructure

Remote State

This module creates the S3 bucket and DynamoDB table to remotely manage the terraform state for the application.

  1. Update the reponame and domain variables in the ./infra/prod/terraform.tfvars file.
  2. From the application root:
cd ./infra/remote-state && \
terraform init && \
terraform apply --var-file ../prod/terraform.tfvars

OpenID Connect Provider

This module also sets up the GitHub OpenID connect provider so GitHub action workflows can assume a AWS IAM role and obtain short-lived credentials to manage resources on AWS.

Application Environment

This module sets up all the infrastructure required for the application.

cd ../prod && \
terraform init && \
terraform apply

Setup

Migrations

Basti

Access to the RDS instance in the private subnet is allowed via Basti

pnpm install --global basti
basti init

After a few minutes the infrastructure should be ready to connect to with:

basti connect

Drizzle

Generate your migration files from the schema using the command:

pnpm generate

Apply migrations making sure to use the correct connection string. The password can be taken from AWS Secrets Manager once access is gained to the private RDS instance using Basti. Run the command:

pnpm migrate 'postgres://birdie-stack:password@localhost:port/birdie-stack'

GitHub Actions

Update the deploy workflows in the .github/workflows/ directory by changing the role arn provided to role-to-assume in all the Configure AWS Credentials steps to the arn of the role named github-actions-role in AWS IAM.

Development

From your terminal:

pnpm dev

This starts your app in development mode, rebuilding assets on file changes.

Deployment

A GitHub action is included that will build the application on push using AWS CodeBuild for ARM and generate and push a docker image to ECR which will then be deployed to the ECS cluster.