An open API service indexing awesome lists of open source software.

https://github.com/safinn/birdie-stack

Deploy Remix applications to AWS servers (not serverless) using containers on ECS.
https://github.com/safinn/birdie-stack

remix-stack

Last synced: 2 months ago
JSON representation

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

Awesome Lists containing this project

README

        

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](#features)
- [Getting Started](#getting-started)
- [Infrastructure](#infrastructure)
- [Remote State](#remote-state)
- [OpenID Connect Provider](#openid-connect-provider)
- [Application Environment](#application-environment)
- [Setup](#setup)
- [Migrations](#migrations)
- [Basti](#basti)
- [Drizzle](#drizzle)
- [GitHub Actions](#github-actions)
- [Development](#development)
- [Deployment](#deployment)


## 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

```sh
pnpm create remix@latest --template safinn/birdie-stack
```

- [Terraform](https://www.terraform.io) is required to manage and deploy the infrastructure-as-code with configured AWS credentials.
- [Basti](https://github.com/BohdanPetryshyn/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](./infra/prod/terraform.tfvars) file.
2. From the application root:

```sh
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.

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

## Setup

### Migrations

#### Basti

Access to the RDS instance in the private subnet is allowed via [Basti](https://github.com/BohdanPetryshyn/basti)

```sh
pnpm install --global basti
```

```sh
basti init
```

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

```sh
basti connect
```

#### Drizzle

Generate your migration files from the schema using the command:

```sh
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](#basti). Run the command:

```sh
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:

```sh
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.