Refactor Docker Compose for local builds and enhance Ollama client . … #25
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: Build & Push Portfolio Images | |
| on: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| build-and-push: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Log in to GHCR | |
| uses: docker/login-action@v2 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GHCR_TOKEN }} | |
| - name: Build frontend image | |
| run: | | |
| API_URL="${{ secrets.NEXT_PUBLIC_API_URL }}" | |
| if [ -z "$API_URL" ]; then | |
| API_URL="https://portfolio-api.medevs.local" | |
| fi | |
| docker build \ | |
| --build-arg NEXT_PUBLIC_API_URL=${API_URL} \ | |
| -t ghcr.io/${{ github.repository_owner }}/portfolio-frontend:latest \ | |
| ./frontend | |
| - name: Build backend image | |
| run: | | |
| docker build -t ghcr.io/${{ github.repository_owner }}/portfolio-backend:latest ./backend | |
| - name: Push frontend image | |
| run: | | |
| docker push ghcr.io/${{ github.repository_owner }}/portfolio-frontend:latest | |
| - name: Push backend image | |
| run: | | |
| docker push ghcr.io/${{ github.repository_owner }}/portfolio-backend:latest | |
| deploy: | |
| runs-on: self-hosted | |
| needs: build-and-push | |
| if: github.ref == 'refs/heads/main' | |
| steps: | |
| - name: Deploy to homelab | |
| run: | | |
| set -e | |
| cd ~/projects/local-smart-portfolio | |
| echo "📥 Pulling latest images..." | |
| docker compose pull | |
| echo "🔄 Recreating containers..." | |
| docker compose up -d --force-recreate | |
| echo "🧹 Cleaning up old images..." | |
| docker image prune -f | |
| echo "✅ Deployment complete!" |