0%

Deploy Memos on AWS for fun

Memos Github Link is a lightweight, self-hosted memo hub. Open Source. Currently there are docs supporting manage hosting link on Render.com, Fly.io, PikaPods.com.

I tried to deploy Memos app on AWS with ECR, ECS Fargate and Application Load balancer(ALB). JUST FOR FUN. Because it is too EXPENSIVE. Memo is a long-lived app and almost certainly needs a load balancer. ALB by itself will cost $16.2/month.
My setup has no HTTPS, no CDK. It is against a lot of best practices :).

I will recommend using Fly.io

  • You can manage the whole thing at $0!
  • Automatic db backup to S3 bucket with easy setup
  • Easy to upgrade

I quickly moved to Fly.io after I finished this blog :)

Assume you already have a AWS account.

Local code change

Deploy to ECR

  • Search ECR in AWS console. Click Create repository, give it a name, for example, mymemos
  • You will see your docker on the dashboard. Click on your docker repository
  • Click View Push Commands, and follow the instruction there to deploy your app

Create ALB

  • Search load balancers in AWS console. Find EC2 and on left panel click Load Balancers
  • Click Create load balancer, choose Application Load Balancer
    • Give it a name, choose VPC and Security groups
    • Under Listeners and routing tab, click Create target group
      • Choose IP addresses as target type
      • Protocol HTTP and Port 5230
    • Select the target group just created
    • Click Create Load Balancer

Config Security group

  • I only have a default security group, select it. Under Inbound rules tab, click Edit Inbound rules
  • Add Type Custom TCP, Port Range 5230, Source 0.0.0.0/0
  • Add Type HTTP, Port Range 80, Source 0.0.0.0/0
  • Save it and go to outbound rules, Add Type Custom TCP, Port Range 5230, Source 0.0.0.0/0

Config ECS

  • Search ECS in AWS console, on left panel, click Task definitions
  • Click Create new task definition
  • Set Image Url to XXXXXX.dkr.ecr.us-east-1.amazonaws.com/mymemos, you can get it from ECR page
  • Set port tp 5230 with is the default in memos app
  • Click Create if you don’t want to do other fancy settings
  • Click Cluster on left panel, then Create cluster
    • Set Cluster name, add VPC and subnet
    • Click Create
  • Select the cluster you created
    • If you want to save money, consider Fargate Spot. 70% discount!!!
    • Under Services Tab, click Create
      • Under Deployment configuration, choose the family created in the previous step
    • Under Load Balancer, choose the ALB and target group created in the previous step
    • After service is created you should see a task running.
    • Go to your broswer with your ALB DNS name you should see the memo homepage let you to create an user
    • In the s3 bucket you should see a folder name with memos_prod.db/.

What’s Next