Skip to content

Commit

Permalink
Working Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
DrewThomasson authored Dec 31, 2024
1 parent 8f8b5af commit c8b027b
Showing 1 changed file with 35 additions and 60 deletions.
95 changes: 35 additions & 60 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,62 +1,37 @@
# Use an official NVIDIA CUDA image with cudnn8 and Ubuntu 20.04 as the base
FROM nvidia/cuda:11.8.0-cudnn8-runtime-ubuntu20.04

# Set non-interactive installation to avoid timezone and other prompts
ENV DEBIAN_FRONTEND=noninteractive

# Install necessary packages including Miniconda
RUN apt-get update && apt-get install -y --no-install-recommends \
wget \
git \
espeak \
espeak-ng \
ffmpeg \
tk \
mecab \
libmecab-dev \
libegl1 \
libopengl0 \
libxcb-cursor0 \
mecab-ipadic-utf8 \
build-essential \
calibre \
&& rm -rf /var/lib/apt/lists/*

RUN ebook-convert --version

# Install Miniconda
RUN wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda.sh && \
bash ~/miniconda.sh -b -p /opt/conda && \
rm ~/miniconda.sh


# Set PATH to include conda
ENV PATH=/opt/conda/bin:$PATH

# Create a conda environment with Python 3.12
RUN conda create -n ebookenv python=3.12 -y

# Clone the ebook2audiobookXTTS repository
RUN git clone https://github.com/DrewThomasson/ebook2audiobook.git

# Set the working directory in the container
WORKDIR /ebook2audiobook

# Activate the conda environment
SHELL ["conda", "run", "-n", "ebookenv", "/bin/bash", "-c"]

# Install Python dependencies using conda and pip
RUN conda install -n ebookenv -c conda-forge \
pydub \
nltk \
mecab-python3 \
&& pip install --no-cache-dir -r requirements.txt

# Expose the Gradio port
EXPOSE 7860
# Read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
# you will also find guides on how best to write your Dockerfile

FROM python:3.10

# Create and switch to a non-root user
RUN useradd -m -u 1000 user
USER user
ENV PATH="/home/user/.local/bin:$PATH"

# Set a working directory for temporary operations
WORKDIR /app

# Install system packages
USER root
RUN apt-get update && \
apt-get install -y wget git calibre ffmpeg libmecab-dev mecab mecab-ipadic && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

# Set the command to run your GUI application using the conda environment
CMD ["conda", "run", "--no-capture-output", "-n", "ebookenv", "python", "app.py"]
# Clone the GitHub repository and set it as the working directory
USER root
RUN apt-get update && apt-get install -y git && apt-get clean && rm -rf /var/lib/apt/lists/*
USER user
RUN git clone https://github.com/DrewThomasson/ebook2audiobook.git /home/user/ebook2audiobook

# Set the cloned repository as the base working directory
WORKDIR /home/user/ebook2audiobook

#Install Python dependences from the ebook2audiobook repo
RUN pip install --no-cache-dir --upgrade -r requirements.txt

# Expose the required port
EXPOSE 7860

# Build with this command
# docker build --no-cache --platform linux/amd64 -t ebook2audiobook .
# Start the Gradio app from the repository
CMD ["python", "app.py"]

0 comments on commit c8b027b

Please sign in to comment.