File size: 1,309 Bytes
5d32fba
 
ea32f3a
5d32fba
 
 
 
 
ea32f3a
5d32fba
 
535d5e0
5d32fba
 
535d5e0
5d32fba
 
 
ea32f3a
5d32fba
 
ea32f3a
5d32fba
 
501bd4b
5d32fba
 
 
ea32f3a
5d32fba
 
 
 
 
 
 
 
 
 
 
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 lightweight Python 3.11 image as the base.
FROM python:3.11-slim

# Update package lists, install curl, and run the Ollama installer script.
# This downloads and installs Ollama, then cleans up the package lists.
RUN apt-get update && apt-get install -y curl && \
    curl -fsSL https://ollama.ai/install.sh | sh && \
    apt-get clean && rm -rf /var/lib/apt/lists/*

# Create a non-root user (named "user" with UID 1000) for better security.
RUN useradd -m -u 1000 user

# Switch to the newly created user.
USER user

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

# Create directories for your application and logs.
RUN mkdir -p $HOME/docker_ollama $HOME/logs

# Set the working directory to the application directory.
WORKDIR $HOME/docker_ollama

# Copy the requirements.txt file into the container and install Python dependencies.
COPY --chown=user requirements.txt .
RUN pip install --no-cache-dir --upgrade -r requirements.txt

# Copy the rest of your application code into the container.
COPY --chown=user . .

# Ensure the start script has executable permissions.
RUN chmod +x start.sh

# Expose the necessary ports:
EXPOSE 7860 11434

# Set the container's default command to run the start.sh script when the container launches.
CMD ["./start.sh"]