Pune Developer's Community

Speaker- SANGAM BIRADAR and Hire Me!

DOCKER

Quick 5 Minutes Guide to CI/CD pipelining using Docker & Circle-CI

Tested Infrastructure

Platform Number of Instance Reading Time
Play with Docker 1 5 min

Pre-requisite

Create an account with [DockerHub]

Open [PWD] Platform on your browser

Click on **Add New Instance** on the left side of the screen to bring up Alpine OS instance on the right side

circle-ci and github account

Continous Integration Pipeline - (Without Docker)

Docker comes to Rescue

1.step



                                 git clone https://github.com/sangam14/dockerapp1.git
                                
				
					

Clone the Repository: Project.

2.step



                                 cd dockerapp1 
                              
					

Change directory to dockerapp1 as shown above

3.step



                              docker-compose up
                                
					

Bringing up app using Docker Compose

As shown above, we can save key and value by clicking "Save" button.

Integrating Cirecle-ci (Before Docker) Make sure you add circle-ci config file under .circleci/... as shown under the example https://github.com/sangam14/dockerapp1/tree/master/.circleci


					
version: 2
jobs:
  build:
    working_directory: /dockerapp1
    docker:
      - image: docker:17.05.0-ce-git
    steps:
      - checkout
      - setup_remote_docker
      - run:
          name: Install dependencies
          command: |
            apk add --no-cache py-pip=9.0.0-r1
            pip install docker-compose==1.15.0
      - run:
          name: Run tests
          command: |
            docker-compose up -d
            docker-compose run dockerapp1 python test.py
      - deploy:
          name: Push application Docker image
          command: |
            docker login -e $DOCKER_HUB_EMAIL -u $DOCKER_HUB_USER_ID -p $DOCKER_HUB_PWD
            docker tag dockerapp_dockerapp $DOCKER_HUB_USER_ID/dockerapp1:$CIRCLE_SHA1
            docker tag dockerapp_dockerapp $DOCKER_HUB_USER_ID/dockerapp1:latest
            docker push $DOCKER_HUB_USER_ID/dockerapp1:$CIRCLE_SHA1
            docker push $DOCKER_HUB_USER_ID/dockerapp1:latest 
	    
					

As shown above, make sure to add environment variable like $DOCKER_HUB_EMAIL, $DOCKER_HUB_USER_ID,$DOCKER_HUB_PWD Once you get circleci job running sucessfully, it should automatically be deployed on DockerHub repository.

Login to the circl-ci account https://circleci.com using github. Select project which you want to deploy.

Go to the setting of the project in circleci dashboard and add the environment veriable which declared in .circleci/config.yml file io. You can also provide Github SSH permission.