Skip to content

feat: Update Dockerfile to use --system flag for pip installations an… #21

feat: Update Dockerfile to use --system flag for pip installations an…

feat: Update Dockerfile to use --system flag for pip installations an… #21

Workflow file for this run

name: Build and Push Docker Image
on:
push:
branches:
- '**'
tags: ["v*.*.*"]
pull_request:
branches:
- '**'
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
CACHE_FROM: type=registry,ref=${{ github.repository }}:buildcache
CACHE_TO: type=registry,ref=${{ github.repository }}:buildcache,mode=max
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
version: latest
driver-opts: |
image=moby/buildkit:latest
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Cache Python dependencies
- name: Cache pip packages
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt', '**/pyproject.toml') }}
restore-keys: |
${{ runner.os }}-pip-
# Set image name based on branch
- name: Set image name and tags
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
# For main branch
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
type=sha,format=short,prefix=,enable=${{ github.ref == 'refs/heads/main' }}
# For other branches
type=raw,value=dev-latest,enable=${{ github.ref != 'refs/heads/main' }}
type=sha,format=short,prefix=dev-,enable=${{ github.ref != 'refs/heads/main' }}
# For tags
type=ref,event=tag
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: |
type=gha
type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache
cache-to: |
type=gha,mode=max
type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache,mode=max
platforms: linux/amd64
build-args: |
BUILDKIT_INLINE_CACHE=1