Update Dockerfile
Browse files- Dockerfile +10 -7
Dockerfile
CHANGED
@@ -29,30 +29,33 @@ RUN mkdir -p /app/.streamlit \
|
|
29 |
&& chmod -R 755 /app/.cache /app/.streamlit \
|
30 |
&& chown -R appuser:appuser /app
|
31 |
|
32 |
-
# 8.
|
|
|
|
|
|
|
33 |
COPY requirements.txt .
|
34 |
|
35 |
-
#
|
36 |
USER appuser
|
37 |
RUN pip install --no-cache-dir -r requirements.txt
|
38 |
|
39 |
-
#
|
40 |
COPY --chown=appuser:appuser src/ ./src
|
41 |
|
42 |
-
#
|
43 |
RUN if [ -f /app/src/.streamlit/config.toml ]; then \
|
44 |
mv /app/src/.streamlit/config.toml /app/.streamlit/config.toml && \
|
45 |
chmod 644 /app/.streamlit/config.toml; \
|
46 |
fi
|
47 |
|
48 |
-
#
|
49 |
EXPOSE 8501
|
50 |
|
51 |
-
#
|
52 |
HEALTHCHECK --interval=30s --timeout=3s \
|
53 |
CMD curl -f http://localhost:8501/healthz || exit 1
|
54 |
|
55 |
-
#
|
56 |
CMD ["/app/.local/bin/streamlit", "run", "src/app.py", \
|
57 |
"--server.port=8501", \
|
58 |
"--server.address=0.0.0.0"]
|
|
|
29 |
&& chmod -R 755 /app/.cache /app/.streamlit \
|
30 |
&& chown -R appuser:appuser /app
|
31 |
|
32 |
+
# 8. Upgrade pip
|
33 |
+
RUN pip install --upgrade pip
|
34 |
+
|
35 |
+
# 9. Copy requirements as root to ensure permissions
|
36 |
COPY requirements.txt .
|
37 |
|
38 |
+
# 10. Install dependencies as appuser
|
39 |
USER appuser
|
40 |
RUN pip install --no-cache-dir -r requirements.txt
|
41 |
|
42 |
+
# 11. Copy source code as appuser
|
43 |
COPY --chown=appuser:appuser src/ ./src
|
44 |
|
45 |
+
# 12. Move .streamlit/config.toml to the correct location with proper permissions
|
46 |
RUN if [ -f /app/src/.streamlit/config.toml ]; then \
|
47 |
mv /app/src/.streamlit/config.toml /app/.streamlit/config.toml && \
|
48 |
chmod 644 /app/.streamlit/config.toml; \
|
49 |
fi
|
50 |
|
51 |
+
# 13. Expose Streamlit default port
|
52 |
EXPOSE 8501
|
53 |
|
54 |
+
# 14. Healthcheck to verify app is running
|
55 |
HEALTHCHECK --interval=30s --timeout=3s \
|
56 |
CMD curl -f http://localhost:8501/healthz || exit 1
|
57 |
|
58 |
+
# 15. Launch Streamlit pointing to src/app.py
|
59 |
CMD ["/app/.local/bin/streamlit", "run", "src/app.py", \
|
60 |
"--server.port=8501", \
|
61 |
"--server.address=0.0.0.0"]
|