From 01f04c44d9ce369bbee642ad1e485df68a26c215 Mon Sep 17 00:00:00 2001 From: David Inostroza Date: Thu, 23 Apr 2026 17:54:38 -0400 Subject: [PATCH] persiste datos en ./data/ montado como volumen del host MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reemplaza los bind mounts individuales de cantina.db y .spotify_cache por un único directorio ./data/ montado en /app/data. El entrypoint crea el directorio y los archivos vacíos si no existen, evitando que Docker los cree como directorios al hacer un despliegue limpio. Co-Authored-By: Claude Sonnet 4.6 --- .gitignore | 1 + app/config.py | 2 +- app/routers/auth.py | 2 +- app/spotify.py | 2 +- docker-compose.yml | 3 +-- entrypoint.sh | 4 ++-- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 745d7a8..edb2376 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ .env .spotify_cache cantina.db +data/ __pycache__/ *.pyc .venv/ diff --git a/app/config.py b/app/config.py index 2a34223..e033550 100644 --- a/app/config.py +++ b/app/config.py @@ -8,7 +8,7 @@ class Settings(BaseSettings): ADMIN_USERNAME: str = "admin" ADMIN_PASSWORD: str = "admin123" SECRET_KEY: str = "cambia-esta-clave-secreta" - DATABASE_URL: str = "sqlite:///./cantina.db" + DATABASE_URL: str = "sqlite:///./data/cantina.db" SPOTIFY_SCOPES: str = ( "user-read-playback-state " diff --git a/app/routers/auth.py b/app/routers/auth.py index 59cbc96..591e106 100644 --- a/app/routers/auth.py +++ b/app/routers/auth.py @@ -21,7 +21,7 @@ def spotify_callback(code: str): @router.get("/logout") def spotify_logout(): try: - os.remove(".spotify_cache") + os.remove("data/.spotify_cache") except FileNotFoundError: pass return RedirectResponse(url="/auth/login") diff --git a/app/spotify.py b/app/spotify.py index 02229db..97e5b33 100644 --- a/app/spotify.py +++ b/app/spotify.py @@ -8,7 +8,7 @@ _oauth = SpotifyOAuth( client_secret=settings.SPOTIFY_CLIENT_SECRET, redirect_uri=settings.SPOTIFY_REDIRECT_URI, scope=settings.SPOTIFY_SCOPES, - cache_path=".spotify_cache", + cache_path="data/.spotify_cache", open_browser=False, ) diff --git a/docker-compose.yml b/docker-compose.yml index 084e246..b23ee48 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,8 +5,7 @@ services: - "8000:8000" env_file: .env volumes: - - ./cantina.db:/app/cantina.db - - ./.spotify_cache:/app/.spotify_cache + - ./data:/app/data restart: unless-stopped networks: - containers diff --git a/entrypoint.sh b/entrypoint.sh index 5477b6d..678e6b9 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,8 +1,8 @@ #!/bin/sh set -e -# Archivos de datos — crearlos si no existen para que los bind mounts funcionen -touch cantina.db .spotify_cache +mkdir -p data +touch data/cantina.db data/.spotify_cache exec uvicorn app.main:app \ --host 0.0.0.0 \