Update Dockerfile
Browse files- Dockerfile +23 -46
Dockerfile
CHANGED
@@ -1,53 +1,30 @@
|
|
1 |
-
|
2 |
-
# 1 ─ Base image & build‑tools
|
3 |
-
############################################################
|
4 |
FROM python:3.10-slim
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
|
|
|
|
|
9 |
|
|
|
|
|
|
|
|
|
10 |
WORKDIR /app
|
11 |
|
12 |
-
|
13 |
-
# 2 ─ Copy dependency manifests
|
14 |
-
############################################################
|
15 |
-
# requirements.txt must already live at repo root
|
16 |
COPY requirements.txt .
|
17 |
|
18 |
-
#
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
# a future transitive dep overrides them.
|
31 |
-
RUN pip install --no-cache-dir --force-reinstall "numpy==1.23.5" "scipy<1.11"
|
32 |
-
|
33 |
-
############################################################
|
34 |
-
# 4 ─ Copy application source code
|
35 |
-
############################################################
|
36 |
-
COPY . /app
|
37 |
-
|
38 |
-
############################################################
|
39 |
-
# 5 ─ Validate wheels & fetch minimal spaCy model
|
40 |
-
############################################################
|
41 |
-
RUN python -m spacy validate && \
|
42 |
-
python -m spacy download en_core_web_sm
|
43 |
-
|
44 |
-
############################################################
|
45 |
-
# 6 ─ Expose the correct port & start Streamlit
|
46 |
-
############################################################
|
47 |
-
ENV PORT=7860
|
48 |
-
EXPOSE 7860
|
49 |
-
|
50 |
-
CMD streamlit run app.py \
|
51 |
-
--server.headless=true \
|
52 |
-
--server.address=0.0.0.0 \
|
53 |
-
--server.port=$PORT
|
|
|
1 |
+
# Use the official Python 3.10 slim image as the base
|
|
|
|
|
2 |
FROM python:3.10-slim
|
3 |
|
4 |
+
# Set environment variables to ensure consistent behavior
|
5 |
+
ENV PYTHONUNBUFFERED=1 \
|
6 |
+
STREAMLIT_BROWSER_GATHER_USAGE_STATS=false \
|
7 |
+
STREAMLIT_SERVER_HEADLESS=true \
|
8 |
+
STREAMLIT_HOME=/tmp/.streamlit
|
9 |
|
10 |
+
# Create the .streamlit directory with appropriate permissions
|
11 |
+
RUN mkdir -p $STREAMLIT_HOME && chmod -R 755 $STREAMLIT_HOME
|
12 |
+
|
13 |
+
# Set the working directory in the container
|
14 |
WORKDIR /app
|
15 |
|
16 |
+
# Copy only the requirements file first to leverage Docker cache
|
|
|
|
|
|
|
17 |
COPY requirements.txt .
|
18 |
|
19 |
+
# Install Python dependencies
|
20 |
+
RUN pip install --no-cache-dir --upgrade pip \
|
21 |
+
&& pip install --no-cache-dir -r requirements.txt
|
22 |
+
|
23 |
+
# Copy the rest of the application code
|
24 |
+
COPY . .
|
25 |
+
|
26 |
+
# Expose the port Streamlit will run on
|
27 |
+
EXPOSE 8501
|
28 |
+
|
29 |
+
# Define the command to run the Streamlit app
|
30 |
+
CMD ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|