Publishing in Docker Hub and Azure— Github -> Docker Hub -> Azure Deploy Pipeline Part 4

Hasan Şahin
HardwareAndro
Published in
3 min readFeb 18, 2021

With this part, we will have completed a full pipeline. Firstly, make the necessary settings through the docker hub. then we’ll connect and publish via azure.

After opening a new membership through the Docker hub, create a new repository.

SECRET KEYS

To connect to Docker Hub via GitHub, need to type in our user and password. To make this safe, enter the Github repository and go to the ‘Settings’ section then enter our repository private information in the Secrets tab.

Docker Secrets : DOCKER_USERNAME, DOCKER_PASSWORD
Azure Secrets : SSH_HOST, SSH_PASSWORD, SSH_PORT, SSH_USERNAME

I explained the use of Azure SSH information in the first part. As we use when accessing via PuTTy,
SSH_HOST: Azure Virtual Machine Public IP Address
SSH_PORT: 22
You typed Username and Password during virtual machine creation.

DOCKER HUB AND AZURE DEPLOY

Now that everything is ready, we can examine the codes. the code also includes the test stages I wrote in the previous part.

One of the parts that you should pay attention to when creating a workflow file is spaces. connected commands are connected after space. Let’s look at some of the commands saw for the first time.

needs : If the job it is connected to ends successfully, it will work.

${{ secrets.XX }} : That’s how to use the secret keys we’ve created.

push & tags : These commands are features of the ‘docker/build-push-action@v2’ package added With ‘uses’. In the Tags section, write the name of the repository that opened on the Docker Hub. You can use the Latest option if you have specified a version. by default, it is ‘latest’.

script : After providing a connection through SSH, this is the part where we add the commands that want to write through the console. We’ve to know Docker commands here.

54. Remove the running container.
55. We’re deleting the previous image.
56. We’re downloading the new image through the Docker Hub.
57. We deploy using the new image.

Let’s check our container on Azure. Open the command line and type sudo docker container ps

We can access our application through the public IP address of our virtual machine. as specified in the workflow file; this container is set to run through the 5000 port.

Result

We have successfully prepared Pipeline. Our project will be stopped, even for a short time. One of the topics I will tell in my next posts will be to distribute the workload between containers with ‘HTTP Load Balancing’, to perform update operations with Docker Swarm without disrupting the system.

Thank you for reading. I hope that was helpful.

Part 1 : https://medium.com/@hasansahinn/install-docker-on-azure-virtual-machine-github-docker-hub-azure-deploy-pipeline-part-1-4b1e73dd0d7

Part 2 : https://hasansahinn.medium.com/docker-file-and-net-core-project-github-docker-hub-azure-deploy-pipeline-part-2-4526bc02581d

Part 3 : https://hasansahinn.medium.com/github-actions-auto-test-github-docker-hub-azure-deploy-pipeline-part-3-105d9002acae

Part 4 : https://hasansahinn.medium.com/publishing-in-dockerhub-and-azure-github-docker-hub-azure-deploy-pipeline-part-4-d6efde5aca1e

--

--