Docker- Continuous Integration and Deployment
Some notes about the Continuous Integration and Deployment with AWS
.travis.yml
|
|
Dockerfile
|
|
AWS
Initial Setup
-
Go to AWS Management Console
-
Search for Elastic Beanstalk in “Find Services”
-
Click the “Create Application” button
-
Enter “
” for the Application Name -
Scroll down to “Platform” and select “Docker” from the dropdown list.
-
Change “Platform Branch” to Docker running on 64bit Amazon Linux
-
Click “Create Application”
-
You should see a green checkmark after some time.
-
Click the link above the checkmark for your application. This should open the application in your browser and display a Congratulations message.
Add AWS configuration details to .travis.yml file’s deploy script
- Set the region. The region code can be found by clicking the region in the toolbar next to your username.
eg: ‘us-east-1’
-
app should be set to the Application Name (Step #4 in the Initial Setup above)
-
env should be set to the lower case of your Beanstalk Environment name.
eg: ‘
- Set the bucket_name. This can be found by searching for the S3 Storage service. Click the link for the elasticbeanstalk bucket that matches your region code and copy the name.
eg: ‘elasticbeanstalk-us-east-1-xxxxxxxxxx’
-
Set the bucket_path to ‘
’(the “folder” by with this name will be created in the previous bucket_name once deployed) -
Set access_key_id to $AWS_ACCESS_KEY
-
Set secret_access_key to $AWS_SECRET_KEY
Create an IAM User
-
Search for the “IAM Security, Identity & Compliance Service”
-
Click “Create Individual IAM Users” and click “Manage Users”
-
Click “Add User”
-
Enter any name you’d like in the “User Name” field.
eg: docker-react-travis-ci
-
Tick the “Programmatic Access” checkbox
-
Click “Next:Permissions”
-
Click “Attach Existing Policies Directly”
-
Search for “beanstalk”
-
Tick the box next to “AWSElasticBeanstalkFullAccess”
-
Click “Next:Tags”
-
Click “Next:Review”
-
Click “Create user”
-
Copy and / or download the Access Key ID and Secret Access Key to use in the Travis Variable Setup.
Travis Variable Setup
-
Go to your Travis Dashboard and find the project repository for the application we are working on.
-
On the repository page, click “More Options” and then “Settings”
-
Create an AWS_ACCESS_KEY variable and paste your IAM access key from step #13 above.
-
Create an AWS_SECRET_KEY variable and paste your IAM secret key from step #13 above.
Deploying App
-
Make a change to the feature branch.
-
Merge into master branch.
-
Go to your Travis Dashboard and check the status of your build.
-
The status should eventually return with a green checkmark and show “build passing”
-
Go to your AWS Elasticbeanstalk application
-
It should say “Elastic Beanstalk is updating your environment”
-
It should eventually show a green checkmark under “Health”. You will now be able to access your application at the external URL provided under the environment name.