Trae Assistant commited on
Commit
3f9ecc8
·
1 Parent(s): b39c72b

Fix HF Spaces permissions: use /app/data for DB and set correct Docker permissions

Browse files
Files changed (3) hide show
  1. .gitignore +1 -1
  2. Dockerfile +5 -3
  3. app.py +3 -1
.gitignore CHANGED
@@ -1,5 +1,5 @@
1
  __pycache__/
2
  *.pyc
3
- fleet.db
4
  uploads/
5
  .DS_Store
 
1
  __pycache__/
2
  *.pyc
3
+ data/
4
  uploads/
5
  .DS_Store
Dockerfile CHANGED
@@ -7,11 +7,13 @@ RUN pip install --no-cache-dir -r requirements.txt
7
 
8
  COPY . .
9
 
10
- # Create uploads directory and set permissions
 
 
11
  RUN mkdir -p /app/uploads && \
 
12
  chmod 777 /app/uploads && \
13
- touch /app/fleet.db && \
14
- chmod 777 /app/fleet.db
15
 
16
  # Create a non-root user for security (recommended for HF Spaces)
17
  RUN useradd -m -u 1000 user
 
7
 
8
  COPY . .
9
 
10
+ # Create uploads and data directory and set permissions
11
+ # It is critical to set permissions for the directory containing the SQLite DB
12
+ # because SQLite creates temporary journal files in that directory.
13
  RUN mkdir -p /app/uploads && \
14
+ mkdir -p /app/data && \
15
  chmod 777 /app/uploads && \
16
+ chmod 777 /app/data
 
17
 
18
  # Create a non-root user for security (recommended for HF Spaces)
19
  RUN useradd -m -u 1000 user
app.py CHANGED
@@ -26,7 +26,9 @@ SILICONFLOW_BASE_URL = "https://api.siliconflow.cn/v1"
26
  os.makedirs(app.config['UPLOAD_FOLDER'], exist_ok=True)
27
 
28
  # Database Setup
29
- DB_PATH = 'fleet.db'
 
 
30
 
31
  def init_db():
32
  conn = sqlite3.connect(DB_PATH)
 
26
  os.makedirs(app.config['UPLOAD_FOLDER'], exist_ok=True)
27
 
28
  # Database Setup
29
+ DATA_DIR = 'data'
30
+ os.makedirs(DATA_DIR, exist_ok=True)
31
+ DB_PATH = os.path.join(DATA_DIR, 'fleet.db')
32
 
33
  def init_db():
34
  conn = sqlite3.connect(DB_PATH)