Skip to content

Base Docker Image - Build and Push #1

Base Docker Image - Build and Push

Base Docker Image - Build and Push #1

# This YAML file is used to build and push a base Docker image with the necessary tools and dependencies for an ML project
# It contains a job that builds the Docker image and pushes it to GitHub Container Registry
name: Base Docker Image - Build and Push
on:
# Trigger the workflow manually
workflow_dispatch:
jobs:
build_and_push:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
# Check out the repository containing the Dockerfile and other necessary files
uses: actions/checkout@v2
- name: Log in to GitHub Container Registry
# Log in to GitHub Container Registry using the actor and a GitHub token
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
# Set up Docker Buildx for building multi-architecture images
uses: docker/setup-buildx-action@v2
- name: Format repo slug
# Format the repository slug to lowercase for use in the Docker image tags
id: repo_slug
run: echo "REPO_SLUG=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
- name: Build and push Docker image
# Build the Docker image using the Dockerfile in the `docker_base` directory and push it to GitHub Container Registry
uses: docker/build-push-action@v4
with:
context: ./docker_base
push: true
tags: ghcr.io/${{ env.REPO_SLUG }}/arm-mlops-docker-base:latest
# Use GitHub Actions cache to speed up the build process
cache-from: type=gha
cache-to: type=gha,mode=max