Spaces:
Build error
Build error
Upload 2 files
Browse files
dockerfiles/HuggingfaceDockerfile
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
|
2 |
+
# you will also find guides on how best to write your Dockerfile
|
3 |
+
|
4 |
+
# Build with the command:
|
5 |
+
# docker build --platform linux/amd64 -t athomasson2/ebook2audiobook:latest .
|
6 |
+
|
7 |
+
FROM python:3.12
|
8 |
+
|
9 |
+
# Create and switch to a non-root user
|
10 |
+
RUN useradd -m -u 1000 user
|
11 |
+
USER user
|
12 |
+
ENV PATH="/home/user/.local/bin:$PATH"
|
13 |
+
|
14 |
+
# Set a working directory for temporary operations
|
15 |
+
WORKDIR /app
|
16 |
+
|
17 |
+
# Install system packages
|
18 |
+
USER root
|
19 |
+
RUN apt-get update && \
|
20 |
+
apt-get install -y wget git calibre ffmpeg libmecab-dev mecab mecab-ipadic-utf8 curl espeak-ng sox libsndfile1-dev libc-dev && \
|
21 |
+
curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && \
|
22 |
+
apt-get install -y nodejs && \
|
23 |
+
apt-get clean && \
|
24 |
+
rm -rf /var/lib/apt/lists/*
|
25 |
+
|
26 |
+
|
27 |
+
|
28 |
+
# Clone the GitHub repository and set it as the working directory
|
29 |
+
USER root
|
30 |
+
RUN apt-get update && apt-get install -y git && apt-get clean && rm -rf /var/lib/apt/lists/*
|
31 |
+
USER user
|
32 |
+
RUN git clone --depth 1 https://github.com/DrewThomasson/ebook2audiobook.git /home/user/app && rm -rf /home/user/app/.git
|
33 |
+
|
34 |
+
|
35 |
+
# Set the cloned repository as the base working directory
|
36 |
+
WORKDIR /home/user/app
|
37 |
+
|
38 |
+
# Install Python dependencies
|
39 |
+
# Install UniDic and its dependencies
|
40 |
+
RUN pip install --no-cache-dir unidic-lite unidic
|
41 |
+
RUN python3 -m unidic download # Download UniDic
|
42 |
+
RUN mkdir -p /home/user/.local/share/unidic && \
|
43 |
+
mv ~/.local/share/unidic/* /home/user/.local/share/unidic/ || true
|
44 |
+
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
45 |
+
|
46 |
+
# Set environment variable to ensure MeCab can locate UniDic
|
47 |
+
ENV UNIDIC_DIR=/home/user/.local/share/unidic
|
48 |
+
|
49 |
+
# Do a test run to make sure that the base models are pre-downloaded and baked into the image
|
50 |
+
#RUN echo "This is a test sentence." > test.txt
|
51 |
+
#RUN python app.py --headless --ebook test.txt --script_mode full_docker
|
52 |
+
#RUN rm test.txt
|
53 |
+
|
54 |
+
# Expose the required port
|
55 |
+
EXPOSE 7860
|
56 |
+
|
57 |
+
# Start the Gradio app with the required flag
|
58 |
+
ENTRYPOINT ["python", "app.py", "--script_mode", "full_docker"]
|
dockerfiles/UbuntuCudaDockerfile
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 --all --yes
|
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"]
|