build (dockerfile.dev): refactor to use uv #80
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish Docker image | |
on: | |
push: | |
branches: | |
- 'main' | |
- 'master' | |
tags: | |
- '*.*.*' | |
paths: | |
# Application code | |
- 'app/**' | |
- 'bin/**' | |
- 'config/**' | |
- 'tests/**' | |
- 'static/**' | |
# Docker and environment configs | |
- 'Dockerfile*' | |
- 'docker-compose.yml' | |
- 'docker-bake.hcl' | |
- '.dockerignore' | |
- '.env.example' | |
# Dependencies and python configs | |
- 'requirements.txt' | |
- 'pyproject.toml' | |
- 'uv.lock' | |
# Workflow files | |
- '.github/workflows/**' | |
# Shell scripts | |
- '**/*.py' | |
- '**/*.sh' | |
- '**/*.js' | |
- '**/*.css' | |
# workflow_run: | |
# workflows: ["Run pytest"] | |
# types: | |
# - completed | |
env: | |
REGISTRY_URL: ghcr.io | |
REGISTRY_USER: ${{ github.repository_owner }} | |
IMAGE_NAME: ${{ vars.IMAGE || 'meetup_bot' }} | |
DOCKERFILE: Dockerfile.web | |
jobs: | |
build-and-push: | |
name: Build and push Docker image | |
runs-on: ubuntu-latest | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
permissions: | |
packages: write | |
contents: read | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v4 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY_URL }} | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: | | |
${{ env.REGISTRY_URL }}/${{ env.REGISTRY_USER }}/${{ env.IMAGE_NAME }} | |
tags: | | |
type=raw,value=latest,enable=${{ endsWith(github.ref, 'main') }} | |
type=ref,event=branch,enable=${{ !endsWith(github.ref, 'main') }} | |
type=semver,pattern={{version}} | |
flavor: | | |
latest=false | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
with: | |
platforms: linux/amd64,linux/arm64 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
with: | |
platforms: linux/amd64,linux/arm64 | |
- name: Build and push with Docker Bake | |
uses: docker/bake-action@v6 | |
env: | |
TAG: ${{ steps.meta.outputs.version }} | |
with: | |
files: ./docker-bake.hcl | |
targets: multi-platform | |
push: ${{ github.event_name != 'pull_request' }} | |
set: | | |
*.tags=${{ steps.meta.outputs.tags }} | |
*.cache-from=type=gha,scope=${{ github.workflow }} | |
*.cache-to=type=gha,mode=max,scope=${{ github.workflow }} | |
*.platform=linux/amd64,linux/arm64 | |
*.args.PYTHON_VERSION=3.11 |