mgbam commited on
Commit
f16d0f1
·
verified ·
1 Parent(s): ba02d68

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +43 -14
Dockerfile CHANGED
@@ -1,23 +1,52 @@
1
- # Use an official Python base image
2
- FROM python:3.10-slim
 
 
 
 
 
 
 
3
 
4
- # Install system dependencies
5
  RUN apt-get update && \
6
- apt-get install -y build-essential libglib2.0-0 libsm6 libxrender1 libxext6 && \
 
 
 
 
 
 
7
  rm -rf /var/lib/apt/lists/*
8
 
9
- # Set workdir
 
 
 
 
 
 
 
10
  WORKDIR /app
11
 
12
- # Copy your code
13
- COPY . /app
 
 
 
 
 
 
 
 
 
 
 
14
 
15
- # Install Python dependencies
16
- RUN pip install --no-cache-dir --upgrade pip
17
- RUN pip install --no-cache-dir -r requirements.txt
 
18
 
19
- # Expose the port Streamlit uses
20
- EXPOSE 7860
21
 
22
- # Command to run your app
23
- CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0"]
 
1
+ # Dockerfile
2
+
3
+ # Stage 1: build dependencies and spaCy model
4
+ FROM python:3.10-slim as builder
5
+
6
+ ENV PYTHONUNBUFFERED=1 \
7
+ PYTHONDONTWRITEBYTECODE=1
8
+
9
+ WORKDIR /app
10
 
 
11
  RUN apt-get update && \
12
+ apt-get install -y --no-install-recommends \
13
+ build-essential \
14
+ libglib2.0-0 \
15
+ libsm6 \
16
+ libxrender1 \
17
+ libxext6 \
18
+ curl && \
19
  rm -rf /var/lib/apt/lists/*
20
 
21
+ COPY requirements.txt .
22
+ RUN pip install --upgrade pip && \
23
+ pip install --no-cache-dir -r requirements.txt && \
24
+ python -m spacy download en_core_web_sm
25
+
26
+ # Stage 2: final slim image
27
+ FROM python:3.10-slim
28
+
29
  WORKDIR /app
30
 
31
+ RUN apt-get update && \
32
+ apt-get install -y --no-install-recommends \
33
+ libglib2.0-0 \
34
+ libsm6 \
35
+ libxrender1 \
36
+ libxext6 \
37
+ curl && \
38
+ rm -rf /var/lib/apt/lists/*
39
+
40
+ COPY --from=builder /usr/local/lib/python3.10/site-packages /usr/local/lib/python3.10/site-packages
41
+ COPY --from=builder /usr/local/bin /usr/local/bin
42
+
43
+ COPY . .
44
 
45
+ RUN groupadd -r appuser && \
46
+ useradd -r -g appuser appuser && \
47
+ chown -R appuser:appuser /app
48
+ USER appuser
49
 
50
+ EXPOSE 8501
 
51
 
52
+ ENTRYPOINT ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0"]