Automated and Manual Container Update from Sixfab Registry

This comprehensive guide details the process of automating container updates using GitHub Actions and manually updating containers using Docker Buildx from a Sixfab private registry. These methods ensure your container images are consistently updated with the latest code and dependencies.


Before diving into the steps, here’s a quick overview of the tools we’ll be using:

  • GitHub Actions is a tool that helps automate your software development workflows, such as building, testing, and deploying code. Learn more on the official GitHub Actions documentation.
  • Docker Buildx is a powerful tool for building multi-platform container images with Docker. It provides a flexible way to build, push, and manage images. For further information, check out the Docker Buildx documentation.

1. Automated Container Updates Using GitHub Actions

GitHub Actions can automate the process of building and pushing container images to your Sixfab private registry whenever changes are made to your repository.

Setup Guide

1. Create a Dockerfile:

Ensure your repository contains a Dockerfile, which defines how your container image is built.
Refer to App Containerization with Dockerfile Templates for more details.

2. Configure GitHub Secrets:

  • Navigate to your GitHub repository, then go to Settings → Secrets and variables → Actions.

  • Add the following secrets:

    REGISTRY_URLcr.sixfab.io
    SIXFAB_USERNAMESixfab registry username.
    SIXFAB_PASSWORDSixfab registry password.
    DOCKER_IMAGEDocker image name (e.g., yourusername/yourrepository)

3. Create a GitHub Action Workflow:

  • In your repository, create a .github/workflows 📁 directory.


  • Inside this directory, create a file named docker-build.yml with the following content:

name: Build and Push Docker Image

on:
  push:
    branches:
      - main  # Change this to your default branch if different
  workflow_dispatch:  # Allows manual triggering

jobs:

  build:
    runs-on: ubuntu-latest
   
    steps:
    - uses: actions/checkout@v4
    - name: Set up Docker Buildx
      uses: docker/setup-buildx-action@v3
    - name: Login to Sixfab Registry
      uses: docker/login-action@v3
      with:
        registry: cr.sixfab.io
        username: ${{ secrets.SIXFAB_USERNAME }}
        password: ${{ secrets.SIXFAB_PASSWORD }}
    - name: Build Docker Image
      uses: docker/build-push-action@v6
      with:
        context: .
        platforms: linux/arm64
        load: true
        tags: ${{ secrets.DOCKER_IMAGE }}:latest
    - name: Tag Docker Image for Sixfab Registry
      run: docker tag ${{ secrets.DOCKER_IMAGE }}:latest cr.sixfab.io/${{ secrets.SIXFAB_USERNAME }}/${{ secrets.DOCKER_IMAGE }}:latest
    - name: Push Docker Image to Sixfab Registry
      run: docker push cr.sixfab.io/${{ secrets.SIXFAB_USERNAME }}/${{ secrets.DOCKER_IMAGE }}:latest

How It Works

  • This GitHub Action workflow triggers on every push to the main branch (or the specified branch).
  • It checks out your code, sets up Docker Buildx, logs into your Sixfab registry, and builds and pushes the image to the specified registry.

Triggering the Action

The action runs automatically on each push to the main branch and can also be triggered manually from the Actions tab under Build and Push Docker Image → Run workflow.



2. Manual Container Update Using Docker Buildx

If you prefer to manually update your container images using Docker Buildx, follow these steps:


1. Install Docker Buildx:

Ensure Docker is installed on your system. Docker Buildx comes pre-installed with Docker Desktop or can be added as a plugin for Docker Engine.


2. Prepare Your Dockerfile:

Make sure your project directory contains a Dockerfile that defines your container image.


3. Build the New Container Version:

Use the docker buildx command to build your container image. Example:

docker buildx build --platform linux/arm64 -t [image]:[tag] .

Replace [image]:[tag] with the name and tag of your image.

🚧

Important

Ensure that the tag is unique to avoid confusion with older versions.


4. Push the New Container to Sixfab Registry:

Visit the Manage & Deploy Applications page for all the necessary details on pushing your container image to the Sixfab Registry.


5. Deploy the New Version:

  • Go to the Application section of your asset on Sixfab Connect.

  • Click the Edit Deployment button.


  • Select your newly tagged image and click Update button.

  • Wait for the deployment to finish!



Leveraging GitHub Actions for automated container updates ensures seamless integration and deployment of new code, while Docker Buildx provides a flexible manual update option. Select the method that best suits your workflow to keep your container images consistently up-to-date in your private registry.