Skip to content

Build and Push Docker Images #14

Build and Push Docker Images

Build and Push Docker Images #14

name: Build and Push Docker Images
on:
push:
tags:
- 'v*'
workflow_dispatch:
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Ensure all history and tags are fetched
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Get git version
run: echo "VERSION=$(git describe --tags --always)" >> $GITHUB_ENV
- name: Build and Push Backend Docker Image
uses: docker/build-push-action@v5
with:
context: ./backend
file: ./backend/Dockerfile
push: true
tags: |
ghcr.io/${{ github.repository }}/backend:${{ env.VERSION }}
ghcr.io/${{ github.repository }}/backend:latest
platforms: linux/amd64,linux/arm64,linux/arm64/v8
- name: Build and Push Frontend Docker Image
uses: docker/build-push-action@v5
with:
context: ./frontend
file: ./frontend/Dockerfile
push: true
tags: |
ghcr.io/${{ github.repository }}/frontend:${{ env.VERSION }}
ghcr.io/${{ github.repository }}/frontend:latest
platforms: linux/amd64,linux/arm64,linux/arm64/v8