GitOps — Github Actions Docker Build Workflow

GitOps using Github Actions

Tony
3 min readApr 14, 2023

--

In my previous Github Actions Workflow articles, I introduced what is Github Actions Workflow, why do we need it and how to use it. In this article I will provide a practical example for how to use it to build a Docker CICD workflow.

Prerequisites

  • Docker Hub account
  • Git repository contains
.
├── app
│ ├── __init__.py
│ └── main.py
├── Dockerfile
├── .github
│ └── workflows
├── .gitignore
├── LICENSE
├── README.md
└── requirements.txt
  • Predefined Github Action Secrets:
secrets.DOCKER_HUB_USERNAME
secrets.DOCKER_HUB_TOKEN

Dockerfile

The Dockerfile looks like:

# Start from the official Python base image.
FROM python:3.9

# Set the current working directory to /code.
# This is where we'll put the requirements.txt file and the app directory.
WORKDIR /code

# Copy the file with the requirements to the /code directory.
# Copy only the file with the requirements first, not the rest of the code.
COPY ./requirements.txt /code/requirements.txt

# Install the package dependencies in the requirements file.
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt

# Copy the…

--

--

Tony
Tony

Responses (1)