# ALTERNATIVE SOLUTION: Configure runner with Docker CLI pre-installed
#
# This file shows how to set up the Gitea runner to have Docker CLI available
# by default, eliminating the need for Docker-in-Docker.
#
# SETUP INSTRUCTIONS:
#
# 1. SSH into your server where the Gitea runner is running
#
# 2. Find the runner container or installation:
#    docker ps | grep act_runner
#
# 3. Option A: If runner is in Docker, create custom runner image
#    Create a Dockerfile:
#
#    FROM gitea/act_runner:latest
#    RUN apk add --no-cache docker-cli
#
#    Build and use:
#    docker build -t gitea-runner-with-docker .
#    # Update docker-compose or run command to use this image
#
# 4. Option B: If runner is installed on host, install Docker CLI:
#
#    # For Ubuntu/Debian host
#    curl -fsSL https://get.docker.com -o get-docker.sh
#    sh get-docker.sh
#
#    # Restart the runner service
#    systemctl restart act_runner
#
# 5. Once Docker CLI is available in runner, use this simpler workflow:

name: Build and Push Docker Image

on:
  push:
    branches:
      - main

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Verify Docker is available
        run: docker version

      - name: Log in to Gitea Container Registry
        run: |
          echo "${{ secrets.GITHUB_TOKEN }}" | docker login code.puffinoffset.com -u ${{ github.actor }} --password-stdin

      - name: Build Docker image
        run: |
          docker build -t code.puffinoffset.com/matt/puffin-app:latest \
                       -t code.puffinoffset.com/matt/puffin-app:main-${{ github.sha }} \
                       .

      - name: Push Docker images
        run: |
          docker push code.puffinoffset.com/matt/puffin-app:latest
          docker push code.puffinoffset.com/matt/puffin-app:main-${{ github.sha }}

      - name: Show image info
        run: |
          docker images | grep puffin-app

# BENEFITS OF THIS APPROACH:
# - Faster workflow execution (no container setup overhead)
# - Simpler workflow file
# - Better caching between builds
# - More control over runner environment
#
# WHEN TO USE:
# - If you have access to modify the runner
# - If you run multiple workflows that need Docker
# - For production environments where performance matters
