Skip to content

Latest commit

 

History

History
117 lines (84 loc) · 5.9 KB

README.md

File metadata and controls

117 lines (84 loc) · 5.9 KB

Fire Starter

Fire Starter is a Github template repository that you can use it to take a website running locally on your machine and deploy it to the cloud using Docker, GitHub Actions, and AWS App Runner.

Please feel free to open an issue if you have any questions or issues.

Table of Contents

  1. Presentation Slides
  2. Architecture
  3. Getting Started
  4. Sources and Tutorials

Presentation Slides

I built Fire Starter for a talk I gave at the 2022 Grace Hopper Celebration (GHC22). Here are the slides from my talk:

GHC22 Slides

Architecture

architecture-diagram

  • A developer can trigger different GitHub Actions workflows by pushing a commit or merging to a certain branch.
    • These workflows are in ./github/workflows/.
  • The GitHub Actions workflows do the following tasks automatically when triggered:
    • Use AWS CloudFormation to create cloud infrastructure resources for the website in AWS
    • Build and upload Docker container images of the website into AWS Elastic Container Registry (ECR)
    • Set up AWS App Runner to pull the most recent Docker image for the website from ECR
    • Create App Runner instances running the website ready to receive live traffic

Getting Started

To get started, copy this template repository to create a new repository by clicking "Use this template" on the GitHub home page of this repository.

1. Create Website

To create and run your website, you will need npm and node 16 installed. Then in the directory where your code is downloaded, run:

cd example-react-app/
npm run start

Go to localhost:3000 and your website will be running.

2. Containerize

To use Docker, you will need Docker installed. To run your website out of a Docker container, run:

docker build -t fire-starter .
docker run -p 3000:3000 fire-starter

Go to localhost:3000 and your website will be running.

3. Automate

Several of the GitHub Actions workflows will run automatically if you make a new commit to your repo. These include "Run Tests" (./github/workflows/test.yaml) and "Build Image" (./github/workflows/build.yaml). Go to the Actions tab in the GitHub UI to explore actions.

To run the other workflows, follow the steps in the Deploy section below.

4. Deploy

To deploy your website, you will need to create an AWS account.

Note: Some of the AWS infrastructure for this website will cost money to run, so please be aware.

After creating your AWS account, you will need to set up your AWS credentials to authorize GitHub Actions.

Set Up

  1. Go to the AWS console and create a stack in CloudFormation using this template: ./cloudformation/github_iam_role.yaml. This will create an IAM role for you to use.
  2. Copy the ARN of the github-user-role IAM role you created.
  3. Create a secret in GitHub Actions and call it AWS_GITHUB_ROLE_ARN and enter the value of the arn from step 2.
  4. Run the "Deploy CloudFormation" action (/.github/workflows/deploy_cloudformation.yaml). This will set up AWS infrastructure for ECR and App Runner and create another IAM role.
  5. Copy the arn of the app-runner-service-role IAM role you created.
  6. Create a secret in GitHub Actions and call it AWS_APP_RUNNER_ROLE_ARN and enter the value of the arn from step 5.

Now you are ready to deploy your site.

  1. Run the "Build and Deploy" action (/.github/workflows/build_and_deploy.yaml). This will deploy your website using App Runner.
  2. Go to the AWS console and go to the App Runner service. You will see a service called fire-starter-service. It should have a default domain attached to it.
  3. Click on the default domain and you should see your website running!

Sources and Tutorials

Sources

Tutorials