mgbam commited on
Commit
b30b2b5
·
verified ·
1 Parent(s): 20eea62

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +12 -59
Dockerfile CHANGED
@@ -1,72 +1,25 @@
1
- # --------------------
2
- # Base image & metadata
3
- # --------------------
4
  FROM python:3.10-slim
5
 
6
- LABEL maintainer="Your Name <[email protected]>" \
7
- description="Streamlit app with spaCy, CPU-only, for Hugging Face Space"
8
-
9
- # --------------------
10
- # Environment variables
11
- # --------------------
12
- ENV PYTHONUNBUFFERED=1 \
13
- PIP_NO_CACHE_DIR=1 \
14
- PORT=7860 \
15
- HOME=/code \
16
- STREAMLIT_HOME=/code/.streamlit \
17
- STREAMLIT_SERVER_HEADLESS=true \
18
- STREAMLIT_SERVER_ENABLECORS=false \
19
- STREAMLIT_SERVER_ENABLEWEBRTC=false \
20
- STREAMLIT_SERVER_PORT=7860
21
-
22
- # --------------------
23
- # Working directory
24
- # --------------------
25
  WORKDIR /code
26
 
27
- # --------------------
28
- # System dependencies
29
- # --------------------
30
  RUN apt-get update \
31
- && apt-get install -y --no-install-recommends build-essential \
32
- && rm -rf /var/lib/apt/lists/*
33
 
34
- # --------------------
35
- # Python dependencies
36
- # --------------------
37
  COPY requirements.txt .
 
 
 
 
 
38
  RUN pip install --upgrade pip setuptools wheel \
39
- && pip install -r requirements.txt
40
 
41
- # --------------------
42
- # spaCy English model
43
- # --------------------
44
  RUN python -m spacy download en_core_web_sm
45
 
46
- # --------------------
47
- # Copy application code
48
- # --------------------
49
  COPY . .
50
 
51
- # --------------------
52
- # Expose port
53
- # --------------------
54
- EXPOSE 7860
55
-
56
- # --------------------
57
- # Create non-root user (optional but recommended)
58
- # --------------------
59
- ARG USER_UID=1000
60
- ARG USER_GID=1000
61
-
62
- RUN groupadd --gid "$USER_GID" appgroup \
63
- && useradd --uid "$USER_UID" --gid appgroup --shell /bin/false --no-create-home appuser \
64
- && chown -R appuser:appgroup /code
65
-
66
- USER appuser
67
-
68
- # --------------------
69
- # Entrypoint
70
- # --------------------
71
- ENTRYPOINT ["streamlit", "run", "app.py"]
72
- CMD ["--server.address=0.0.0.0", "--server.port=7860"]
 
 
 
 
1
  FROM python:3.10-slim
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  WORKDIR /code
4
 
5
+ # Install system deps
 
 
6
  RUN apt-get update \
7
+ && apt-get install -y --no-install-recommends build-essential gcc \
8
+ && rm -rf /var/lib/apt/lists/*
9
 
10
+ # Copy requirements and install
 
 
11
  COPY requirements.txt .
12
+
13
+ # First install NumPy alone to get the right ABI
14
+ RUN pip install --no-cache-dir numpy==1.24.4
15
+
16
+ # Now install everything else
17
  RUN pip install --upgrade pip setuptools wheel \
18
+ && pip install --no-cache-dir -r requirements.txt
19
 
20
+ # Finally download the spaCy model
 
 
21
  RUN python -m spacy download en_core_web_sm
22
 
 
 
 
23
  COPY . .
24
 
25
+ CMD ["streamlit", "run", "app.py", "--server.address=0.0.0.0", "--server.port=7860"]