Spaces:
Build error
Build error
Update Dockerfile
Browse files- Dockerfile +40 -34
Dockerfile
CHANGED
@@ -1,34 +1,40 @@
|
|
1 |
-
# Use Ubuntu as the base image
|
2 |
-
FROM ubuntu:22.04
|
3 |
-
|
4 |
-
# Set the working directory in the container
|
5 |
-
WORKDIR /app
|
6 |
-
|
7 |
-
# Install system dependencies and Python
|
8 |
-
RUN apt-get update && apt-get install -y \
|
9 |
-
python3 \
|
10 |
-
python3-pip \
|
11 |
-
curl \
|
12 |
-
&& rm -rf /var/lib/apt/lists/*
|
13 |
-
|
14 |
-
# Set Python3 as the default
|
15 |
-
RUN ln -s /usr/bin/python3 /usr/bin/python
|
16 |
-
|
17 |
-
# Copy the requirements file and install dependencies
|
18 |
-
COPY requirements.txt ./
|
19 |
-
RUN pip install --no-cache-dir -r requirements.txt
|
20 |
-
|
21 |
-
# Install Ollama
|
22 |
-
RUN curl -fsSL https://ollama.com/install.sh | bash
|
23 |
-
|
24 |
-
# Ensure Ollama is in the system path
|
25 |
-
ENV PATH="/root/.ollama/bin:$PATH"
|
26 |
-
|
27 |
-
#
|
28 |
-
|
29 |
-
|
30 |
-
#
|
31 |
-
|
32 |
-
|
33 |
-
#
|
34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Use Ubuntu as the base image
|
2 |
+
FROM ubuntu:22.04
|
3 |
+
|
4 |
+
# Set the working directory in the container
|
5 |
+
WORKDIR /app
|
6 |
+
|
7 |
+
# Install system dependencies and Python
|
8 |
+
RUN apt-get update && apt-get install -y \
|
9 |
+
python3 \
|
10 |
+
python3-pip \
|
11 |
+
curl \
|
12 |
+
&& rm -rf /var/lib/apt/lists/*
|
13 |
+
|
14 |
+
# Set Python3 as the default
|
15 |
+
RUN ln -s /usr/bin/python3 /usr/bin/python
|
16 |
+
|
17 |
+
# Copy the requirements file and install dependencies
|
18 |
+
COPY requirements.txt ./
|
19 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
20 |
+
|
21 |
+
# Install Ollama
|
22 |
+
RUN curl -fsSL https://ollama.com/install.sh | bash
|
23 |
+
|
24 |
+
# Ensure Ollama is in the system path
|
25 |
+
ENV PATH="/root/.ollama/bin:$PATH"
|
26 |
+
|
27 |
+
# Set Ollama's home directory to a writable location
|
28 |
+
ENV OLLAMA_HOME="/app/.ollama"
|
29 |
+
|
30 |
+
# Create the directory with proper permissions
|
31 |
+
RUN mkdir -p $OLLAMA_HOME && chmod -R 777 $OLLAMA_HOME
|
32 |
+
|
33 |
+
# Copy the application files
|
34 |
+
COPY . .
|
35 |
+
|
36 |
+
# Expose the FastAPI default port
|
37 |
+
EXPOSE 8000
|
38 |
+
|
39 |
+
# Start Ollama, pull Llama3 if not present, then start FastAPI
|
40 |
+
CMD ["sh", "-c", "ollama serve & sleep 5 && ollama pull llama3 && uvicorn main:app --host 0.0.0.0 --port 8000"]
|