Spaces:
Running
Running
Commit
·
d5bb983
1
Parent(s):
053d168
Refactor Dockerfile and migration script: adjust directory creation order in Dockerfile for improved clarity, and enhance logging in migrate.py to include current directory and file existence checks for better debugging.
Browse files- Dockerfile +5 -6
- scripts/migrate.py +22 -6
Dockerfile
CHANGED
@@ -20,14 +20,13 @@ RUN apt-get update && apt-get install -y \
|
|
20 |
COPY requirements.txt .
|
21 |
RUN pip install --no-cache-dir -r requirements.txt
|
22 |
|
23 |
-
#
|
24 |
-
RUN mkdir -p /app/app/models /app/storage/audio /app/storage/text /app/storage/temp
|
25 |
-
|
26 |
-
# Copy application code
|
27 |
COPY . .
|
28 |
|
29 |
-
#
|
30 |
-
RUN
|
|
|
|
|
31 |
# Create app user
|
32 |
useradd -m -u 1000 app && \
|
33 |
# Set ownership of all files and directories
|
|
|
20 |
COPY requirements.txt .
|
21 |
RUN pip install --no-cache-dir -r requirements.txt
|
22 |
|
23 |
+
# Copy application code first
|
|
|
|
|
|
|
24 |
COPY . .
|
25 |
|
26 |
+
# Create storage directories (after copying code)
|
27 |
+
RUN mkdir -p /app/storage/audio /app/storage/text /app/storage/temp && \
|
28 |
+
# Set up permissions
|
29 |
+
chmod +x /app/scripts/run.sh && \
|
30 |
# Create app user
|
31 |
useradd -m -u 1000 app && \
|
32 |
# Set ownership of all files and directories
|
scripts/migrate.py
CHANGED
@@ -5,18 +5,34 @@ import logging
|
|
5 |
from alembic.config import Config
|
6 |
from alembic import command
|
7 |
|
8 |
-
#
|
9 |
-
project_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
10 |
-
if project_root not in sys.path:
|
11 |
-
sys.path.insert(0, project_root)
|
12 |
-
|
13 |
-
# Configure logging
|
14 |
logging.basicConfig(
|
15 |
level=logging.INFO,
|
16 |
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
|
17 |
)
|
18 |
logger = logging.getLogger(__name__)
|
19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
try:
|
21 |
from app.models.database import Base
|
22 |
except ImportError as e:
|
|
|
5 |
from alembic.config import Config
|
6 |
from alembic import command
|
7 |
|
8 |
+
# Configure logging first
|
|
|
|
|
|
|
|
|
|
|
9 |
logging.basicConfig(
|
10 |
level=logging.INFO,
|
11 |
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
|
12 |
)
|
13 |
logger = logging.getLogger(__name__)
|
14 |
|
15 |
+
# Add the project root to Python path
|
16 |
+
project_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
17 |
+
if project_root not in sys.path:
|
18 |
+
sys.path.insert(0, project_root)
|
19 |
+
|
20 |
+
# Debug: Print current directory and file existence
|
21 |
+
logger.info(f"Current directory: {os.getcwd()}")
|
22 |
+
logger.info(f"Project root: {project_root}")
|
23 |
+
|
24 |
+
models_init = os.path.join(project_root, "app", "models", "__init__.py")
|
25 |
+
models_db = os.path.join(project_root, "app", "models", "database.py")
|
26 |
+
|
27 |
+
logger.info(f"Checking if files exist:")
|
28 |
+
logger.info(f"__init__.py exists: {os.path.exists(models_init)}")
|
29 |
+
logger.info(f"database.py exists: {os.path.exists(models_db)}")
|
30 |
+
|
31 |
+
if os.path.exists(models_db):
|
32 |
+
logger.info(f"Content of {models_db}:")
|
33 |
+
with open(models_db, 'r') as f:
|
34 |
+
logger.info(f.read())
|
35 |
+
|
36 |
try:
|
37 |
from app.models.database import Base
|
38 |
except ImportError as e:
|