Developer Guide

Instrumenting Amazon ECS Applications

In the xray-ecs branch, the Scorekeep sample application shows how to instrument an application running in Amazon Elastic Container Service (Amazon ECS). The branch provides scripts and configuration files for creating, uploading, and running Docker images in a Multicontainer Docker environment in AWS Elastic Beanstalk.

The project includes three Dockerfiles that define container images for the API, front end, and X-Ray daemon components.

  • /Dockerfile – The Scorekeep API.

  • /scorekeep-frontend/Dockerfile – The Angular web app client, and the nginx proxy that routes incoming traffic.

  • /xray-daemon/Dockerfile – The X-Ray daemon.

The X-Ray daemon Dockerfile creates an image based on Amazon Linux that runs the X-Ray daemon. Download the complete example image on Docker Hub.

Example Dockerfile – Amazon Linux

FROM amazonlinux RUN yum install -y unzip RUN curl -o RUN unzip && cp xray /usr/bin/xray ENTRYPOINT ["/usr/bin/xray", "-t", "", "-b", ""] EXPOSE 2000/udp EXPOSE 2000/tcp

The makefile in the same directory defines commands for building the image, uploading it to Amazon ECR, and running it locally.

To run the containers on Amazon ECS, the branch includes a script to generate a file, which you can deploy to a multicontainer Docker environment in Elastic Beanstalk. The template that the script uses shows how to write a task definition that configures networking between the containers in Amazon ECS.

Note is the Elastic Beanstalk version of an Amazon ECS task definition file. If you don't want to use Elastic Beanstalk to create your Amazon ECS cluster, you can modify the file to run on Amazon ECS directly by removing the AWSEBDockerrunVersion key from the file.

See the branch README for instructions on how to deploy Scorekeep to Amazon ECS.