File size: 1,055 Bytes
6acaae5
 
936cdc4
5506c9f
936cdc4
 
5506c9f
 
936cdc4
5506c9f
6acaae5
 
5506c9f
72ac111
 
5506c9f
6acaae5
72ac111
5506c9f
6acaae5
 
 
72ac111
5506c9f
936cdc4
 
6acaae5
936cdc4
 
5506c9f
72ac111
 
5506c9f
6acaae5
 
72ac111
5506c9f
936cdc4
 
5506c9f
936cdc4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# Use a base Ubuntu image
FROM ubuntu:22.04

# Set environment variables to prevent interactive prompts
ENV DEBIAN_FRONTEND=noninteractive

# Install system dependencies: curl for Ollama, python3 and pip for the app
RUN apt update && apt install -y curl python3 python3-pip

# Create a non-root user to solve the Gradio permission error
RUN useradd -m -u 1000 user

# Install Ollama using its official installation script (as root)
RUN curl -fsSL https://ollama.com/install.sh | sh

# Set the working directory
WORKDIR /app

# Copy only the necessary application files with correct ownership
COPY --chown=user app.py .
COPY --chown=user requirements.txt .
COPY --chown=user run.sh .

# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt

# Make the startup script executable
RUN chmod +x run.sh

# Switch to the non-root user
USER user

# Set home environment for the user
ENV HOME=/home/user \
	PATH=/home/user/.local/bin:$PATH

# Expose the Gradio port
EXPOSE 7860

# Set the entrypoint to our startup script
CMD ["./run.sh"]