fariedalfarizi commited on
Commit
2195b13
Β·
1 Parent(s): 05fd8f1

Fix cache permission denied error - recursive chmod 777

Browse files
Files changed (2) hide show
  1. Dockerfile +7 -4
  2. start.sh +3 -0
Dockerfile CHANGED
@@ -20,7 +20,7 @@ RUN pip install --no-cache-dir -r requirements.txt
20
 
21
  # Create cache directory for models BEFORE copying code
22
  # This ensures model downloads are cached even when code changes
23
- RUN mkdir -p /.cache && chmod 777 /.cache
24
  ENV HF_HOME=/.cache
25
  ENV TORCH_HOME=/.cache
26
  ENV XDG_CACHE_HOME=/.cache
@@ -33,7 +33,7 @@ RUN python -c "from transformers import AutoTokenizer, AutoModelForSequenceClass
33
  print('πŸ“₯ Downloading Structure Model from HF Hub...'); \
34
  AutoTokenizer.from_pretrained('Cyberlace/swara-structure-model', cache_dir='/.cache'); \
35
  AutoModelForSequenceClassification.from_pretrained('Cyberlace/swara-structure-model', cache_dir='/.cache'); \
36
- print('βœ… Structure Model cached!')"
37
 
38
  # 2. Whisper will be downloaded on first use (lazy loading to avoid OOM during build)
39
  # RUN python -c "import whisper; \
@@ -45,18 +45,21 @@ RUN python -c "from transformers import AutoTokenizer, AutoModelForSequenceClass
45
  RUN python -c "from sentence_transformers import SentenceTransformer; \
46
  print('πŸ“₯ Downloading Sentence Transformer...'); \
47
  SentenceTransformer('paraphrase-multilingual-MiniLM-L12-v2', cache_folder='/.cache'); \
48
- print('βœ… Sentence Transformer cached!')"
49
 
50
  # 4. Download Silero VAD (~10MB)
51
  RUN python -c "import torch; \
52
  print('πŸ“₯ Downloading Silero VAD model...'); \
53
  torch.hub.load(repo_or_dir='snakers4/silero-vad', model='silero_vad', force_reload=False); \
54
- print('βœ… Silero VAD cached!')"
55
 
56
  # Copy application code LAST (after model downloads)
57
  # This way, code changes don't invalidate model cache layers
58
  COPY . .
59
 
 
 
 
60
  # Create uploads directory with proper permissions
61
  RUN mkdir -p uploads && chmod 777 uploads
62
 
 
20
 
21
  # Create cache directory for models BEFORE copying code
22
  # This ensures model downloads are cached even when code changes
23
+ RUN mkdir -p /.cache && chmod -R 777 /.cache
24
  ENV HF_HOME=/.cache
25
  ENV TORCH_HOME=/.cache
26
  ENV XDG_CACHE_HOME=/.cache
 
33
  print('πŸ“₯ Downloading Structure Model from HF Hub...'); \
34
  AutoTokenizer.from_pretrained('Cyberlace/swara-structure-model', cache_dir='/.cache'); \
35
  AutoModelForSequenceClassification.from_pretrained('Cyberlace/swara-structure-model', cache_dir='/.cache'); \
36
+ print('βœ… Structure Model cached!')" && chmod -R 777 /.cache
37
 
38
  # 2. Whisper will be downloaded on first use (lazy loading to avoid OOM during build)
39
  # RUN python -c "import whisper; \
 
45
  RUN python -c "from sentence_transformers import SentenceTransformer; \
46
  print('πŸ“₯ Downloading Sentence Transformer...'); \
47
  SentenceTransformer('paraphrase-multilingual-MiniLM-L12-v2', cache_folder='/.cache'); \
48
+ print('βœ… Sentence Transformer cached!')" && chmod -R 777 /.cache
49
 
50
  # 4. Download Silero VAD (~10MB)
51
  RUN python -c "import torch; \
52
  print('πŸ“₯ Downloading Silero VAD model...'); \
53
  torch.hub.load(repo_or_dir='snakers4/silero-vad', model='silero_vad', force_reload=False); \
54
+ print('βœ… Silero VAD cached!')" && chmod -R 777 /.cache
55
 
56
  # Copy application code LAST (after model downloads)
57
  # This way, code changes don't invalidate model cache layers
58
  COPY . .
59
 
60
+ # Fix all cache permissions after code copy (in case any new cache created)
61
+ RUN chmod -R 777 /.cache || true
62
+
63
  # Create uploads directory with proper permissions
64
  RUN mkdir -p uploads && chmod 777 uploads
65
 
start.sh CHANGED
@@ -4,6 +4,9 @@ echo "=========================================="
4
  echo "Starting Swara API Services"
5
  echo "=========================================="
6
 
 
 
 
7
  # Fix OpenMP warning - set proper thread count
8
  export OMP_NUM_THREADS=4
9
 
 
4
  echo "Starting Swara API Services"
5
  echo "=========================================="
6
 
7
+ # Fix cache permissions on startup (in case of permission issues)
8
+ chmod -R 777 /.cache 2>/dev/null || true
9
+
10
  # Fix OpenMP warning - set proper thread count
11
  export OMP_NUM_THREADS=4
12