Spaces:
Sleeping
Sleeping
Commit
·
9ba0e86
1
Parent(s):
9f5fcda
Update Dockerfile
Browse files- Dockerfile +19 -0
Dockerfile
CHANGED
@@ -5,6 +5,9 @@ FROM ubuntu:22.04
|
|
5 |
ENV DEBIAN_FRONTEND=noninteractive
|
6 |
ENV PYTHONUNBUFFERED=1
|
7 |
ENV PYTHONPATH=/app
|
|
|
|
|
|
|
8 |
|
9 |
# Install system dependencies
|
10 |
RUN apt-get update && apt-get install -y \
|
@@ -19,6 +22,16 @@ RUN apt-get update && apt-get install -y \
|
|
19 |
# Create symbolic link for python3
|
20 |
RUN ln -sf /usr/bin/python3.10 /usr/bin/python3
|
21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
# Install Ollama
|
23 |
RUN curl -fsSL https://ollama.com/install.sh | sh
|
24 |
|
@@ -34,6 +47,9 @@ RUN pip3 install --no-cache-dir -r requirements.txt
|
|
34 |
# Copy the application code
|
35 |
COPY . .
|
36 |
|
|
|
|
|
|
|
37 |
# Create a startup script
|
38 |
RUN echo '#!/bin/bash\n\
|
39 |
# Start Ollama in the background\n\
|
@@ -52,5 +68,8 @@ cd /app && uvicorn main:app --host 0.0.0.0 --port 8000\n\
|
|
52 |
# Expose ports
|
53 |
EXPOSE 8000 11434
|
54 |
|
|
|
|
|
|
|
55 |
# Set the entrypoint
|
56 |
ENTRYPOINT ["/app/start.sh"]
|
|
|
5 |
ENV DEBIAN_FRONTEND=noninteractive
|
6 |
ENV PYTHONUNBUFFERED=1
|
7 |
ENV PYTHONPATH=/app
|
8 |
+
ENV OLLAMA_HOST=0.0.0.0
|
9 |
+
ENV TRANSFORMERS_CACHE=/app/.cache/huggingface
|
10 |
+
ENV HF_HOME=/app/.cache/huggingface
|
11 |
|
12 |
# Install system dependencies
|
13 |
RUN apt-get update && apt-get install -y \
|
|
|
22 |
# Create symbolic link for python3
|
23 |
RUN ln -sf /usr/bin/python3.10 /usr/bin/python3
|
24 |
|
25 |
+
# Create a non-root user
|
26 |
+
RUN useradd -m -s /bin/bash appuser
|
27 |
+
|
28 |
+
# Create necessary directories with proper permissions
|
29 |
+
RUN mkdir -p /app/.cache/huggingface \
|
30 |
+
&& mkdir -p /app/.ollama \
|
31 |
+
&& chown -R appuser:appuser /app \
|
32 |
+
&& chown -R appuser:appuser /app/.cache \
|
33 |
+
&& chown -R appuser:appuser /app/.ollama
|
34 |
+
|
35 |
# Install Ollama
|
36 |
RUN curl -fsSL https://ollama.com/install.sh | sh
|
37 |
|
|
|
47 |
# Copy the application code
|
48 |
COPY . .
|
49 |
|
50 |
+
# Set proper ownership of all files
|
51 |
+
RUN chown -R appuser:appuser /app
|
52 |
+
|
53 |
# Create a startup script
|
54 |
RUN echo '#!/bin/bash\n\
|
55 |
# Start Ollama in the background\n\
|
|
|
68 |
# Expose ports
|
69 |
EXPOSE 8000 11434
|
70 |
|
71 |
+
# Switch to non-root user
|
72 |
+
USER appuser
|
73 |
+
|
74 |
# Set the entrypoint
|
75 |
ENTRYPOINT ["/app/start.sh"]
|