Spaces:
Paused
Paused
Update DockerFile to Avoid Having a Second Port
Browse files- Dockerfile +44 -67
Dockerfile
CHANGED
|
@@ -1,67 +1,44 @@
|
|
| 1 |
-
FROM python:3.12.11-slim
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
WORKDIR /app
|
| 9 |
-
|
| 10 |
-
#
|
| 11 |
-
RUN apt-get update && \
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
#
|
| 21 |
-
COPY
|
| 22 |
-
|
| 23 |
-
#
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
#
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
stderr_logfile=/var/log/supervisor/realtime_server.err.log
|
| 46 |
-
stdout_logfile=/var/log/supervisor/realtime_server.out.log
|
| 47 |
-
priority=100
|
| 48 |
-
|
| 49 |
-
[program:streamlit]
|
| 50 |
-
command=streamlit run app.py --server.port=7860 --server.address=0.0.0.0 --server.enableXsrfProtection=false --server.enableCORS=false
|
| 51 |
-
directory=/app
|
| 52 |
-
autostart=true
|
| 53 |
-
autorestart=true
|
| 54 |
-
stderr_logfile=/var/log/supervisor/streamlit.err.log
|
| 55 |
-
stdout_logfile=/var/log/supervisor/streamlit.out.log
|
| 56 |
-
priority=200
|
| 57 |
-
EOF
|
| 58 |
-
|
| 59 |
-
# Expose both ports (Streamlit on 7860, Realtime API on 7861)
|
| 60 |
-
EXPOSE 7860 7861
|
| 61 |
-
|
| 62 |
-
# Health check for both services
|
| 63 |
-
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
|
| 64 |
-
CMD curl --fail http://localhost:7860/_stcore/health && curl --fail http://localhost:7861/health || exit 1
|
| 65 |
-
|
| 66 |
-
# Use supervisor to run both services
|
| 67 |
-
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
|
|
|
|
| 1 |
+
FROM python:3.12.11-slim
|
| 2 |
+
|
| 3 |
+
ENV PYTHONUNBUFFERED=1 \
|
| 4 |
+
PYTHONDONTWRITEBYTECODE=1 \
|
| 5 |
+
PIP_NO_CACHE_DIR=1 \
|
| 6 |
+
DEBIAN_FRONTEND=noninteractive
|
| 7 |
+
|
| 8 |
+
WORKDIR /app
|
| 9 |
+
|
| 10 |
+
# System deps
|
| 11 |
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 12 |
+
build-essential curl git libgomp1 supervisor nginx \
|
| 13 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 14 |
+
|
| 15 |
+
# Requirements first (better caching)
|
| 16 |
+
COPY requirements.txt .
|
| 17 |
+
RUN python -m pip install --upgrade pip \
|
| 18 |
+
&& pip install -r requirements.txt
|
| 19 |
+
|
| 20 |
+
# App source
|
| 21 |
+
COPY . .
|
| 22 |
+
|
| 23 |
+
# Nginx + Supervisor configs
|
| 24 |
+
COPY nginx.conf /etc/nginx/nginx.conf
|
| 25 |
+
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
|
| 26 |
+
|
| 27 |
+
# Needed dirs
|
| 28 |
+
RUN mkdir -p /app/data /app/embeddings /app/graph /app/metadata \
|
| 29 |
+
/var/log/supervisor /run
|
| 30 |
+
|
| 31 |
+
# (Optional) Drop root
|
| 32 |
+
RUN useradd -m -u 1000 appuser \
|
| 33 |
+
&& chown -R appuser:appuser /app /var/log/supervisor /run
|
| 34 |
+
USER appuser
|
| 35 |
+
|
| 36 |
+
# HF Spaces proxies this port
|
| 37 |
+
EXPOSE 7860
|
| 38 |
+
|
| 39 |
+
# Healthcheck hits Streamlit through Nginx (public path) and API via path
|
| 40 |
+
HEALTHCHECK --interval=30s --timeout=10s --start-period=90s --retries=3 \
|
| 41 |
+
CMD curl -fsS http://localhost:7860/_stcore/health >/dev/null \
|
| 42 |
+
&& curl -fsS http://localhost:7860/api/health >/dev/null || exit 1
|
| 43 |
+
|
| 44 |
+
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|