drewThomasson commited on
Commit
569b754
·
verified ·
1 Parent(s): 16195d6

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +21 -36
Dockerfile CHANGED
@@ -1,58 +1,43 @@
1
- # Use an official Python image
2
  FROM nvidia/cuda:11.8.0-base-ubuntu22.04
3
 
4
- # Set up Python environment
5
  ENV DEBIAN_FRONTEND=noninteractive
6
  ENV PYTHONUNBUFFERED=1
 
7
 
8
- # Install system packages and Python 3.12
9
  RUN apt-get update && apt-get install -y \
10
- software-properties-common && \
11
- add-apt-repository ppa:deadsnakes/ppa && \
12
- apt-get update && apt-get install -y \
13
- python3.12 python3.12-venv python3.12-dev libxml2-dev libxslt1-dev zlib1g-dev \
14
- wget git calibre ffmpeg libmecab-dev mecab mecab-ipadic python3-pip \
15
- && apt-get clean && rm -rf /var/lib/apt/lists/*
16
 
17
- # Make 'python' command work for Python 3.12
18
- RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.12 1 && \
19
- update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.12 1
20
-
21
- # Install pip, setuptools, and wheel manually
22
- RUN wget https://bootstrap.pypa.io/get-pip.py && \
23
- python get-pip.py && \
24
- rm get-pip.py && \
25
- pip install --no-cache-dir --upgrade pip setuptools wheel
26
-
27
- # Ensure latest lxml is installed
28
- RUN pip install --no-cache-dir --upgrade lxml
29
-
30
- # Ensure latest Pillow is installed
31
- RUN pip install --no-cache-dir --upgrade Pillow
32
-
33
- # Explicitly install regex
34
- RUN pip install --no-cache-dir regex --force-reinstall
35
-
36
- # Explicitly install matplotlib and its dependencies
37
- RUN pip install --no-cache-dir matplotlib kiwisolver
38
 
39
  # Create and switch to a non-root user
40
  RUN useradd -m -u 1000 user
41
  USER user
42
- ENV PATH="/home/user/.local/bin:$PATH"
43
 
44
- # Set working directory
45
- WORKDIR /home/user/app
46
 
47
  # Clone the GitHub repository
48
  RUN git clone https://github.com/DrewThomasson/ebook2audiobook.git /home/user/app
49
 
50
- # Install Python dependencies
 
 
 
51
  RUN pip install --no-cache-dir --upgrade pip setuptools wheel && \
52
- pip install --no-cache-dir --use-pep517 -r requirements.txt
53
 
54
  # Expose the application port
55
  EXPOSE 7860
56
 
57
  # Start the Gradio app
58
- CMD ["python", "app.py"]
 
1
+ # Use an official CUDA base image
2
  FROM nvidia/cuda:11.8.0-base-ubuntu22.04
3
 
4
+ # Set up environment variables
5
  ENV DEBIAN_FRONTEND=noninteractive
6
  ENV PYTHONUNBUFFERED=1
7
+ ENV PATH="/opt/conda/bin:$PATH"
8
 
9
+ # Install system packages and Miniconda
10
  RUN apt-get update && apt-get install -y \
11
+ wget git calibre ffmpeg libmecab-dev mecab mecab-ipadic \
12
+ && apt-get clean && rm -rf /var/lib/apt/lists/* && \
13
+ wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh && \
14
+ bash miniconda.sh -b -p /opt/conda && \
15
+ rm miniconda.sh && \
16
+ /opt/conda/bin/conda clean -tipsy
17
 
18
+ # Create and activate the Python 3.12 environment
19
+ RUN conda create -y -n py312 python=3.12 && \
20
+ conda clean -a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
  # Create and switch to a non-root user
23
  RUN useradd -m -u 1000 user
24
  USER user
 
25
 
26
+ # Activate the Conda environment
27
+ SHELL ["conda", "run", "-n", "py312", "/bin/bash", "-c"]
28
 
29
  # Clone the GitHub repository
30
  RUN git clone https://github.com/DrewThomasson/ebook2audiobook.git /home/user/app
31
 
32
+ # Set the working directory
33
+ WORKDIR /home/user/app
34
+
35
+ # Install Python dependencies using requirements.txt
36
  RUN pip install --no-cache-dir --upgrade pip setuptools wheel && \
37
+ pip install --no-cache-dir -r requirements.txt
38
 
39
  # Expose the application port
40
  EXPOSE 7860
41
 
42
  # Start the Gradio app
43
+ CMD ["conda", "run", "-n", "py312", "python", "app.py"]