Spaces:
Running
Running
fix use root user
Browse files- Dockerfile +4 -14
Dockerfile
CHANGED
|
@@ -1,14 +1,7 @@
|
|
| 1 |
FROM ollama/ollama:latest
|
| 2 |
|
| 3 |
-
# Create a user and set up permissions
|
| 4 |
-
RUN useradd -ms /bin/bash ollama-user
|
| 5 |
|
| 6 |
-
# Set the home directory
|
| 7 |
-
ENV HOME=/home/ollama-user
|
| 8 |
-
WORKDIR $HOME
|
| 9 |
|
| 10 |
-
# Ensure the user has access to the directory
|
| 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 \
|
|
@@ -23,7 +16,6 @@ RUN apt-get update && apt-get install -y \
|
|
| 23 |
&& apt-get autoremove -y
|
| 24 |
|
| 25 |
# Set core environment variables
|
| 26 |
-
ENV HOME=/home/ollama-user
|
| 27 |
ENV OLLAMA_HOST=0.0.0.0:7860
|
| 28 |
ENV OLLAMA_ORIGINS="*"
|
| 29 |
ENV OLLAMA_MODELS=/tmp/ollama-models
|
|
@@ -63,8 +55,6 @@ COPY entrypoint.sh /usr/local/bin/entrypoint.sh
|
|
| 63 |
# Set permissions for the entrypoint script
|
| 64 |
RUN chmod +x /usr/local/bin/entrypoint.sh
|
| 65 |
|
| 66 |
-
# Switch to the non-root user
|
| 67 |
-
USER ollama-user
|
| 68 |
|
| 69 |
# Set Ollama to listen on all network interfaces
|
| 70 |
ENV OLLAMA_HOST=0.0.0.0:7860
|
|
@@ -83,13 +73,13 @@ if ! curl -sf --max-time 3 http://localhost:7860/api/version >/dev/null; then\n\
|
|
| 83 |
exit 1\n\
|
| 84 |
fi\n\
|
| 85 |
echo "HEALTHY: Ollama running"\n\
|
| 86 |
-
exit 0' > /
|
| 87 |
-
chmod +x /
|
| 88 |
|
| 89 |
# Health check configuration
|
| 90 |
HEALTHCHECK --interval=60s --timeout=10s --start-period=120s --retries=3 \
|
| 91 |
-
CMD /
|
| 92 |
-
|
| 93 |
|
| 94 |
# Use the custom entrypoint script
|
| 95 |
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
|
|
|
|
| 1 |
FROM ollama/ollama:latest
|
| 2 |
|
|
|
|
|
|
|
| 3 |
|
|
|
|
|
|
|
|
|
|
| 4 |
|
|
|
|
|
|
|
| 5 |
|
| 6 |
# Install netcat (nc) for checking server readiness
|
| 7 |
RUN apt-get update && apt-get install -y \
|
|
|
|
| 16 |
&& apt-get autoremove -y
|
| 17 |
|
| 18 |
# Set core environment variables
|
|
|
|
| 19 |
ENV OLLAMA_HOST=0.0.0.0:7860
|
| 20 |
ENV OLLAMA_ORIGINS="*"
|
| 21 |
ENV OLLAMA_MODELS=/tmp/ollama-models
|
|
|
|
| 55 |
# Set permissions for the entrypoint script
|
| 56 |
RUN chmod +x /usr/local/bin/entrypoint.sh
|
| 57 |
|
|
|
|
|
|
|
| 58 |
|
| 59 |
# Set Ollama to listen on all network interfaces
|
| 60 |
ENV OLLAMA_HOST=0.0.0.0:7860
|
|
|
|
| 73 |
exit 1\n\
|
| 74 |
fi\n\
|
| 75 |
echo "HEALTHY: Ollama running"\n\
|
| 76 |
+
exit 0' > /healthcheck.sh && \
|
| 77 |
+
chmod +x /healthcheck.sh
|
| 78 |
|
| 79 |
# Health check configuration
|
| 80 |
HEALTHCHECK --interval=60s --timeout=10s --start-period=120s --retries=3 \
|
| 81 |
+
CMD /healthcheck.sh
|
| 82 |
+
|
| 83 |
|
| 84 |
# Use the custom entrypoint script
|
| 85 |
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
|