Devteds Episode #6
Single-node deployment of a containerized API application on Amazon EC2 with database on RDS (Amazon Relational Database Service) using docker machine and docker compose.
- macOS - 10.12
- Docker - 1.13.0
- Docker compose - 1.10.0
- Docker machine - 0.9.0
git clone https://github.com/devteds/e6-deploy-on-aws.git deploy-on-aws
cd deploy-on-aws
# edit local.yml for local testing env
docker-compose -f local.yml up
# on a separate terminal window
docker-compose -f local.yml run --rm app rails db:migrate
docker-compose -f local.yml run --rm app rails db:seed
# Use REST client or curl to browse the APIs
curl http://localhost:3007/posts
Follow the instructions from the video. Below are the highlights,
- Spin up RDS on AWS
- Edit staging.yml for the database configs and endpoint
- Create a new user using AWS IAM
- Install AWS CLI, if not installed already
aws configure
docker-machine create -d amazonec2 --amazonec2-region=<REGION FROM AWS> node1
docker-machine ls
eval $(docker-machine env node1)
# enter the API key id and secret for the user created on IAM
docker-compose -f staging.yml run --rm app rails db:migrate
docker-compose -f staging.yml run --rm app rails db:seed
docker-compose -f staging.yml up -d
# Use REST client or curl to browse the APIs
curl http://$(docker-machine ip node1)/posts
docker-compose -f staging.yml ps
docker-compose -f staging.yml stop
docker-compose -f staging.yml start
docker-compose -f staging.yml logs