An example dockerized hapi “Hello World” application that will deploy to amazon ECS using CircleCi whenever the master branch is updated.


You’ll need to setup Amazon ECR for your docker image, in this sample it’s just test-app, a variable within .circleci/config.yml

You’ll then need to setup ECS.

  • A ECS cluster – test-app for this example, variable within .circleci/config.yml
  • A Task Definition – test-app for this example, variable within .circleci/config.yml. You can use the test-app-task.json file as a template to configure the task via json.
  • A Service within the cluster – app-service for this example, variable within .circleci/config.yml

See the EC2 Container Service
Resources Page
if you need more help on the above.

You’ll need AWS credentials for the step below that have access to ECR and ECS.


You’ll need to have your project setup with the following environment variables


Deployment via CircleCi

Anytime you push to master branch, CircleCI will go through it’s build and then deploy to AWS. The branch for deployment
is specified within the .circleci/config.yml file.

Example app should respond on port 80 of your ECS instance/load balancer with “Hello world”.

Deployment via custom bash script

If you don’t want to use CircleCi you can deploy with the script. There is a section of variables that you can customize for your needs. The only one you’ll need to modify for this example if you’ve stuck with test-app for everything is just modify the AWS_ACCOUNT_ID variable.

Credentials should be saved locally so they do not need to be in your repo, see more about this here
and here

Just pass it a tag that you want your dockerfile tagged with and it will handle the push to ECR and deployment to ECS.

./ production