Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +28 -15
Dockerfile
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
#
|
2 |
FROM ubuntu:18.04
|
3 |
|
4 |
# Set environment variables
|
@@ -6,8 +6,10 @@ ENV NB_USER jovyan
|
|
6 |
ENV NB_UID 1000
|
7 |
ENV HOME /home/${NB_USER}
|
8 |
ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64/
|
|
|
|
|
9 |
|
10 |
-
# Install required packages
|
11 |
RUN apt-get update && apt-get install -y \
|
12 |
tar \
|
13 |
wget \
|
@@ -28,6 +30,8 @@ RUN apt-get update && apt-get install -y \
|
|
28 |
openjdk-8-jdk \
|
29 |
ant \
|
30 |
ca-certificates-java \
|
|
|
|
|
31 |
&& apt-get clean \
|
32 |
&& update-ca-certificates -f
|
33 |
|
@@ -40,6 +44,10 @@ RUN add-apt-repository ppa:deadsnakes/ppa \
|
|
40 |
# Set up JAVA_HOME
|
41 |
RUN echo "export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/" >> /etc/profile \
|
42 |
&& echo "export PATH=\$JAVA_HOME/bin:\$PATH" >> /etc/profile
|
|
|
|
|
|
|
|
|
43 |
# Create a new user named "jovyan" with user ID 1000
|
44 |
RUN useradd -m -u ${NB_UID} ${NB_USER}
|
45 |
|
@@ -50,23 +58,28 @@ USER ${NB_USER}
|
|
50 |
ENV HOME=/home/${NB_USER} \
|
51 |
PATH=/home/${NB_USER}/.local/bin:$PATH
|
52 |
|
53 |
-
# Set up PySpark to use Python 3.8 for both driver and workers
|
54 |
-
ENV PYSPARK_PYTHON=/usr/bin/python3.8
|
55 |
-
ENV PYSPARK_DRIVER_PYTHON=/usr/bin/python3.8
|
56 |
-
|
57 |
-
# Set the working directory to the user's home directory
|
58 |
-
WORKDIR ${HOME}
|
59 |
-
|
60 |
# Upgrade pip and install Python dependencies
|
61 |
RUN python3.8 -m pip install --upgrade pip
|
|
|
|
|
62 |
COPY requirements.txt /tmp/requirements.txt
|
63 |
RUN python3.8 -m pip install -r /tmp/requirements.txt
|
64 |
|
65 |
-
#
|
66 |
-
|
|
|
|
|
|
|
|
|
67 |
|
68 |
-
#
|
69 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
|
71 |
-
#
|
72 |
-
|
|
|
1 |
+
# Base image: Start with Ubuntu 18.04
|
2 |
FROM ubuntu:18.04
|
3 |
|
4 |
# Set environment variables
|
|
|
6 |
ENV NB_UID 1000
|
7 |
ENV HOME /home/${NB_USER}
|
8 |
ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64/
|
9 |
+
ENV PYSPARK_PYTHON=/usr/bin/python3.8
|
10 |
+
ENV PYSPARK_DRIVER_PYTHON=/usr/bin/python3.8
|
11 |
|
12 |
+
# Install required packages and dependencies
|
13 |
RUN apt-get update && apt-get install -y \
|
14 |
tar \
|
15 |
wget \
|
|
|
30 |
openjdk-8-jdk \
|
31 |
ant \
|
32 |
ca-certificates-java \
|
33 |
+
curl \
|
34 |
+
git \
|
35 |
&& apt-get clean \
|
36 |
&& update-ca-certificates -f
|
37 |
|
|
|
44 |
# Set up JAVA_HOME
|
45 |
RUN echo "export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/" >> /etc/profile \
|
46 |
&& echo "export PATH=\$JAVA_HOME/bin:\$PATH" >> /etc/profile
|
47 |
+
|
48 |
+
# Install Nvidia Container Toolkit for GPU support (if necessary for Ollama)
|
49 |
+
RUN apt-get install -y nvidia-container-toolkit && apt-get clean
|
50 |
+
|
51 |
# Create a new user named "jovyan" with user ID 1000
|
52 |
RUN useradd -m -u ${NB_UID} ${NB_USER}
|
53 |
|
|
|
58 |
ENV HOME=/home/${NB_USER} \
|
59 |
PATH=/home/${NB_USER}/.local/bin:$PATH
|
60 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
# Upgrade pip and install Python dependencies
|
62 |
RUN python3.8 -m pip install --upgrade pip
|
63 |
+
|
64 |
+
# Copy the Python requirements file and install dependencies
|
65 |
COPY requirements.txt /tmp/requirements.txt
|
66 |
RUN python3.8 -m pip install -r /tmp/requirements.txt
|
67 |
|
68 |
+
# Download and set up Ollama CLI
|
69 |
+
USER root
|
70 |
+
RUN curl -fsSL https://ollama.com/download.sh | bash
|
71 |
+
|
72 |
+
# Switch back to the "jovyan" user
|
73 |
+
USER ${NB_USER}
|
74 |
|
75 |
+
# Set working directory to the user's home directory
|
76 |
+
WORKDIR ${HOME}
|
77 |
+
|
78 |
+
# Expose ports for Streamlit and Ollama
|
79 |
+
EXPOSE 7860 11434
|
80 |
+
|
81 |
+
# Copy application code into the container
|
82 |
+
COPY --chown=${NB_USER}:${NB_USER} . ${HOME}
|
83 |
|
84 |
+
# Start Streamlit and Ollama server
|
85 |
+
CMD ["bash", "-c", "streamlit run Demo.py --server.port=7860 --server.address=0.0.0.0 & ollama serve --port 11434"]
|