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

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay