Files
ltbxd-actorle/.gitea/workflows/docker.yml
thibaud-leclere 21b0f681be
Some checks failed
Build and Push Docker Images / Build app image (push) Failing after 3m4s
Build and Push Docker Images / Build database image (push) Failing after 15s
chore(docker): dockerize app, add workflow to push image on gitea registry
2026-03-28 09:22:47 +01:00

87 lines
3.0 KiB
YAML

name: Build and Push Docker Images
on:
push:
branches:
- main
jobs:
build-app:
name: Build app image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Check if app image should be rebuilt
id: changed
run: |
# Rebuild if docker/app/ or any PHP/config source changed
CHANGED=$(git diff --name-only HEAD~1 HEAD | grep -E '^(docker/app/|src/|config/|templates/|migrations/|composer\.(json|lock)|symfony\.lock|\.env)' | wc -l)
echo "changed=$([ "$CHANGED" -gt 0 ] && echo true || echo false)" >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
if: steps.changed.outputs.changed == 'true'
uses: docker/setup-buildx-action@v3
- name: Login to Gitea registry
if: steps.changed.outputs.changed == 'true'
uses: docker/login-action@v3
with:
registry: git.lclr.dev
username: ${{ gitea.actor }}
password: ${{ secrets.GITEA_TOKEN }}
- name: Build and push app
if: steps.changed.outputs.changed == 'true'
uses: docker/build-push-action@v6
with:
context: .
file: docker/app/Dockerfile
target: prod
push: true
tags: |
git.lclr.dev/thibaud-lclr/ltbxd-actorle/app:latest
git.lclr.dev/thibaud-lclr/ltbxd-actorle/app:${{ github.sha }}
cache-from: type=registry,ref=git.lclr.dev/thibaud-lclr/ltbxd-actorle/app:buildcache
cache-to: type=registry,ref=git.lclr.dev/thibaud-lclr/ltbxd-actorle/app:buildcache,mode=max
build-database:
name: Build database image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Check if database image should be rebuilt
id: changed
run: |
CHANGED=$(git diff --name-only HEAD~1 HEAD | grep -q '^docker/database/' && echo true || echo false)
echo "changed=$CHANGED" >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
if: steps.changed.outputs.changed == 'true'
uses: docker/setup-buildx-action@v3
- name: Login to Gitea registry
if: steps.changed.outputs.changed == 'true'
uses: docker/login-action@v3
with:
registry: git.lclr.dev
username: ${{ gitea.actor }}
password: ${{ secrets.GITEA_TOKEN }}
- name: Build and push database
if: steps.changed.outputs.changed == 'true'
uses: docker/build-push-action@v6
with:
context: docker/database
push: true
tags: |
git.lclr.dev/thibaud-lclr/ltbxd-actorle/database:latest
git.lclr.dev/thibaud-lclr/ltbxd-actorle/database:${{ github.sha }}
cache-from: type=registry,ref=git.lclr.dev/thibaud-lclr/ltbxd-actorle/database:buildcache
cache-to: type=registry,ref=git.lclr.dev/thibaud-lclr/ltbxd-actorle/database:buildcache,mode=max