Spaces:
Running
Running
fix netcat
Browse files- Dockerfile +29 -1
Dockerfile
CHANGED
|
@@ -11,7 +11,16 @@ WORKDIR $HOME
|
|
| 11 |
RUN mkdir -p $HOME/.ollama && chown -R ollama-user:ollama-user $HOME/.ollama
|
| 12 |
|
| 13 |
# Install netcat (nc) for checking server readiness
|
| 14 |
-
RUN apt-get update && apt-get install -y
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
# Set core environment variables
|
| 17 |
ENV HOME=/home/ollama-user
|
|
@@ -63,5 +72,24 @@ ENV OLLAMA_HOST=0.0.0.0:7860
|
|
| 63 |
# Expose the default port
|
| 64 |
EXPOSE 7860
|
| 65 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
# Use the custom entrypoint script
|
| 67 |
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
|
|
|
|
| 11 |
RUN mkdir -p $HOME/.ollama && chown -R ollama-user:ollama-user $HOME/.ollama
|
| 12 |
|
| 13 |
# Install netcat (nc) for checking server readiness
|
| 14 |
+
RUN apt-get update && apt-get install -y \
|
| 15 |
+
netcat-openbsd \
|
| 16 |
+
htop \
|
| 17 |
+
curl \
|
| 18 |
+
wget \
|
| 19 |
+
procps \
|
| 20 |
+
ca-certificates \
|
| 21 |
+
&& rm -rf /var/lib/apt/lists/* \
|
| 22 |
+
&& apt-get clean \
|
| 23 |
+
&& apt-get autoremove -y
|
| 24 |
|
| 25 |
# Set core environment variables
|
| 26 |
ENV HOME=/home/ollama-user
|
|
|
|
| 72 |
# Expose the default port
|
| 73 |
EXPOSE 7860
|
| 74 |
|
| 75 |
+
# Create health check script inline to reduce image layers
|
| 76 |
+
RUN echo '#!/bin/bash\n\
|
| 77 |
+
if ! nc -z localhost 7860 2>/dev/null; then\n\
|
| 78 |
+
echo "UNHEALTHY: Service not responding"\n\
|
| 79 |
+
exit 1\n\
|
| 80 |
+
fi\n\
|
| 81 |
+
if ! curl -sf --max-time 3 http://localhost:7860/api/version >/dev/null; then\n\
|
| 82 |
+
echo "UNHEALTHY: API not responding"\n\
|
| 83 |
+
exit 1\n\
|
| 84 |
+
fi\n\
|
| 85 |
+
echo "HEALTHY: Ollama running"\n\
|
| 86 |
+
exit 0' > /home/ollama-user/healthcheck.sh && \
|
| 87 |
+
chmod +x /home/ollama-user/healthcheck.sh
|
| 88 |
+
|
| 89 |
+
# Health check configuration
|
| 90 |
+
HEALTHCHECK --interval=60s --timeout=10s --start-period=120s --retries=3 \
|
| 91 |
+
CMD /home/ollama-user/healthcheck.sh
|
| 92 |
+
|
| 93 |
+
|
| 94 |
# Use the custom entrypoint script
|
| 95 |
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
|