File size: 2,125 Bytes
7a77c92
cc6a9bb
b3f566d
cc6a9bb
 
 
 
 
7a77c92
 
b3f566d
7a77c92
cc6a9bb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7a77c92
 
cc6a9bb
 
b3f566d
cc6a9bb
 
 
 
 
b3f566d
cc6a9bb
 
 
7a77c92
cc6a9bb
 
 
 
 
 
 
 
 
 
 
 
7a77c92
 
cc6a9bb
 
 
7a77c92
 
 
 
 
 
b3f566d
7a77c92
 
 
 
 
 
 
 
b3f566d
7a77c92
 
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# Base image: Start with Ubuntu 18.04
FROM ubuntu:18.04

# Set environment variables
ENV NB_USER jovyan
ENV NB_UID 1000
ENV HOME /home/${NB_USER}
ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64/
ENV PYSPARK_PYTHON=/usr/bin/python3.8
ENV PYSPARK_DRIVER_PYTHON=/usr/bin/python3.8

# Install required packages and dependencies
RUN apt-get update && apt-get install -y \
    tar \
    wget \
    bash \
    rsync \
    gcc \
    libfreetype6-dev \
    libhdf5-serial-dev \
    libpng-dev \
    libzmq3-dev \
    python3 \
    python3-dev \
    python3-pip \
    unzip \
    pkg-config \
    software-properties-common \
    graphviz \
    openjdk-8-jdk \
    ant \
    ca-certificates-java \
    curl \
    git \
    && apt-get clean \
    && update-ca-certificates -f

# Install Python 3.8 and pip
RUN add-apt-repository ppa:deadsnakes/ppa \
    && apt-get update \
    && apt-get install -y python3.8 python3-pip \
    && apt-get clean

# Set up JAVA_HOME
RUN echo "export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/" >> /etc/profile \
    && echo "export PATH=\$JAVA_HOME/bin:\$PATH" >> /etc/profile

# Create a new user named "jovyan" with user ID 1000
RUN useradd -m -u ${NB_UID} ${NB_USER}

# Switch to the "jovyan" user
USER ${NB_USER}

# Set home and path variables for the user
ENV HOME=/home/${NB_USER} \
    PATH=/home/${NB_USER}/.local/bin:$PATH

# Upgrade pip and install Python dependencies
RUN python3.8 -m pip install --upgrade pip

# Copy the Python requirements file and install dependencies
COPY requirements.txt /tmp/requirements.txt
RUN python3.8 -m pip install -r /tmp/requirements.txt

# Download and set up Ollama CLI
USER root
RUN curl -fsSL https://ollama.com/download.sh | bash

# Switch back to the "jovyan" user
USER ${NB_USER}

# Set working directory to the user's home directory
WORKDIR ${HOME}

# Expose ports for Streamlit and Ollama
EXPOSE 7860 11434

# Copy application code into the container
COPY --chown=${NB_USER}:${NB_USER} . ${HOME}

# Start Streamlit and Ollama server
CMD ["bash", "-c", "streamlit run Demo.py --server.port=7860 --server.address=0.0.0.0 & ollama serve --port 11434"]