diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml new file mode 100644 index 0000000..56d8d6f --- /dev/null +++ b/.github/workflows/docker-publish.yml @@ -0,0 +1,46 @@ +name: Docker Build and Publish + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=raw,value=latest,enable={{is_default_branch}} + type=sha + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/README.md b/README.md index 68b1ba3..5bd34c2 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,22 @@ make docker-up Access the API: `http://localhost:8080` +## Deployment + +### Unraid + +A dedicated configuration file `docker-compose.unraid.yaml` is provided for Unraid servers. It pulls the pre-built image from GitHub Container Registry. + +1. Copy **only** `docker-compose.unraid.yaml` to your Unraid server (e.g. into `/mnt/user/appdata/flowreader`). +2. Run with Docker Compose: + +```bash +docker-compose -f docker-compose.unraid.yaml up -d +``` + +Note: The configuration uses `/mnt/user/appdata/flowreader/postgres_data` for database persistence. + + ## Development ```bash diff --git a/docker-compose.unraid.yaml b/docker-compose.unraid.yaml new file mode 100644 index 0000000..662fd16 --- /dev/null +++ b/docker-compose.unraid.yaml @@ -0,0 +1,43 @@ +services: + app: + # Utilise l'image construite par GitHub Actions + image: ghcr.io/r0m1k3/flowreader:latest + container_name: flowreader-app + # build: + # context: . + # dockerfile: Dockerfile + ports: + - "8080:8080" + environment: + - PORT=8080 + - DATABASE_URL=postgres://flowreader:flowreader@db:5432/flowreader?sslmode=disable + depends_on: + db: + condition: service_healthy + restart: unless-stopped + # Mappage des logs si nécessaire + # volumes: + # - /mnt/user/appdata/flowreader/logs:/app/logs + + db: + image: postgres:16-alpine + container_name: flowreader-db + environment: + - POSTGRES_USER=flowreader + - POSTGRES_PASSWORD=flowreader + - POSTGRES_DB=flowreader + volumes: + # Persistance des données sur Unraid (chemin typique) + - /mnt/user/appdata/flowreader/postgres_data:/var/lib/postgresql/data + ports: + - "5432:5432" + restart: unless-stopped + healthcheck: + test: [ "CMD-SHELL", "pg_isready -U flowreader -d flowreader" ] + interval: 5s + timeout: 5s + retries: 5 + command: > + postgres -c shared_buffers=24MB -c max_connections=20 -c work_mem=2MB + +# Pas de volumes nommés globaux si on utilise des bind mounts directs pour Unraid