Solano CI Integrates with Amazon EC2 Container Registry at Launch

Today, we are proud to announce our integration of Solano CI with Amazon EC2 Container Registry (ECR).  With Amazon ECR and Solano CI, you can now reliably build, test, and deploy your Docker workflow without operating your own container repositories or scaling your infrastructure.  Amazon ECR is a fully-managed, secure, and highly-available Docker container registry that makes it easy for developers to store, manage, and deploy Docker container images.  In addition to the simplified workflow, you can configure policies to manage permissions and control access to your images using AWS Identity and Access Management (IAM).  There is no easier way to gain fine-grain permission control over your Docker images today.

We decided to create an example repository to demonstrate integrating Amazon ECR and Amazon EC2 Container Service (ECS) with Solano CI. Each commit to the repository will trigger a build, and when all of the tests pass, the new Docker image will be pushed to Amazon ECR and Amazon ECS will start a new container. The step-by-step process we used:

Prepare your local system

  1. Since Amazon ECR is a new service, we had to install a new version of the AWS Command Line Interface to enable the aws ecr command.
  2. Set the environment variables for the aws command:

Setup Amazon ECR and ECS

For Amazon ECR enabled accounts, the Amazon ECS first run wizard allows creating the private Docker image repository in a few easy steps:

Set the repository name:

Aws ECR Step 1

Upon creation of the Amazon ECR registry, run the provided commands. The aws ecr get-login command will output a docker login command to run, but this can be done in one step by running it in a subshell: $(aws ecr get-login --region $AWS_DEFAULT_REGION)

AWS ECR Step 2

After setting up Amazon ECR, the wizard continues with the standard Amazon ECS setup steps.

Amazon ECS Step 3

On the task definition step, clicking the Advanced button allows us to set our own entry point and ensure the command field is empty.

Amazon ECR Step 3 Advanced

Configure the service:

Amazon ECS Step 4

Configure the cluster:

Amazon ECS Step 5

Review the settings and Launch!

Amazon ECS Step 6

Setup Solano CI

After AWS has launched the container, we set Solano CI to automatically build and test on each git push. When all of the tests pass, the new Docker image is pushed to Amazon ECR and Amazon ECS launches a new container from the image.

Inform Solano CI of the repository:

Now that the repository has been registered with Solano CI, we went into the repositories settings by clicking the gear icon for the repository on the Solano CI dashboard:

Repository on Solano CI Dashboard

On the CI Setup tab of Solano CI’s repository settings page we used the values to link the GitHub repository. The values under #2 are set in GitHub’s Tddium service hook. The value under #3 is Solano CI’s repository public key and is added as a GitHub deploy key.

Github configuration

To set the auth credentials necessary for connecting to AWS, the solano config:add command is the recommended way to set sensitive environment variables:

Success!

Now the example repository will trigger a build and deploy to both Amazon ECR and ECS upon passing builds. In particular there are a couple of files that we recommend taking a look at:

solano.yml: This file informs Solano CI to use a Docker enabled queue and specifies the setup hooks, tests, and other settings.

scripts/solano-pre_setup.sh: Installs aws-cli and jq (for JSON processing), logs into Amazon ECR, builds a Docker image, and installs dependencies.

scripts/solano-worker_setup.sh: Starts the docker container and prepares the test database.

scripts/solano-deploy.sh: Verifies the tests pass, pushes the new image to Amazon ECR, registers a new task definition with Amazon ECS, and updates the Amazon ECS service.

Give it a try and send us any questions or comments via Twitter @SolanoLabs, email support at support@solanolabs.com or use the comment section below.

With Amazon ECR and ECS alongside Solano CI: May green builds be with you!

Yoda Broken Build

Post a Comment