mgbam commited on
Commit
0ca81fc
·
verified ·
1 Parent(s): 4232e86

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +50 -10
Dockerfile CHANGED
@@ -1,32 +1,72 @@
 
 
 
1
  FROM python:3.10-slim
2
 
 
 
 
 
 
 
3
  ENV PYTHONUNBUFFERED=1 \
4
  PIP_NO_CACHE_DIR=1 \
5
  PORT=7860 \
6
  HOME=/code \
7
  STREAMLIT_HOME=/code/.streamlit \
8
- STREAMLIT_SERVER_PORT=7860 \
9
  STREAMLIT_SERVER_HEADLESS=true \
10
  STREAMLIT_SERVER_ENABLECORS=false \
11
- STREAMLIT_SERVER_ENABLEWEBRTC=false
 
12
 
 
 
 
13
  WORKDIR /code
14
 
15
- RUN apt-get update && \
16
- apt-get install -y --no-install-recommends \
17
- build-essential \
 
 
18
  && rm -rf /var/lib/apt/lists/*
19
 
 
 
 
20
  COPY requirements.txt .
21
- RUN pip install --upgrade pip setuptools wheel && \
22
- pip install -r requirements.txt
23
 
24
- # Install spaCy small model at build time
 
 
25
  RUN python -m spacy download en_core_web_sm
26
 
 
 
 
27
  COPY . .
28
 
 
 
 
29
  EXPOSE 7860
30
 
31
- CMD ["streamlit", "run", "app.py",
32
- "--server.address=0.0.0.0", "--server.port=7860"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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"]