From 3e225b158f8273b05fff6cfc0dda7aa141eb586b Mon Sep 17 00:00:00 2001 From: Benoit Date: Tue, 23 Dec 2025 13:23:07 +0100 Subject: [PATCH] Fix build et actions --- .claude/settings.local.json | 3 +- .gitea/workflows/docker.yml | 20 ++++++------ DEPLOYMENT.md | 4 ++- README.md | 17 ++++++++-- backend/Dockerfile | 9 +++--- docker-compose.build.yml | 64 +++++++++++++++++++++++++++++++++++++ docker-compose.yml | 7 ++-- frontend/Dockerfile | 11 +++---- 8 files changed, 104 insertions(+), 31 deletions(-) create mode 100644 docker-compose.build.yml diff --git a/.claude/settings.local.json b/.claude/settings.local.json index 2ebede2..33dba69 100644 --- a/.claude/settings.local.json +++ b/.claude/settings.local.json @@ -10,7 +10,8 @@ "Bash(curl:*)", "Bash(docker logs:*)", "Bash(docker exec:*)", - "Bash(ls:*)" + "Bash(ls:*)", + "Bash(docker build:*)" ] } } diff --git a/.gitea/workflows/docker.yml b/.gitea/workflows/docker.yml index 08e6a96..da29646 100644 --- a/.gitea/workflows/docker.yml +++ b/.gitea/workflows/docker.yml @@ -36,8 +36,8 @@ jobs: - name: Determine version id: version run: | - if [[ "${{ github.ref }}" == refs/tags/v* ]]; then - echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT + if [[ "${{ gitea.ref }}" == refs/tags/v* ]]; then + echo "VERSION=${GITEA_REF#refs/tags/}" >> $GITHUB_OUTPUT else echo "VERSION=dev-$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT fi @@ -50,9 +50,9 @@ jobs: tags: | type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} - type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/v') }} - type=raw,value=dev,enable=${{ github.ref == 'refs/heads/main' }} - type=sha,prefix=dev-,format=short,enable=${{ github.ref == 'refs/heads/main' }} + type=raw,value=latest,enable=${{ startsWith(gitea.ref, 'refs/tags/v') }} + type=raw,value=dev,enable=${{ gitea.ref == 'refs/heads/main' }} + type=sha,prefix=dev-,format=short,enable=${{ gitea.ref == 'refs/heads/main' }} - name: Build and push backend uses: docker/build-push-action@v5 @@ -90,8 +90,8 @@ jobs: - name: Determine version id: version run: | - if [[ "${{ github.ref }}" == refs/tags/v* ]]; then - echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT + if [[ "${{ gitea.ref }}" == refs/tags/v* ]]; then + echo "VERSION=${GITEA_REF#refs/tags/}" >> $GITHUB_OUTPUT else echo "VERSION=dev-$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT fi @@ -104,9 +104,9 @@ jobs: tags: | type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} - type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/v') }} - type=raw,value=dev,enable=${{ github.ref == 'refs/heads/main' }} - type=sha,prefix=dev-,format=short,enable=${{ github.ref == 'refs/heads/main' }} + type=raw,value=latest,enable=${{ startsWith(gitea.ref, 'refs/tags/v') }} + type=raw,value=dev,enable=${{ gitea.ref == 'refs/heads/main' }} + type=sha,prefix=dev-,format=short,enable=${{ gitea.ref == 'refs/heads/main' }} - name: Build and push frontend uses: docker/build-push-action@v5 diff --git a/DEPLOYMENT.md b/DEPLOYMENT.md index ea18e01..bafebd0 100644 --- a/DEPLOYMENT.md +++ b/DEPLOYMENT.md @@ -14,7 +14,7 @@ Le système est **100% autonome** - aucune action manuelle requise ! Les modèle 1. **Cloner le projet** : ```bash -git clone +git clone https://git.benoitsz.com/benoit/Audio-Classifier.git cd Audio-Classifier ``` @@ -36,6 +36,8 @@ docker-compose up -d C'est tout ! 🎉 +**Note** : Les images Docker sont automatiquement téléchargées depuis git.benoitsz.com. Aucun build nécessaire ! + ### Premier Scan 1. Ouvrir http://localhost:3000 diff --git a/README.md b/README.md index 42b1e95..cc5e6d0 100644 --- a/README.md +++ b/README.md @@ -41,8 +41,8 @@ Outil de classification audio automatique capable d'indexer et analyser des bibl ```bash # 1. Cloner le projet -git clone -cd audio-classifier +git clone https://git.benoitsz.com/benoit/Audio-Classifier.git +cd Audio-Classifier # 2. Configurer le chemin audio (optionnel) echo "AUDIO_LIBRARY_PATH=/chemin/vers/votre/musique" > .env @@ -53,6 +53,8 @@ docker-compose up -d **C'est tout !** 🎉 +Les images Docker sont automatiquement téléchargées depuis le registry Gitea. + - Frontend : http://localhost:3000 - API : http://localhost:8001 - API Docs : http://localhost:8001/docs @@ -66,13 +68,22 @@ docker-compose up -d ### ✨ Particularités -- **Aucun téléchargement manuel** : Les modèles Essentia (28 MB) sont inclus dans l'image Docker +- **Images pré-construites** : Téléchargées automatiquement depuis git.benoitsz.com +- **Modèles inclus** : Les modèles Essentia (28 MB) sont intégrés dans l'image - **Aucune configuration** : Tout fonctionne out-of-the-box - **Transcodage automatique** : MP3 128kbps créés pour streaming rapide - **Waveforms pré-calculées** : Chargement instantané 📖 **Documentation complète** : Voir [DEPLOYMENT.md](DEPLOYMENT.md) +### 🛠 Build local (développement) + +Si vous voulez builder les images localement : +```bash +docker-compose -f docker-compose.build.yml build +docker-compose -f docker-compose.build.yml up -d +``` + ## 📖 Utilisation ### Scanner un dossier diff --git a/backend/Dockerfile b/backend/Dockerfile index 80e4ad1..c4aa464 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -32,7 +32,7 @@ WORKDIR /app RUN pip install --no-cache-dir --upgrade pip setuptools wheel # Copy requirements -COPY requirements.txt . +COPY backend/requirements.txt . # Install Python dependencies in stages for better caching # Using versions compatible with Python 3.9 @@ -45,10 +45,11 @@ RUN pip install --no-cache-dir essentia-tensorflow RUN pip install --no-cache-dir -r requirements.txt # Copy application code -COPY src/ ./src/ -COPY alembic.ini . +COPY backend/src/ ./src/ +COPY backend/alembic.ini . -COPY src/models/ ./models/ +# Copy Essentia models into image (28 MB total) +COPY backend/models/ ./models/ RUN ls -lh /app/models # Expose port diff --git a/docker-compose.build.yml b/docker-compose.build.yml new file mode 100644 index 0000000..0b627f7 --- /dev/null +++ b/docker-compose.build.yml @@ -0,0 +1,64 @@ +# Docker Compose pour build local (développement) +# Usage: docker-compose -f docker-compose.build.yml build + +services: + postgres: + image: pgvector/pgvector:pg16 + container_name: audio_classifier_db + environment: + POSTGRES_USER: ${POSTGRES_USER:-audio_user} + POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-audio_password} + POSTGRES_DB: ${POSTGRES_DB:-audio_classifier} + ports: + - "5433:5432" + volumes: + - postgres_data:/var/lib/postgresql/data + - ./backend/init-db.sql:/docker-entrypoint-initdb.d/init-db.sql + healthcheck: + test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-audio_user}"] + interval: 10s + timeout: 5s + retries: 5 + restart: unless-stopped + + backend: + build: + context: . + dockerfile: backend/Dockerfile + container_name: audio_classifier_api + depends_on: + postgres: + condition: service_healthy + environment: + DATABASE_URL: postgresql://${POSTGRES_USER:-audio_user}:${POSTGRES_PASSWORD:-audio_password}@postgres:5432/${POSTGRES_DB:-audio_classifier} + CORS_ORIGINS: ${CORS_ORIGINS:-http://localhost:3000} + ANALYSIS_USE_CLAP: ${ANALYSIS_USE_CLAP:-false} + ANALYSIS_NUM_WORKERS: ${ANALYSIS_NUM_WORKERS:-4} + ESSENTIA_MODELS_PATH: /app/models + ports: + - "8001:8000" + volumes: + # Mount your audio library (read-write for transcoding and waveforms) + - ${AUDIO_LIBRARY_PATH:-./audio_samples}:/audio + restart: unless-stopped + + frontend: + build: + context: . + dockerfile: frontend/Dockerfile + args: + NEXT_PUBLIC_API_URL: http://localhost:8001 + container_name: audio_classifier_ui + environment: + # Use localhost:8001 because the browser (client-side) needs to access the API + # The backend is mapped to port 8001 on the host machine + NEXT_PUBLIC_API_URL: http://localhost:8001 + ports: + - "3000:3000" + depends_on: + - backend + restart: unless-stopped + +volumes: + postgres_data: + driver: local diff --git a/docker-compose.yml b/docker-compose.yml index 223c50c..4b9be24 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -19,7 +19,7 @@ services: restart: unless-stopped backend: - build: ./backend + image: git.benoitsz.com/benoit/audio-classifier-backend:latest container_name: audio_classifier_api depends_on: postgres: @@ -38,10 +38,7 @@ services: restart: unless-stopped frontend: - build: - context: ./frontend - args: - NEXT_PUBLIC_API_URL: http://localhost:8001 + image: git.benoitsz.com/benoit/audio-classifier-frontend:latest container_name: audio_classifier_ui environment: # Use localhost:8001 because the browser (client-side) needs to access the API diff --git a/frontend/Dockerfile b/frontend/Dockerfile index f025dbc..566423f 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -4,16 +4,13 @@ FROM node:20-alpine WORKDIR /app # Copy package files -COPY package*.json ./ +COPY frontend/package*.json ./ -# Debug: List files and Node.js version -RUN ls -la && node --version && npm --version - -# Install dependencies with more verbose output -RUN npm install --verbose +# Install dependencies +RUN npm ci # Copy application code -COPY . . +COPY frontend/ . # Build argument for API URL ARG NEXT_PUBLIC_API_URL=http://localhost:8001