-
-
Notifications
You must be signed in to change notification settings - Fork 634
/
Copy pathDockerfile
54 lines (40 loc) · 1.64 KB
/
Dockerfile
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
ARG BASE=python:3.12
FROM ${BASE}
# Set environment PATH for local installations
ENV PATH="/root/.local/bin:$PATH"
# Set a working directory for temporary operations
WORKDIR /app
# Set non-interactive mode to prevent tzdata prompt
ENV DEBIAN_FRONTEND=noninteractive
# Install system packages
RUN apt-get update && \
apt-get install -y gcc g++ make wget git calibre ffmpeg libmecab-dev mecab mecab-ipadic-utf8 libsndfile1-dev libc-dev curl espeak-ng sox && \
curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && \
apt-get install -y nodejs && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Install Rust compiler (to build sudachipy for Mac)
RUN curl --proto '=https' --tlsv1.2 -sSf "https://sh.rustup.rs" | sh -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"
# Copy ebook2audiobook repository contents:
WORKDIR /app
COPY . /app
# Remove git folder to save space
# rm -rf /app/.git
# Ensure the repository is the current working directory
WORKDIR /app
# Install Python dependencies and UniDic
RUN pip install --no-cache-dir unidic-lite unidic
RUN python3 -m unidic download # Download UniDic
RUN mkdir -p /root/.local/share/unidic
RUN pip install --no-cache-dir --upgrade -r requirements.txt
# Set environment variable so MeCab can locate UniDic
ENV UNIDIC_DIR=/root/.local/share/unidic
# Do a test run to pre-download and bake base models into the image
RUN echo "This is a test sentence." > test.txt
RUN python app.py --headless --ebook test.txt --script_mode full_docker
RUN rm test.txt
# Expose the required port
EXPOSE 7860
# Start the Gradio app with the required flag
ENTRYPOINT ["python", "app.py", "--script_mode", "full_docker"]