Spaces:
Sleeping
Sleeping
Commit
·
4dc1e6c
1
Parent(s):
95c4487
Refactor Dockerfile and start script: fix user ID assignment, enhance Ollama directory setup, and improve debug information
Browse files- Dockerfile +6 -4
- start.sh +13 -0
Dockerfile
CHANGED
@@ -10,7 +10,7 @@ RUN apt-get update && apt-get install -y \
|
|
10 |
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
11 |
|
12 |
# Create non-root user for security
|
13 |
-
RUN groupadd -r appuser && useradd -r -g appuser -m appuser
|
14 |
|
15 |
# Set working directory
|
16 |
WORKDIR /app
|
@@ -26,7 +26,9 @@ COPY start.sh .
|
|
26 |
RUN chmod +x start.sh
|
27 |
|
28 |
# Create Ollama directory and set permissions
|
29 |
-
RUN mkdir -p /home/appuser/.ollama &&
|
|
|
|
|
30 |
|
31 |
# Change ownership to non-root user
|
32 |
RUN chown -R appuser:appuser /app
|
@@ -35,6 +37,7 @@ RUN chown -R appuser:appuser /app
|
|
35 |
ENV OLLAMA_HOST=0.0.0.0:11434
|
36 |
ENV OLLAMA_ORIGINS=*
|
37 |
ENV HOME=/home/appuser
|
|
|
38 |
|
39 |
# Expose ports
|
40 |
EXPOSE 7860
|
@@ -44,5 +47,4 @@ EXPOSE 11434
|
|
44 |
USER appuser
|
45 |
|
46 |
# Start both Ollama and FastAPI
|
47 |
-
|
48 |
-
CMD ["bash", "/app/start.sh"]
|
|
|
10 |
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
11 |
|
12 |
# Create non-root user for security
|
13 |
+
RUN groupadd -r appuser && useradd -r -g appuser -m -u 1000 appuser
|
14 |
|
15 |
# Set working directory
|
16 |
WORKDIR /app
|
|
|
26 |
RUN chmod +x start.sh
|
27 |
|
28 |
# Create Ollama directory and set permissions
|
29 |
+
RUN mkdir -p /home/appuser/.ollama && \
|
30 |
+
chown -R appuser:appuser /home/appuser/.ollama && \
|
31 |
+
chmod -R 755 /home/appuser/.ollama
|
32 |
|
33 |
# Change ownership to non-root user
|
34 |
RUN chown -R appuser:appuser /app
|
|
|
37 |
ENV OLLAMA_HOST=0.0.0.0:11434
|
38 |
ENV OLLAMA_ORIGINS=*
|
39 |
ENV HOME=/home/appuser
|
40 |
+
ENV OLLAMA_HOME=/home/appuser/.ollama
|
41 |
|
42 |
# Expose ports
|
43 |
EXPOSE 7860
|
|
|
47 |
USER appuser
|
48 |
|
49 |
# Start both Ollama and FastAPI
|
50 |
+
CMD ["/app/start.sh"]
|
|
start.sh
CHANGED
@@ -3,14 +3,27 @@
|
|
3 |
# Debug information
|
4 |
echo "=== Debug Information ==="
|
5 |
echo "Current user: $(whoami)"
|
|
|
6 |
echo "Current directory: $(pwd)"
|
7 |
echo "Home directory: $HOME"
|
8 |
echo "Ollama home: $OLLAMA_HOME"
|
9 |
echo "PATH: $PATH"
|
10 |
echo "Which ollama: $(which ollama)"
|
11 |
echo "Ollama version: $(ollama --version 2>&1 || echo 'Failed to get version')"
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
echo "========================="
|
13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
# Start Ollama server in background
|
15 |
echo "Starting Ollama server..."
|
16 |
|
|
|
3 |
# Debug information
|
4 |
echo "=== Debug Information ==="
|
5 |
echo "Current user: $(whoami)"
|
6 |
+
echo "User ID: $(id)"
|
7 |
echo "Current directory: $(pwd)"
|
8 |
echo "Home directory: $HOME"
|
9 |
echo "Ollama home: $OLLAMA_HOME"
|
10 |
echo "PATH: $PATH"
|
11 |
echo "Which ollama: $(which ollama)"
|
12 |
echo "Ollama version: $(ollama --version 2>&1 || echo 'Failed to get version')"
|
13 |
+
|
14 |
+
# Check Ollama directory permissions
|
15 |
+
echo "Checking Ollama directory:"
|
16 |
+
ls -la $HOME/.ollama/ 2>/dev/null || echo "Ollama directory doesn't exist"
|
17 |
+
echo "Checking if we can write to Ollama directory:"
|
18 |
+
touch $HOME/.ollama/test_write 2>/dev/null && rm $HOME/.ollama/test_write && echo "Write test: SUCCESS" || echo "Write test: FAILED"
|
19 |
echo "========================="
|
20 |
|
21 |
+
# Ensure Ollama directory exists and has correct permissions
|
22 |
+
echo "Setting up Ollama directory..."
|
23 |
+
mkdir -p $HOME/.ollama
|
24 |
+
chmod 755 $HOME/.ollama
|
25 |
+
echo "Ollama directory setup complete."
|
26 |
+
|
27 |
# Start Ollama server in background
|
28 |
echo "Starting Ollama server..."
|
29 |
|