persiste datos en ./data/ montado como volumen del host
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 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
.env
|
.env
|
||||||
.spotify_cache
|
.spotify_cache
|
||||||
cantina.db
|
cantina.db
|
||||||
|
data/
|
||||||
__pycache__/
|
__pycache__/
|
||||||
*.pyc
|
*.pyc
|
||||||
.venv/
|
.venv/
|
||||||
|
|||||||
+1
-1
@@ -8,7 +8,7 @@ class Settings(BaseSettings):
|
|||||||
ADMIN_USERNAME: str = "admin"
|
ADMIN_USERNAME: str = "admin"
|
||||||
ADMIN_PASSWORD: str = "admin123"
|
ADMIN_PASSWORD: str = "admin123"
|
||||||
SECRET_KEY: str = "cambia-esta-clave-secreta"
|
SECRET_KEY: str = "cambia-esta-clave-secreta"
|
||||||
DATABASE_URL: str = "sqlite:///./cantina.db"
|
DATABASE_URL: str = "sqlite:///./data/cantina.db"
|
||||||
|
|
||||||
SPOTIFY_SCOPES: str = (
|
SPOTIFY_SCOPES: str = (
|
||||||
"user-read-playback-state "
|
"user-read-playback-state "
|
||||||
|
|||||||
+1
-1
@@ -21,7 +21,7 @@ def spotify_callback(code: str):
|
|||||||
@router.get("/logout")
|
@router.get("/logout")
|
||||||
def spotify_logout():
|
def spotify_logout():
|
||||||
try:
|
try:
|
||||||
os.remove(".spotify_cache")
|
os.remove("data/.spotify_cache")
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
pass
|
pass
|
||||||
return RedirectResponse(url="/auth/login")
|
return RedirectResponse(url="/auth/login")
|
||||||
|
|||||||
+1
-1
@@ -8,7 +8,7 @@ _oauth = SpotifyOAuth(
|
|||||||
client_secret=settings.SPOTIFY_CLIENT_SECRET,
|
client_secret=settings.SPOTIFY_CLIENT_SECRET,
|
||||||
redirect_uri=settings.SPOTIFY_REDIRECT_URI,
|
redirect_uri=settings.SPOTIFY_REDIRECT_URI,
|
||||||
scope=settings.SPOTIFY_SCOPES,
|
scope=settings.SPOTIFY_SCOPES,
|
||||||
cache_path=".spotify_cache",
|
cache_path="data/.spotify_cache",
|
||||||
open_browser=False,
|
open_browser=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
+1
-2
@@ -5,8 +5,7 @@ services:
|
|||||||
- "8000:8000"
|
- "8000:8000"
|
||||||
env_file: .env
|
env_file: .env
|
||||||
volumes:
|
volumes:
|
||||||
- ./cantina.db:/app/cantina.db
|
- ./data:/app/data
|
||||||
- ./.spotify_cache:/app/.spotify_cache
|
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
networks:
|
networks:
|
||||||
- containers
|
- containers
|
||||||
|
|||||||
+2
-2
@@ -1,8 +1,8 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# Archivos de datos — crearlos si no existen para que los bind mounts funcionen
|
mkdir -p data
|
||||||
touch cantina.db .spotify_cache
|
touch data/cantina.db data/.spotify_cache
|
||||||
|
|
||||||
exec uvicorn app.main:app \
|
exec uvicorn app.main:app \
|
||||||
--host 0.0.0.0 \
|
--host 0.0.0.0 \
|
||||||
|
|||||||
Reference in New Issue
Block a user