thelip commited on
Commit
6ea319c
·
verified ·
1 Parent(s): 888e1b2

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +15 -17
Dockerfile CHANGED
@@ -1,15 +1,18 @@
1
  # 1. Base Image: Use a slim Python image
2
  FROM python:3.10-slim
3
 
4
- # 2. Set Environment Variables (Optional but good practice)
5
- ENV PYTHONUNBUFFERED=1 \
6
- PIP_NO_CACHE_DIR=off \
7
- PIP_DISABLE_PIP_VERSION_CHECK=on \
8
- # Set path for Hugging Face model cache (inside the container)
9
- HF_HOME="/app/huggingface_cache" \
10
- TRANSFORMERS_CACHE="/app/huggingface_cache/transformers" # <-- REMOVED TRAILING BACKSLASH HERE
11
- # If you need to use a Hugging Face token (e.g., for gated models, though Gemma isn't)
12
- # HUGGING_FACE_HUB_TOKEN="your_hf_token_here" # Best to pass this at runtime or via secrets
 
 
 
13
 
14
  # 3. Set Working Directory
15
  WORKDIR /app
@@ -19,23 +22,18 @@ WORKDIR /app
19
  COPY requirements.txt .
20
  RUN apt-get update && apt-get install -y --no-install-recommends \
21
  build-essential \
22
- && rm -rf /var/lib/apt/lists/* # build-essential might be needed by some torch/scipy deps
23
  RUN pip install --no-cache-dir -r requirements.txt
24
 
25
  # 5. Copy the rest of the application code
26
  COPY app.py .
27
 
28
- # 6. Create the cache directory and set permissions (if needed)
29
- # The user running the pip install command will own the HF_HOME path.
30
- # If running as non-root later, ensure permissions.
31
  RUN mkdir -p $HF_HOME && chmod -R 777 $HF_HOME
32
- # Note: chmod 777 is very permissive, for production, use a more specific user/group.
33
- # For Hugging Face Spaces, this is generally fine.
34
 
35
  # 7. Expose the port the app runs on
36
  EXPOSE 8000
37
 
38
  # 8. Command to run the application
39
- # The model will be downloaded on the first run if not already cached.
40
- # For Hugging Face Spaces, this download happens during the build process.
41
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"]
 
1
  # 1. Base Image: Use a slim Python image
2
  FROM python:3.10-slim
3
 
4
+ # 2. Set Environment Variables
5
+ # General Python/PIP settings
6
+ ENV PYTHONUNBUFFERED=1
7
+ ENV PIP_NO_CACHE_DIR=off
8
+ ENV PIP_DISABLE_PIP_VERSION_CHECK=on
9
+
10
+ # Hugging Face cache settings
11
+ ENV HF_HOME="/app/huggingface_cache"
12
+ ENV TRANSFORMERS_CACHE="/app/huggingface_cache/transformers"
13
+
14
+ # Optional: For Hugging Face token (if needed for private models, Gemma is public)
15
+ # ENV HUGGING_FACE_HUB_TOKEN="your_hf_token_here" # Pass at runtime or via secrets
16
 
17
  # 3. Set Working Directory
18
  WORKDIR /app
 
22
  COPY requirements.txt .
23
  RUN apt-get update && apt-get install -y --no-install-recommends \
24
  build-essential \
25
+ && rm -rf /var/lib/apt/lists/*
26
  RUN pip install --no-cache-dir -r requirements.txt
27
 
28
  # 5. Copy the rest of the application code
29
  COPY app.py .
30
 
31
+ # 6. Create the cache directory and set permissions
 
 
32
  RUN mkdir -p $HF_HOME && chmod -R 777 $HF_HOME
33
+ # Note: chmod 777 is permissive; for production, consider a more specific user/group.
 
34
 
35
  # 7. Expose the port the app runs on
36
  EXPOSE 8000
37
 
38
  # 8. Command to run the application
 
 
39
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"]