lukhsaankumar commited on
Commit
7bd3f6d
·
1 Parent(s): 52c0a32

Deploy DeepFake Detector API - 2026-04-21 00:22:37

Browse files
Files changed (3) hide show
  1. Dockerfile +8 -3
  2. app/core/config.py +1 -1
  3. start.sh +1 -1
Dockerfile CHANGED
@@ -12,7 +12,10 @@ ENV PYTHONDONTWRITEBYTECODE=1 \
12
  PIP_NO_CACHE_DIR=1 \
13
  PIP_DISABLE_PIP_VERSION_CHECK=1 \
14
  PORT=7860 \
15
- HF_CACHE_DIR=/app/.hf_cache
 
 
 
16
 
17
  # Install system dependencies
18
  RUN apt-get update && apt-get install -y --no-install-recommends \
@@ -37,13 +40,15 @@ COPY --chown=user:user start.sh /app/start.sh
37
 
38
  # Switch to root to create cache directory and set permissions
39
  USER root
40
- RUN mkdir -p /app/.hf_cache && chown -R user:user /app/.hf_cache && chmod +x /app/start.sh
 
 
41
 
42
  # Switch back to user
43
  USER user
44
 
45
  # Prefetch model artifacts at build time so startup does not wait on model downloads.
46
- RUN python -m app.scripts.prefetch_models
47
 
48
  # Copy full project contents after prefetch so docs/tests edits do not invalidate prefetch layers.
49
  COPY --chown=user:user . /app
 
12
  PIP_NO_CACHE_DIR=1 \
13
  PIP_DISABLE_PIP_VERSION_CHECK=1 \
14
  PORT=7860 \
15
+ HF_CACHE_DIR=/app/.hf_cache \
16
+ HF_HUB_CACHE=/app/.hf_cache \
17
+ HF_HOME=/app/.hf_cache/hf_home \
18
+ HF_XET_CACHE=/app/.hf_cache/xet
19
 
20
  # Install system dependencies
21
  RUN apt-get update && apt-get install -y --no-install-recommends \
 
40
 
41
  # Switch to root to create cache directory and set permissions
42
  USER root
43
+ RUN mkdir -p /app/.hf_cache /app/.hf_cache/hf_home /app/.hf_cache/xet \
44
+ && chown -R user:user /app/.hf_cache \
45
+ && chmod +x /app/start.sh
46
 
47
  # Switch back to user
48
  USER user
49
 
50
  # Prefetch model artifacts at build time so startup does not wait on model downloads.
51
+ RUN HF_CACHE_DIR=/app/.hf_cache HF_HUB_CACHE=/app/.hf_cache HF_HOME=/app/.hf_cache/hf_home HF_XET_CACHE=/app/.hf_cache/xet python -m app.scripts.prefetch_models
52
 
53
  # Copy full project contents after prefetch so docs/tests edits do not invalidate prefetch layers.
54
  COPY --chown=user:user . /app
app/core/config.py CHANGED
@@ -19,7 +19,7 @@ def _default_hf_home() -> str:
19
  """Prefer persistent Hugging Face home on HF Spaces when available."""
20
  if os.path.isdir("/data"):
21
  return "/data/.cache/huggingface"
22
- return "/app/.cache/huggingface"
23
 
24
 
25
  class Settings(BaseSettings):
 
19
  """Prefer persistent Hugging Face home on HF Spaces when available."""
20
  if os.path.isdir("/data"):
21
  return "/data/.cache/huggingface"
22
+ return "/app/.hf_cache/hf_home"
23
 
24
 
25
  class Settings(BaseSettings):
start.sh CHANGED
@@ -25,7 +25,7 @@ if [ "${HF_PERSISTENT_CACHE:-true}" = "true" ] && [ -d "$PERSIST_ROOT" ] && [ -w
25
  export HF_CACHE_DIR="$PERSIST_ROOT/.hf_cache"
26
  fi
27
  else
28
- export HF_HOME="${HF_HOME:-/app/.cache/huggingface}"
29
  export HF_CACHE_DIR="${HF_CACHE_DIR:-/app/.hf_cache}"
30
  fi
31
 
 
25
  export HF_CACHE_DIR="$PERSIST_ROOT/.hf_cache"
26
  fi
27
  else
28
+ export HF_HOME="${HF_HOME:-/app/.hf_cache/hf_home}"
29
  export HF_CACHE_DIR="${HF_CACHE_DIR:-/app/.hf_cache}"
30
  fi
31