-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathDockerfile
119 lines (101 loc) · 3.99 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
ARG UBUNTU_VER=20.04
FROM ghcr.io/by275/base:ubuntu AS prebuilt
FROM ghcr.io/by275/base:ubuntu${UBUNTU_VER} AS base
#
# BUILD
#
FROM base AS plexdrive
ARG TARGETARCH
ARG PLEXDRIVE_VER="5.2.1"
ARG DEBIAN_FRONTEND="noninteractive"
RUN \
echo "**** add plexdrive ****" && \
PLEXDRIVE_ARCH=$(if [ "$TARGETARCH" = "arm" ]; then echo "arm7"; else echo "$TARGETARCH"; fi) && \
curl -o /tmp/plexdrive -LJ https://github.com/plexdrive/plexdrive/releases/download/${PLEXDRIVE_VER}/plexdrive-linux-${PLEXDRIVE_ARCH}
#
# COLLECT
#
FROM base AS collector
# add s6 overlay
COPY --from=prebuilt /s6/ /bar/
ADD https://raw.githubusercontent.com/by275/docker-base/main/_/etc/cont-init.d/adduser /bar/etc/cont-init.d/10-adduser
ADD https://raw.githubusercontent.com/by275/docker-base/main/_/etc/cont-init.d/install-pkg /bar/etc/cont-init.d/20-install-pkg
ADD https://raw.githubusercontent.com/by275/docker-base/main/_/etc/cont-init.d/wait-for-mnt /bar/etc/cont-init.d/30-wait-for-mnt
# add plexdrive
COPY --from=plexdrive /tmp/plexdrive /bar/usr/local/bin/
# add local files
COPY root/ /bar/
RUN \
echo "**** directories ****" && \
mkdir -p \
/bar/cache \
/bar/cloud \
/bar/data \
/bar/local \
&& \
echo "**** permissions ****" && \
chmod a+x \
/bar/usr/local/bin/* \
/bar/etc/cont-init.d/* \
/bar/etc/cont-finish.d/* \
/bar/etc/s6-overlay/s6-rc.d/*/run \
/bar/etc/s6-overlay/s6-rc.d/*/data/*
RUN \
echo "**** s6: resolve dependencies ****" && \
for dir in /bar/etc/s6-overlay/s6-rc.d/*; do mkdir -p "$dir/dependencies.d"; done && \
for dir in /bar/etc/s6-overlay/s6-rc.d/*; do touch "$dir/dependencies.d/legacy-cont-init"; done && \
echo "**** s6: create a new bundled service ****" && \
mkdir -p /tmp/app/contents.d && \
for dir in /bar/etc/s6-overlay/s6-rc.d/*; do touch "/tmp/app/contents.d/$(basename "$dir")"; done && \
echo "bundle" > /tmp/app/type && \
mv /tmp/app /bar/etc/s6-overlay/s6-rc.d/app && \
echo "**** s6: deploy services ****" && \
rm /bar/package/admin/s6-overlay/etc/s6-rc/sources/top/contents.d/legacy-services && \
touch /bar/package/admin/s6-overlay/etc/s6-rc/sources/top/contents.d/app
#
# RELEASE
#
FROM base
LABEL maintainer="wiserain"
LABEL org.opencontainers.image.source https://github.com/wiserain/docker-plexdrive
ARG DEBIAN_FRONTEND="noninteractive"
ARG APT_MIRROR="archive.ubuntu.com"
# install packages
RUN \
echo "**** apt source change for local build ****" && \
sed -i "s/archive.ubuntu.com/$APT_MIRROR/g" /etc/apt/sources.list && \
echo "**** install runtime packages ****" && \
apt-get update && \
apt-get install -yqq --no-install-recommends \
fuse \
openssl \
unionfs-fuse \
&& \
sed -i 's/#user_allow_other/user_allow_other/' /etc/fuse.conf && \
echo "**** add mergerfs ****" && \
MFS_VERSION=$(curl -fsL "https://api.github.com/repos/trapexit/mergerfs/releases/latest" | awk '/tag_name/{print $4;exit}' FS='[""]') && \
MFS_DEB="mergerfs_${MFS_VERSION}.ubuntu-focal_$(dpkg --print-architecture).deb" && \
cd $(mktemp -d) && curl -LJO "https://github.com/trapexit/mergerfs/releases/download/${MFS_VERSION}/${MFS_DEB}" && \
dpkg -i ${MFS_DEB} && \
echo "**** cleanup ****" && \
rm -rf \
/tmp/* \
/var/tmp/* \
/var/cache/* \
/var/lib/apt/lists/*
# add build artifacts
COPY --from=collector /bar/ /
# environment settings
ENV \
S6_BEHAVIOUR_IF_STAGE2_FAILS=2 \
S6_KILL_FINISH_MAXTIME=7000 \
S6_SERVICES_GRACETIM=5000 \
S6_KILL_GRACETIME=5000 \
LANG=C.UTF-8 \
PS1="\u@\h:\w\\$ " \
UFS_USER_OPTS="cow,direct_io,nonempty,auto_cache,sync_read" \
MFS_USER_OPTS="rw,use_ino,func.getattr=newest,category.action=all,category.create=ff,cache.files=auto-full,dropcacheonclose=true"
VOLUME /config /cache /cloud /data /local
HEALTHCHECK --interval=30s --timeout=30s --start-period=10s --retries=3 \
CMD /usr/local/bin/healthcheck
ENTRYPOINT ["/init"]