Skip to main content

4 posts tagged with "AWS"

Amazon Web Services (AWS) is a cloud computing platform that provides a wide range of services for building and deploying applications.

View All Tags

IaaC Simplified: Automating EC2 Deployments with GitHub Actions, Terraform, Docker & Distribution Registry

· 20 min read
Ivan Borshchov
Maintainer of AdminForth

alt text

This guide shows how to deploy own Docker apps (with AdminForth as example) to Amazon EC2 instance with Docker and Terraform involving Docker self-hosted registry.

Needed resources:

  • GitHub actions Free plan which includes 2000 minutes per month (1000 of 2-minute builds per month - more then enough for many projects, if you are not running tests etc). Extra builds would cost 0.008$ per minute.
  • AWS account where we will auto-spawn EC2 instance. We will use t3a.small instance (2 vCPUs, 2GB RAM) which costs ~14$ per month in us-east-1 region (cheapest region). Also it will take $2 per month for EBS gp2 storage (20GB) for EC2 instance

This is it, registry will be auto-spawned on EC2 instance, so no extra costs for it. Also GitHub storage is not used, so no extra costs for it.

The setup has next features:

  • Build process is done using IaaC approach with HashiCorp Terraform, so almoast no manual actions are needed from you. Every resource including EC2 server instance is described in code which is commited to repo so no manual clicks are needed.
  • Docker build process is done on GitHub actions, so EC2 server is not overloaded
  • Changes in infrastructure including changing server type, adding S3 Bucket, changing size of sever disk is also can be done by commiting code to repo.
  • Docker images and cache are stored on EC2 server, so no extra costs for Docker registry are needed.
  • Total build time for average commit to AdminForth app (with Vite rebuilds) is around 2 minutes.