ALYYAN commited on
Commit
0e8c893
·
verified ·
1 Parent(s): 9e440e5

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +14 -25
Dockerfile CHANGED
@@ -1,38 +1,27 @@
1
  # 1. Base Image
2
  FROM python:3.11-slim
3
 
4
- # 2. Set environment variables
5
  ENV PYTHONDONTWRITEBYTECODE 1
6
  ENV PYTHONUNBUFFERED 1
7
- ENV STREAMLIT_SERVER_HEADLESS=true
8
- # --- THE DEFINITIVE FIX IS HERE ---
9
- # Tell Hugging Face to use a cache directory INSIDE the user's home folder
10
- ENV HF_HOME=/home/user/.cache/huggingface
11
- # --- END FIX ---
12
 
13
- # 3. Install System Dependencies
14
  RUN apt-get update && apt-get install -y --no-install-recommends \
15
- git git-lfs libgl1 \
16
  && rm -rf /var/lib/apt/lists/*
17
 
18
- # 4. Create and switch to a non-root user
19
- RUN useradd -m -u 1000 user
20
- USER user
21
- WORKDIR /home/user/app
22
 
23
- # 5. Copy and install Python requirements
24
- COPY --chown=user:user requirements.txt packages.txt ./
25
- RUN pip install --no-cache-dir -r requirements.txt
26
-
27
- # 6. Pre-download the model's configuration files (as the correct user)
28
- # This is a small download and ensures the cache directory is created.
29
- RUN python -c "from transformers import AutoImageProcessor; AutoImageProcessor.from_pretrained('google/efficientnet-b2')"
30
 
31
- # 7. Copy application code and model artifacts
32
- COPY --chown=user:user . .
33
- RUN git lfs pull
34
 
35
- # 8. Expose port and run the app
36
  EXPOSE 8501
37
- HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
38
- ENTRYPOINT ["python", "-m", "streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0"]
 
 
1
  # 1. Base Image
2
  FROM python:3.11-slim
3
 
4
+ # 2. Set environment variables for a non-interactive server
5
  ENV PYTHONDONTWRITEBYTECODE 1
6
  ENV PYTHONUNBUFFERED 1
 
 
 
 
 
7
 
8
+ # 3. Install the single critical system dependency for OpenCV
9
  RUN apt-get update && apt-get install -y --no-install-recommends \
10
+ libgl1 \
11
  && rm -rf /var/lib/apt/lists/*
12
 
13
+ # 4. Set the working directory
14
+ WORKDIR /app
 
 
15
 
16
+ # 5. Copy ALL necessary files at once (respecting .dockerignore)
17
+ # This is the simplest and most robust way.
18
+ COPY . .
 
 
 
 
19
 
20
+ # 6. Install Python packages and immediately clean up the cache
21
+ RUN pip install --no-cache-dir -r requirements.txt
 
22
 
23
+ # 7. Expose the port
24
  EXPOSE 8501
25
+
26
+ # 8. Entrypoint to run the app
27
+ ENTRYPOINT ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0", "--server.enableCORS", "false"]