Update Dockerfile
Browse files- Dockerfile +9 -6
Dockerfile
CHANGED
@@ -6,31 +6,34 @@ FROM python:3.9-slim
|
|
6 |
# 2. Set working directory
|
7 |
WORKDIR /app
|
8 |
|
9 |
-
# 3.
|
|
|
|
|
|
|
10 |
ENV STREAMLIT_CONFIG_DIR=/app/.streamlit \
|
11 |
TRANSFORMERS_CACHE=/app/.cache/huggingface/hub \
|
12 |
HF_HOME=/app/.cache/huggingface \
|
13 |
XDG_CACHE_HOME=/app/.cache \
|
14 |
STREAMLIT_HOME=/app/.cache/streamlit
|
15 |
|
16 |
-
#
|
17 |
RUN mkdir -p /app/.streamlit \
|
18 |
&& mkdir -p /app/.cache/huggingface/hub \
|
19 |
&& mkdir -p /app/.cache/streamlit \
|
20 |
&& chmod -R 777 /app/.cache /app/.streamlit \
|
21 |
&& printf '[browser]\ngatherUsageStats = false\n\n[server]\nheadless = true\nenableCORS = false\nport = 8501\n' > /app/.streamlit/config.toml
|
22 |
|
23 |
-
#
|
24 |
COPY requirements.txt .
|
25 |
RUN pip install --no-cache-dir -r requirements.txt
|
26 |
|
27 |
-
#
|
28 |
COPY src/ ./src
|
29 |
|
30 |
-
#
|
31 |
EXPOSE 8501
|
32 |
|
33 |
-
#
|
34 |
CMD ["streamlit", "run", "src/app.py", \
|
35 |
"--server.port=8501", \
|
36 |
"--server.address=0.0.0.0"]
|
|
|
6 |
# 2. Set working directory
|
7 |
WORKDIR /app
|
8 |
|
9 |
+
# 3. Set HOME to /app to avoid writing to root
|
10 |
+
ENV HOME=/app
|
11 |
+
|
12 |
+
# 4. Environment variables for writable cache/config dirs
|
13 |
ENV STREAMLIT_CONFIG_DIR=/app/.streamlit \
|
14 |
TRANSFORMERS_CACHE=/app/.cache/huggingface/hub \
|
15 |
HF_HOME=/app/.cache/huggingface \
|
16 |
XDG_CACHE_HOME=/app/.cache \
|
17 |
STREAMLIT_HOME=/app/.cache/streamlit
|
18 |
|
19 |
+
# 5. Create directories with correct permissions and inject Streamlit config
|
20 |
RUN mkdir -p /app/.streamlit \
|
21 |
&& mkdir -p /app/.cache/huggingface/hub \
|
22 |
&& mkdir -p /app/.cache/streamlit \
|
23 |
&& chmod -R 777 /app/.cache /app/.streamlit \
|
24 |
&& printf '[browser]\ngatherUsageStats = false\n\n[server]\nheadless = true\nenableCORS = false\nport = 8501\n' > /app/.streamlit/config.toml
|
25 |
|
26 |
+
# 6. Copy in dependency file and install
|
27 |
COPY requirements.txt .
|
28 |
RUN pip install --no-cache-dir -r requirements.txt
|
29 |
|
30 |
+
# 7. Copy your source app code
|
31 |
COPY src/ ./src
|
32 |
|
33 |
+
# 8. Expose Streamlit default port
|
34 |
EXPOSE 8501
|
35 |
|
36 |
+
# 9. Launch Streamlit pointing to src/app.py
|
37 |
CMD ["streamlit", "run", "src/app.py", \
|
38 |
"--server.port=8501", \
|
39 |
"--server.address=0.0.0.0"]
|