Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +32 -15
Dockerfile
CHANGED
@@ -1,23 +1,40 @@
|
|
1 |
-
# Use
|
2 |
-
FROM
|
3 |
|
4 |
-
|
|
|
|
|
|
|
|
|
5 |
|
6 |
-
#
|
7 |
-
RUN
|
8 |
|
9 |
-
|
10 |
-
|
11 |
|
12 |
-
#
|
13 |
-
|
|
|
14 |
|
15 |
-
|
16 |
-
|
17 |
|
18 |
-
|
|
|
19 |
|
20 |
-
#
|
21 |
-
|
|
|
22 |
|
23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Use a lightweight Python 3.11 image as the base.
|
2 |
+
FROM python:3.11-slim
|
3 |
|
4 |
+
# Update package lists, install curl, and run the Ollama installer script.
|
5 |
+
# This downloads and installs Ollama, then cleans up the package lists.
|
6 |
+
RUN apt-get update && apt-get install -y curl && \
|
7 |
+
curl -fsSL https://ollama.ai/install.sh | sh && \
|
8 |
+
apt-get clean && rm -rf /var/lib/apt/lists/*
|
9 |
|
10 |
+
# Create a non-root user (named "user" with UID 1000) for better security.
|
11 |
+
RUN useradd -m -u 1000 user
|
12 |
|
13 |
+
# Switch to the newly created user.
|
14 |
+
USER user
|
15 |
|
16 |
+
# Set environment variables:
|
17 |
+
ENV HOME=/home/user \
|
18 |
+
PATH="/home/user/.local/bin:$PATH"
|
19 |
|
20 |
+
# Create directories for your application and logs.
|
21 |
+
RUN mkdir -p $HOME/docker_ollama $HOME/logs
|
22 |
|
23 |
+
# Set the working directory to the application directory.
|
24 |
+
WORKDIR $HOME/docker_ollama
|
25 |
|
26 |
+
# Copy the requirements.txt file into the container and install Python dependencies.
|
27 |
+
COPY --chown=user requirements.txt .
|
28 |
+
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
29 |
|
30 |
+
# Copy the rest of your application code into the container.
|
31 |
+
COPY --chown=user . .
|
32 |
+
|
33 |
+
# Ensure the start script has executable permissions.
|
34 |
+
RUN chmod +x start.sh
|
35 |
+
|
36 |
+
# Expose the necessary ports:
|
37 |
+
EXPOSE 7860 11434
|
38 |
+
|
39 |
+
# Set the container's default command to run the start.sh script when the container launches.
|
40 |
+
CMD ["./start.sh"]
|