Deploying a Dockerized Spring Boot application to AWS Elastic Beanstalk.
-
Configure the AWS Elastic Beanstalk CLI:
eb init --platform docker-17.09.1-ce --region eu-west-2 aws-eb-demo
-
Create the environment in AWS, selecting the defaults when prompted:
eb create
WARNING: You will be charged for these resources until they are destroyed.
-
Visit the outputted environment CNAME, e.g. http://aws-eb-demo-dev.eu-west-2.elasticbeanstalk.com/
To manually deploy the project to AWS:
mvn clean package
docker build -t markhobson/aws-eb-demo .
docker login
docker push markhobson/aws-eb-demo
eb deploy
We'll use CircleCI for continuous deployment.
-
Add the project
-
Add environment variables for your Docker Hub credentials:
DOCKER_REGISTRY_USERNAME
DOCKER_REGISTRY_PASSWORD
-
Add environment variables for your AWS credentials and region:
AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
AWS_DEFAULT_REGION
The job builds the project within the Docker container .circleci/images/primary/Dockerfile. If you need to rebuild this:
docker build -t markhobson/aws-eb-demo-primary .circleci/images/primary
docker login
docker push markhobson/aws-eb-demo-primary
To terminate the environment in AWS:
eb terminate --force aws-eb-demo-dev
You will no longer be charged for these resources.