Update Dockerfile
Browse files- Dockerfile +0 -37
Dockerfile
CHANGED
|
@@ -59,43 +59,6 @@ RUN mkdir -p ${MODELS_BASE_DIR}/llm \
|
|
| 59 |
# Download models using huggingface_hub directly during build
|
| 60 |
# This makes the image self-contained with default models
|
| 61 |
# Error handling added: Build continues but logs errors if download fails
|
| 62 |
-
RUN python -c "\
|
| 63 |
-
import os; \
|
| 64 |
-
from pathlib import Path; \
|
| 65 |
-
from huggingface_hub import hf_hub_download, HfHubHTTPError; \
|
| 66 |
-
import logging; \
|
| 67 |
-
logging.basicConfig(level=logging.INFO, format='%(levelname)s: %(message)s'); \
|
| 68 |
-
\
|
| 69 |
-
def download(repo, filename, target_dir_name): \
|
| 70 |
-
base = Path(os.environ['MODELS_BASE_DIR']); \
|
| 71 |
-
local_path = base / target_dir_name / filename; \
|
| 72 |
-
if local_path.exists(): \
|
| 73 |
-
logging.info(f'Model found: {local_path}'); \
|
| 74 |
-
return; \
|
| 75 |
-
logging.info(f'Downloading: {repo}/{filename} to {local_path.parent}'); \
|
| 76 |
-
try: \
|
| 77 |
-
local_path.parent.mkdir(parents=True, exist_ok=True); \
|
| 78 |
-
hf_hub_download( \
|
| 79 |
-
repo_id=repo, \
|
| 80 |
-
filename=filename, \
|
| 81 |
-
local_dir=local_path.parent, \
|
| 82 |
-
local_dir_use_symlinks=False, \
|
| 83 |
-
resume_download=True, \
|
| 84 |
-
etag_timeout=300 \
|
| 85 |
-
); \
|
| 86 |
-
downloaded_file = local_path.parent / filename; \
|
| 87 |
-
if downloaded_file.exists() and downloaded_file != local_path: os.rename(downloaded_file, local_path); \
|
| 88 |
-
if local_path.exists(): logging.info(f'Download complete: {local_path}'); \
|
| 89 |
-
else: logging.error(f'Download attempted but file missing: {local_path}'); \
|
| 90 |
-
except HfHubHTTPError as e: logging.error(f'HTTP error downloading {repo}/{filename}: {e}'); \
|
| 91 |
-
except Exception as e: logging.error(f'Error downloading {repo}/{filename}: {e}', exc_info=False); \
|
| 92 |
-
\
|
| 93 |
-
download(os.environ['LLM_MODEL_REPO'], os.environ['LLM_MODEL_FILE'], 'llm'); \
|
| 94 |
-
download(os.environ['SD_MODEL_REPO'], os.environ['SD_MODEL_FILE'], 'sd'); \
|
| 95 |
-
download(os.environ['SD_REFINER_MODEL_REPO'], os.environ['SD_REFINER_MODEL_FILE'], 'sd_refiner'); \
|
| 96 |
-
download(os.environ['WHISPER_MODEL_REPO'], os.environ['WHISPER_MODEL_FILE'], 'whisper'); \
|
| 97 |
-
download(os.environ['VIDEO_MODEL_REPO'], os.environ['VIDEO_MODEL_FILE'], 'video'); \
|
| 98 |
-
"
|
| 99 |
|
| 100 |
# Expose the port the app runs on
|
| 101 |
EXPOSE 7860
|
|
|
|
| 59 |
# Download models using huggingface_hub directly during build
|
| 60 |
# This makes the image self-contained with default models
|
| 61 |
# Error handling added: Build continues but logs errors if download fails
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
|
| 63 |
# Expose the port the app runs on
|
| 64 |
EXPOSE 7860
|