Recently, Attlasian has released a new feature, Pipelines. This allows you to build, run and deploy your projects in a simple and easy way.
In 3 simple steps:
- Push our code into Git (in this case, Bitbucket)
- Bitbucket will run the tests tag the images, and push into DockerHub if this success.
- From AWS we can pull the new image we built.
Previous to this configuration, you'll need:
- A bitbucket account (free) ->
- A dockerhub account (free) ->
AWS account (free 1st year) ->
Enable Pipelines inside the project's configuration of BitBucket.
- Configure project's pipeline to run the test and create the docker-hub image:
options: docker: true pipelines: default: - step: script: - mvn -B verify - export IMAGE_NAME=$DOCKER_HUB_USERNAME/MyRepo:MyProject:1.0 - docker build -t $IMAGE_NAME . - docker login --username $DOCKER_HUB_USERNAME --password $DOCKER_HUB_PASSWORD - docker push $IMAGE_NAME
- Configure DockerHub user and psw.
This can be done per project or globally. Settings -> Environment variables:
DOCKER_HUB_USERNAME : your user
DOCKER_HUB_PASSWORD : your psw
Once you push your code into your repository Pipeline will automatically run and push your code into docker-hub. Later on, you can pull the images from AWS using many alternatives or just using docker-compose