An idea behind this blog to walk through the auto build of docker image in docker hub for Spring boot application.
Note: – This method is not production level, so use it for staging or development phase only.
(Why it is not suitable for production ?)
[As we have to push the jar to the git repository, to reduce few steps.]
Technology Stack Used
- Spring Boot [1.4.1 Release]
- Java 8
- Maven 2
- Bit Bucket
- Docker Hub
- Docker Hub Account
- Bit Bucket Account
- Minimum knowledge of Spring boot and Java
- Link Bit Bucket to Docker Hub. CLICK HERE for the reference.
- Create Spring boot Application Capable of creating docker image
- Create simple spring boot application with web module.[CLICK HERE to create using spring start.io or get it from BIT-BUCKET repo (master branch)].
- Add Simple test controller to the Spring Project or check out to the branch controller-test.
- Add Docker support to your current spring boot application or check out to branch docker-support. [To learn how to add docker support to spring boot application you check this blog.]
- Create New Repository and link for auto creation of image
- Go to docker hub and click on create -> create automatic build
- Click on create Auto-build bit-bucket
- Select the desired bitbucket repository
- Fill required information and click on create.
- Go to build setting and provide the branch name from which image should be created and save changes.
- Click on build details, it will be empty right now
- Make Some changes in that particular branch and push it to the Origin.
- Now again check the build details tab, there will be new entry populated with status queued.
- Wait for some time its status will change to building than to success.
- Now your docker image is ready to use.
- Test created docker image
- Now pull the docker image
- Run the docker image with command [docker run –name docker.test -d -p 8088:8080 jainamit333/docker.demo:docker-support]
- Navigate to http://localhost:8088/docker/test.It will show the desired result.
Now each time user push to anything to branch, new docker image will be created.