DEV Community

Wildan Aziz
Wildan Aziz

Posted on

Deploy Docker Application to Virtual Machine Using Github Actions (CI/CD)

Hi there! A quick question. Have you ever been unexpectedly productive during weekend? I remember spending all day doing a research on whether or not cereal was a soup ๐Ÿฅ.

Back to the topic, Microservice architecture has been quite popular for years. When building an application for Microservices, we probably want it to be deployed on a virtual machine let's say for scalling purposes.

In addition, a server automation can be very useful for us since it automates our application build, test, and deployment pipeline before deploying it to a virtual machine.

This post will help you carefully how to deploy your containerized application on a virtual machine using GitHub actions (CI/CD).


Prerequisites

  • Virtual machine - A running virtual machine instance. For this demo, I'm using a DigitalOcean droplet as I have it running already. But there shouldn't be a big difference with other virtual machine running on cloud platforms such as Amazon and Google Cloud Platform.
  • Docker - An open source software that consist of useful tools to containerize and manage our application. The docker software needs to be installed in the running virtual machine instance.
  • Git - A distributed version control system to manage our application code.
  • Web Application - An application server. A code example solely for demo can be viewed on github here.

What are the steps?

There are three files that are important for our deployment process.

workflow.yml tells us how our application deployed in a virtual machine.

workflow

Dockerfile is a set of instructions that run in a sequence in order to build an image of our application.

dockerfile

.dockerignore is a file that tells the docker what file(s) are not to include in the build process

dockerignore

Top comments (0)