feat: update README.md and docker-compose.yaml

This commit is contained in:
Sabiha Khan 2025-09-24 21:43:22 +05:30 committed by Sabiha Khan
parent 9506f40fa3
commit f4736e5ce2
3 changed files with 74 additions and 44 deletions

View file

@ -3,21 +3,33 @@ name: Build and Push Docker Images
on:
push:
branches:
- feat/actions-ci # testing. replace with main
- feat/actions-ci # Temporary branch for testing; replace with main later
# Ensure only one workflow run per branch at a time; cancel any in-progress runs on new push
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
env:
COMMIT_SHA: ${{ github.sha }}
COMMIT_SHA: ${{ github.sha }} # Used to tag images with short commit SHA
strategy:
matrix:
service:
- "dograh-api-test|api/Dockerfile|./api"
- "dograh-ui-test|ui/Dockerfile|./ui"
steps:
- uses: actions/checkout@v4
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up QEMU
- name: Set up QEMU # Enables cross-platform builds (e.g., arm64)
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
- name: Set up Docker Buildx # Enables multi-arch and advanced Docker builds
uses: docker/setup-buildx-action@v3
- name: Log in to DockerHub
@ -31,30 +43,28 @@ jobs:
with:
registry: ghcr.io
username: ${{ secrets.GHCR_USERNAME }}
password: ${{ secrets.GITHUB_TOKEN }}
password: ${{ secrets.GHCR_TOKEN }}
- name: Build and Push API Image
- name: Build and Push ${{ matrix.service }}
run: |
COMMIT_SHA=$(git rev-parse --short=8 HEAD)
IMAGE_NAME=dograh-api-test
docker buildx build \
-f api/Dockerfile \
--platform linux/amd64,linux/arm64 \
--tag chewieee/$IMAGE_NAME:${COMMIT_SHA::8} \
--tag chewieee/$IMAGE_NAME:latest \
--tag ghcr.io/chewwbaka/$IMAGE_NAME:${COMMIT_SHA::8} \
--tag ghcr.io/chewwbaka/$IMAGE_NAME:latest \
--push ./api
# Parse matrix entry into individual variables
SERVICE="${{ matrix.service }}"
IMAGE_NAME=$(echo "$SERVICE" | cut -d '|' -f1)
DOCKERFILE=$(echo "$SERVICE" | cut -d '|' -f2)
CONTEXT=$(echo "$SERVICE" | cut -d '|' -f3)
SHORT_SHA=${COMMIT_SHA::8}
- name: Build and Push UI Image
run: |
COMMIT_SHA=$(git rev-parse --short=8 HEAD)
IMAGE_NAME=dograh-ui-test
echo "Building and pushing image: $IMAGE_NAME"
echo "Dockerfile: $DOCKERFILE"
echo "Context: $CONTEXT"
echo "Commit SHA: $SHORT_SHA"
# Build and push multi-arch Docker image to DockerHub and GHCR
docker buildx build \
-f ui/Dockerfile \
-f "$DOCKERFILE" \
--platform linux/amd64,linux/arm64 \
--tag chewieee/$IMAGE_NAME:${COMMIT_SHA::8} \
--tag chewieee/$IMAGE_NAME:$SHORT_SHA \
--tag chewieee/$IMAGE_NAME:latest \
--tag ghcr.io/chewwbaka/$IMAGE_NAME:${COMMIT_SHA::8} \
--tag ghcr.io/chewwbaka/$IMAGE_NAME:$SHORT_SHA \
--tag ghcr.io/chewwbaka/$IMAGE_NAME:latest \
--push ./ui
--push "$CONTEXT"