-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
98 lines (78 loc) · 2.56 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
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
##------------------------------------------------------------------------------
## ML-Subber dockerfile
##
## @author Lars Thoms <lars@thoms.io>
## @date 2023-05-08
##------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Build
##------------------------------------------------------------------------------
# Base image
FROM debian:bookworm-slim as build
# Explicit shell configuration
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
# Environment variables during build
ENV DEBIAN_FRONTEND=noninteractive
ENV MAKEFLAGS="-j$(nproc)"
# Modify repository
RUN sed -i -e 's/ main/ main contrib/g' /etc/apt/sources.list.d/debian.sources
# Update base system
RUN apt-get update &&\
apt-get dist-upgrade -y
# Install persistent packages
RUN apt-get install -y --no-install-recommends \
ffmpeg \
python3-minimal \
python3-dev \
python3-pkg-resources
# Install temporary packages
ARG BUILDDEPS="autoconf \
automake \
bzip2 \
ca-certificates \
g++ \
gfortran \
git \
libatlas-base-dev \
libtool \
make \
patch \
python2-minimal \
python3-pip \
sox \
subversion \
unzip \
wget"
RUN apt-get install -y --no-install-recommends ${BUILDDEPS}
# Break PEP 668
RUN rm "$(python3 -c "import sysconfig; print(sysconfig.get_config_var('LIBDEST'))")/EXTERNALLY-MANAGED"
# Install Subtitle2go
RUN git clone --depth=1 https://github.com/uhh-lt/subtitle2go.git /app &&\
pip3 install --no-cache-dir --use-pep517 --no-compile --use-feature=fast-deps -r /app/requirements.txt
# Install Kaldi
WORKDIR /app
RUN sed -i -r 's@^\./configure .*$@\./configure --shared --static-math=yes --mathlib=ATLAS@' install_kaldi.sh &&\
./install_kaldi.sh
# Download language models
RUN python3 -m spacy download de_core_news_lg &&\
python3 -m spacy download en_core_web_lg &&\
./download_models.sh
# Create data directory
RUN mkdir /data
# Add entrypoint script
COPY entrypoint.sh /
RUN chmod +x /entrypoint.sh
# Delete temporary packages
RUN apt-get autoremove -y ${BUILDDEPS}
# Clean and harden container
COPY clean.sh /
RUN sh /clean.sh
##------------------------------------------------------------------------------
## Production
##------------------------------------------------------------------------------
# Copy results from build image
FROM scratch
COPY --from=build / /
# Base configuration
WORKDIR /app
ENTRYPOINT ["/entrypoint.sh"]