-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
239 lines (179 loc) · 8.14 KB
/
Copy pathDockerfile
File metadata and controls
239 lines (179 loc) · 8.14 KB
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
FROM debian:latest AS base
ARG VERSION
ARG BUILD_DATE
# set metadata
LABEL org.opencontainers.image.version=$VERSION
LABEL org.opencontainers.image.created=$BUILD_DATE
LABEL org.opencontainers.image.license=MIT
LABEL org.opencontainers.image.description='Automatic Ripping Machine for fully automated Blu-ray, DVD and audio disc ripping.'
LABEL org.opencontainers.image.documentation=https://github.com/automatic-ripping-machine/automatic-ripping-machine/wiki
LABEL org.opencontainers.image.source=https://github.com/automatic-ripping-machine/automatic-ripping-machine
# set systemd environement
ENV container docker
ENV LC_ALL C
ENV DEBIAN_FRONTEND noninteractive
# set ARM environement
ENV ARM_UID=1000
ENV ARM_GID=1000
WORKDIR /tmp
###########################################################
# base packages & repository
RUN apt-get update \
&& apt-get install --no-install-suggests -y \
udev systemd systemd-sysv gnupg git curl \
ca-certificates ca-certificates-java \
apt-utils apt-transport-https \
software-properties-common
RUN sed -i "s/Components: .*/Components: main contrib/g" /etc/apt/sources.list.d/debian.sources \
&& echo 'deb https://ramses.hjramses.com/deb/makemkv bookworm main' >> /etc/apt/sources.list \
&& apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 9E5738E866C5E6B2
RUN cd /lib/systemd/system/sysinit.target.wants/ \
&& rm $(ls | grep -v systemd-tmpfiles-setup)
###########################################################
# upgrading OS
RUN apt clean \
&& apt update && apt upgrade -y -o Dpkg::Options::="--force-confold"
###########################################################
# install deps for ripper
RUN apt update \
&& apt-get install --no-install-suggests -y \
scons swig libzbar-dev libzbar0 \
abcde \
eyed3 \
atomicparsley \
cdparanoia \
eject \
ffmpeg \
flac \
glyrc \
default-jre-headless \
id3 \
id3v2 \
lame \
libavcodec-extra \
lsdvd \
libdvd-pkg \
regionset \
handbrake-cli \
makemkv-oss \
makemkv-bin \
libudev-dev \
python3 \
python3-dev \
python3-pip \
python3-wheel \
python3-psutil \
python3-pyudev \
python3-setuptools \
libcurl4-openssl-dev \
libssl-dev \
&& dpkg-reconfigure libdvd-pkg
###########################################################
# install python reqs
COPY requirements.txt ./requirements.txt
RUN pip3 install --no-cache-dir --break-system-packages --ignore-installed --prefer-binary -r ./requirements.txt
###########################################################
# clean up
RUN apt-get remove --purge -y exim* \
&& apt-get autoremove --yes \
&& apt-get clean autoclean \
&& rm -rf /var/lib/{apt,dpkg,cache,log}/ /root/.cache/pip \
&& rm -rf /var/log/*
RUN rm -f /lib/systemd/system/multi-user.target.wants/* \
/etc/systemd/system/*.wants/* \
/lib/systemd/system/local-fs.target.wants/* \
/lib/systemd/system/sockets.target.wants/*udev* \
/lib/systemd/system/sockets.target.wants/*initctl* \
/lib/systemd/system/basic.target.wants/* \
/lib/systemd/system/anaconda.target.wants/* \
/lib/systemd/system/plymouth* \
/lib/systemd/system/systemd-update-utmp*
###########################################################
# Final image preparation
FROM base AS arm-prepare
# create an arm group(gid 1000) and an arm user(uid 1000), with password logon disabled
RUN groupadd -g 1000 arm \
&& useradd -rM -d /opt/arm -s /bin/bash -g arm -G video,cdrom,render -u 1000 arm
# Setup folders and fstab
RUN mkdir -p /opt/arm /etc/arm /var/log/arm /var/log/arm/progress \
/var/lib/arm \
/var/lib/arm/data \
/var/lib/arm/raw \
/var/lib/arm/transcode \
/var/lib/arm/completed \
/mnt/dev/sr0 \
/mnt/dev/sr1 /mnt/dev/sr2 /mnt/dev/sr3 /mnt/dev/sr4 \
/mnt/dev/sr5 /mnt/dev/sr6 /mnt/dev/sr7 /mnt/dev/sr8 \
/mnt/dev/sr9 /mnt/dev/sr10 /mnt/dev/sr11 /mnt/dev/sr12 \
/mnt/dev/sr13 /mnt/dev/sr14 /mnt/dev/sr15 /mnt/dev/sr16 \
/mnt/dev/sr17 /mnt/dev/sr18 /mnt/dev/sr19 /mnt/dev/sr20 \
&& echo "/dev/sr0 /mnt/dev/sr0 udf,iso9660 users,noauto,exec,utf8,ro 0 0" >> /etc/fstab && \
echo "/dev/sr1 /mnt/dev/sr1 udf,iso9660 users,noauto,exec,utf8,ro 0 0" >> /etc/fstab && \
echo "/dev/sr2 /mnt/dev/sr2 udf,iso9660 users,noauto,exec,utf8,ro 0 0" >> /etc/fstab && \
echo "/dev/sr3 /mnt/dev/sr3 udf,iso9660 users,noauto,exec,utf8,ro 0 0" >> /etc/fstab && \
echo "/dev/sr4 /mnt/dev/sr4 udf,iso9660 users,noauto,exec,utf8,ro 0 0" >> /etc/fstab && \
echo "/dev/sr5 /mnt/dev/sr5 udf,iso9660 users,noauto,exec,utf8,ro 0 0" >> /etc/fstab && \
echo "/dev/sr6 /mnt/dev/sr6 udf,iso9660 users,noauto,exec,utf8,ro 0 0" >> /etc/fstab && \
echo "/dev/sr7 /mnt/dev/sr7 udf,iso9660 users,noauto,exec,utf8,ro 0 0" >> /etc/fstab && \
echo "/dev/sr8 /mnt/dev/sr8 udf,iso9660 users,noauto,exec,utf8,ro 0 0" >> /etc/fstab && \
echo "/dev/sr9 /mnt/dev/sr9 udf,iso9660 users,noauto,exec,utf8,ro 0 0" >> /etc/fstab && \
echo "/dev/sr10 /mnt/dev/sr10 udf,iso9660 users,noauto,exec,utf8,ro 0 0" >> /etc/fstab && \
echo "/dev/sr11 /mnt/dev/sr11 udf,iso9660 users,noauto,exec,utf8,ro 0 0" >> /etc/fstab && \
echo "/dev/sr12 /mnt/dev/sr12 udf,iso9660 users,noauto,exec,utf8,ro 0 0" >> /etc/fstab && \
echo "/dev/sr13 /mnt/dev/sr13 udf,iso9660 users,noauto,exec,utf8,ro 0 0" >> /etc/fstab && \
echo "/dev/sr14 /mnt/dev/sr14 udf,iso9660 users,noauto,exec,utf8,ro 0 0" >> /etc/fstab && \
echo "/dev/sr15 /mnt/dev/sr15 udf,iso9660 users,noauto,exec,utf8,ro 0 0" >> /etc/fstab && \
echo "/dev/sr16 /mnt/dev/sr16 udf,iso9660 users,noauto,exec,utf8,ro 0 0" >> /etc/fstab && \
echo "/dev/sr17 /mnt/dev/sr17 udf,iso9660 users,noauto,exec,utf8,ro 0 0" >> /etc/fstab && \
echo "/dev/sr18 /mnt/dev/sr18 udf,iso9660 users,noauto,exec,utf8,ro 0 0" >> /etc/fstab && \
echo "/dev/sr19 /mnt/dev/sr19 udf,iso9660 users,noauto,exec,utf8,ro 0 0" >> /etc/fstab && \
echo "/dev/sr20 /mnt/dev/sr20 udf,iso9660 users,noauto,exec,utf8,ro 0 0" >> /etc/fstab
# Add udev rule
COPY ./udev/51-docker-arm.rules /lib/udev/rules.d/51-docker-arm.rules
RUN ln -sv /lib/udev/rules.d/50-udev-default.rules /etc/udev/rules.d/ \
&& ln -sv /lib/udev/rules.d/51-docker-arm.rules /etc/udev/rules.d/
# Service scripts
COPY ./systemd/armui.service /lib/systemd/system/
RUN echo 'event_timeout=21600' > /etc/udev/udev.conf \
&& echo '[Install]' >> /usr/lib/systemd/system/udev.service \
&& echo 'WantedBy=multi-user.target' >> /usr/lib/systemd/system/udev.service \
&& systemctl enable udev \
&& systemctl enable armui
###########################################################
# Final image preparation
FROM arm-prepare AS arm-prepare-files
# ARM script
COPY ./arm /opt/arm
RUN chown -R root:arm /etc/arm /var/lib/arm /var/lib/arm/* /var/log/arm \
&& chmod -R ugo=r,ug=rw /etc/arm /var/log/arm /var/log/arm/* /var/lib/arm /var/lib/arm/* /opt/arm /opt/arm/* \
&& chmod ugo+x /etc/arm /var/lib/arm /opt/arm \
&& chmod ugo+rx /opt/arm/*.sh \
&& find /opt/arm -type d -exec chmod ugo+x {} + \
&& find /var/lib/arm -type d -exec chmod ugo+x {} + \
&& find /var/log/arm -type d -exec chmod ugo+x {} +
# Allow git to be managed from the /opt/arm folders
RUN git config --global --add safe.directory /opt/arm
###########################################################
# Final image pushed for use
FROM arm-prepare-files AS automatic-ripping-machine
# Container healthcheck
COPY scripts/healthcheck.sh /usr/share/healthcheck
RUN chmod +rx /usr/share/healthcheck
HEALTHCHECK --interval=5s --timeout=2s --start-period=3s \
CMD ["/bin/sh", "-c", "/usr/share/healthcheck"]
EXPOSE 8080
USER 0:1000
VOLUME [\
"/sys/fs/cgroup", \
"/etc/arm", \
"/var/log/arm", \
"/var/lib/arm/data", \
"/var/lib/arm/raw", \
"/var/lib/arm/transcode", \
"/var/lib/arm/completed/movies", \
"/var/lib/arm/completed/music", \
"/var/lib/arm/completed/unidentified", \
"/opt/arm/tools" \
]
WORKDIR /var/lib/arm/raw
CMD ["/lib/systemd/systemd"]