Skip to content

Commit 3f6b998

Browse files
author
mumie
committed
Merge branch 'dev' into 'master'
Dev See merge request mumie/docker-services!30
2 parents e034ce0 + e284b3b commit 3f6b998

File tree

19 files changed

+295
-86
lines changed

19 files changed

+295
-86
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
Container Services most of them based on alpine image to be lightweight.
2-
Alle Services are build for a gracefull shutdown/restart.
2+
Alle Services are build for a graceful shutdown/restart.

jdownloader/Dockerfile

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,19 @@ FROM alpine:latest
22

33
ENV USER_UID="1002" \
44
USER_NAME="jdownloader" \
5-
JDOWNLOADER_LINK="http://installer.jdownloader.org/JDownloader.jar"
5+
JDOWNLOADER_LINK="http://installer.jdownloader.org/JDownloader.jar" \
6+
JDPATH="/jdownloader" \
7+
LANG='C.UTF-8' \
8+
LANGUAGE='C.UTF-8'
69

7-
ENV JAVA_VERSION=8 \
8-
JAVA_VERSION_MINOR=202 \
9-
JAVA_VERSION_BUILD=08 \
10-
JAVA_PACKAGE=server-jre \
11-
JAVA_MAGIC=1961070e4c9b4e26a04e7f5a083f551e \
12-
JAVA_HOME=/opt/jdk \
10+
ENV JAVA_HOME=/opt/jdk \
1311
PATH=${PATH}:/opt/jdk/bin \
14-
GLIBC_VERSION=2.29-r0 \
15-
LANG=C.UTF-8
12+
GLIBC_VERSION=2.30-r0
1613

1714
# alpine - openjdk8-jre-base java-jna openjdk8-jre-lib libstdc++ glibc-bin glibc-i18n
1815
# libstdc++ and glibc-i18n needed for jdownloader building 7zip Package
1916
RUN set -ex \
20-
&& apk add --no-cache --update wget bash ca-certificates su-exec curl libstdc++ tar \
17+
&& apk add --no-cache --update wget bash ca-certificates su-exec curl libstdc++ tar openjdk8-jre-base \
2118
&& wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub \
2219
&& wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VERSION}/glibc-${GLIBC_VERSION}.apk \
2320
&& wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VERSION}/glibc-bin-${GLIBC_VERSION}.apk \
@@ -26,29 +23,23 @@ RUN set -ex \
2623
# && ( /usr/glibc-compat/bin/localedef --force --inputfile POSIX --charmap UTF-8 C.UTF-8 || true ) \
2724
# && echo "export $LANG" > /etc/profile.d/locale.sh \
2825
# && /usr/glibc-compat/sbin/ldconfig /lib /usr/glibc-compat/lib \
29-
# Downloading Oracle Java Server-Jre
3026
&& mkdir -p /opt \
31-
&& curl -jksSLH "Cookie: oraclelicense=accept-securebackup-cookie" -o /tmp/java.tar.gz \
32-
https://download.oracle.com/otn-pub/java/jdk/${JAVA_VERSION}u${JAVA_VERSION_MINOR}-b${JAVA_VERSION_BUILD}/${JAVA_MAGIC}/${JAVA_PACKAGE}-${JAVA_VERSION}u${JAVA_VERSION_MINOR}-linux-x64.tar.gz \
33-
&& tar -C /opt -zxvf /tmp/java.tar.gz \
34-
&& ln -s /opt/jdk1.${JAVA_VERSION}.0_${JAVA_VERSION_MINOR} /opt/jdk \
35-
&& find /opt/jdk/ -maxdepth 1 -mindepth 1 | grep -v jre | xargs rm -rf \
36-
&& cd /opt/jdk/ \
37-
&& ln -s ./jre/bin ./bin \
27+
&& mkdir -p ${JDPATH} \
3828
&& echo "adding $USER_NAME as Group and User" \
3929
&& addgroup -g ${USER_UID} ${USER_NAME} \
4030
&& adduser -D -u ${USER_UID} -G ${USER_NAME} -s /bin/sh -h /${USER_NAME} ${USER_NAME} \
41-
&& echo "Downloading jDownloader jar File" \
42-
&& wget -O /${USER_NAME}/JDownloader.jar --progress=bar:force ${JDOWNLOADER_LINK} \
43-
&& apk del wget ca-certificates curl tar \
31+
# && echo "Downloading jDownloader jar File" \
32+
# && wget -O ${JDPATH}/JDownloader.jar --progress=bar:force ${JDOWNLOADER_LINK} \
33+
&& apk del wget curl tar \
4434
&& rm -rf /tmp/* /var/cache/apk/* /var/lib/apk/lists/*
4535

4636
ADD start.sh /start.sh
37+
ADD JDownloader.jar ${JDPATH}/JDownloader.jar
4738
RUN chmod +x /start.sh
4839

4940
#USER $USER_NAME
50-
VOLUME /${USER_NAME}/cfg
51-
WORKDIR /${USER_NAME}
41+
VOLUME ${JDPATH}/cfg
42+
WORKDIR ${JDPATH}
5243
CMD ["/start.sh"]
5344

5445
# Run Commands

jdownloader/JDownloader.jar

3.4 MB
Binary file not shown.

jdownloader/README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
Lightweight alpine container with jdownloader (126MB image size) with graceful shutdown/restart (java runs on PID 1 with USER_UID specified). All is working correctly especially extracting ( glibc is added for extraction to work ).
22

3-
Use it with:
4-
docker run -d -m 2g --restart=unless-stopped --name jdownloader -v /home/USER/data/jdownloader:/jdownloader/cfg -v /YOUR/download/path:/jdownloader/Downloads -e USER_UID=1002 mumiehub/jdownloader
3+
# Usage Example:
4+
5+
docker run -d -m 2g --name jdownloader \
6+
--restart=unless-stopped \
7+
--cap-add SYS_ADMIN \
8+
--device /dev/fuse \
9+
--security-opt apparmor:unconfined \
10+
-e USER_UID=1002 \
11+
-v /home/<USER>/jdownloader:/jdownloader/cfg \
12+
-v /host/download/path:/jdownloader/Downloads \
13+
mumiehub/jdownloader
514

615
-m 2g is used because jdownloader will eat up your memory when downloading something (caching).
716

jdownloader/start.sh

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,54 @@
11
#!/bin/sh
22
set -e
33

4-
# Display settings on standard out.
4+
#ENV
5+
OS=""
6+
7+
#Functions
8+
DectectOS(){
9+
if [ -e /etc/alpine-release ]; then
10+
OS="alpine"
11+
elif [ -e /etc/os-release ]; then
12+
if /bin/grep -q "NAME=\"Ubuntu\"" /etc/os-release ; then
13+
OS="ubuntu"
14+
fi
15+
fi
16+
}
17+
18+
AutoUpgrade(){
19+
if [ "${OS}" == "alpine" ]; then
20+
/sbin/apk --no-cache upgrade
21+
/bin/rm -rf /var/cache/apk/*
22+
elif [ "${OS}" == "ubuntu" ]; then
23+
export DEBIAN_FRONTEND=noninteractive
24+
/usr/bin/apt-get update
25+
/usr/bin/apt-get -y --no-install-recommends dist-upgrade
26+
/usr/bin/apt-get -y autoclean
27+
/usr/bin/apt-get -y clean
28+
/usr/bin/apt-get -y autoremove
29+
/bin/rm -rf /var/lib/apt/lists/*
30+
fi
31+
}
32+
33+
AddCredentials(){
34+
if [ ! -f $JDPATH/cfg/org.jdownloader.api.myjdownloader.MyJDownloaderSettings.json ]; then
35+
cat << EOF > $JDPATH/cfg/org.jdownloader.api.myjdownloader.MyJDownloaderSettings.json
36+
{
37+
"autoconnectenabledv2" : true,
38+
"email" : "${DOCKJDMAIL}",
39+
"password" : "${DOCKJDPASSWD}"
40+
}
41+
EOF
42+
/bin/chown -R "${MYUSER}":"${MYUSER}" $JDPATH/cfg/org.jdownloader.api.myjdownloader.MyJDownloaderSettings.json
43+
/bin/chmod 0664 $JDPATH/cfg/org.jdownloader.api.myjdownloader.MyJDownloaderSettings.json
44+
fi
45+
}
46+
47+
SetDownloadFolder(){
48+
if [ -f $JDPATH/cfg/org.jdownloader.settings.GeneralSettings.json ]; then
49+
sed -i "s|\s*\"defaultdownloadfolder\"\s*:\s*\"\"|\ \ \ \ \ \ \ \ \"defaultdownloadfolder\":\ \"/downloads\"|g" $JDPATH/cfg/org.jdownloader.settings.GeneralSettings.json
50+
fi
51+
}
552

653
#USER_NAME="jdownloader"
754
echo "===================="
@@ -26,6 +73,12 @@ chown -R ${USER_NAME}: /jdownloader
2673
chown ${USER_NAME}: /media
2774
echo "[DONE]"
2875

76+
#run functions##############################
77+
DectectOS
78+
AutoUpgrade
79+
#AddCredentials
80+
#SetDownloadFolder
81+
2982
# Finally, start JDownloader.
3083
echo "Starting JDownloader..."
31-
exec su -pc "exec java -Djava.awt.headless=true -jar JDownloader.jar 2>&1 >/dev/null" $USER_NAME
84+
exec su -pc "exec java -Djava.awt.headless=true -jar ${JDPATH}/JDownloader.jar 2>&1 >/dev/null" $USER_NAME

rclone-mount/Dockerfile

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
FROM alpine
1+
FROM alpine:latest
22

3-
ENV GOPATH="/go" \
3+
ARG OVERLAY_VERSION="v1.22.1.0"
4+
ARG OVERLAY_ARCH="amd64"
5+
6+
ENV DEBUG="false" \
7+
GOPATH="/go" \
48
AccessFolder="/mnt" \
59
RemotePath="mediaefs:" \
610
MountPoint="/mnt/mediaefs" \
@@ -10,19 +14,29 @@ ENV GOPATH="/go" \
1014
UnmountCommands="-u -z"
1115

1216
## Alpine with Go Git
13-
RUN apk add --no-cache --update alpine-sdk ca-certificates go git fuse fuse-dev \
17+
RUN apk --no-cache upgrade \
18+
&& apk add --no-cache --update alpine-sdk ca-certificates go git fuse fuse-dev gnupg \
19+
&& echo "Installing S6 Overlay" \
20+
&& curl -o /tmp/s6-overlay.tar.gz -L \
21+
"https://github.com/just-containers/s6-overlay/releases/download/${OVERLAY_VERSION}/s6-overlay-${OVERLAY_ARCH}.tar.gz" \
22+
&& curl -o /tmp/s6-overlay.tar.gz.sig -L \
23+
"https://github.com/just-containers/s6-overlay/releases/download/${OVERLAY_VERSION}/s6-overlay-${OVERLAY_ARCH}.tar.gz.sig" \
24+
&& curl https://keybase.io/justcontainers/key.asc | gpg --import \
25+
&& gpg --verify /tmp/s6-overlay.tar.gz.sig /tmp/s6-overlay.tar.gz \
26+
&& tar xfz /tmp/s6-overlay.tar.gz -C / \
27+
&& echo "Download and compile rclone" \
1428
&& go get -u -v github.com/rclone/rclone \
1529
&& cp /go/bin/rclone /usr/sbin/ \
1630
&& rm -rf /go \
17-
&& apk del alpine-sdk go git \
31+
&& apk del alpine-sdk go git gnupg \
1832
&& rm -rf /tmp/* /var/cache/apk/* /var/lib/apk/lists/*
1933

20-
ADD start.sh /start.sh
21-
RUN chmod +x /start.sh
34+
COPY rootfs/ /
2235

2336
VOLUME ["/mnt"]
2437

25-
CMD ["/start.sh"]
38+
ENTRYPOINT ["/init"]
39+
#CMD ["/start.sh"]
2640

2741
# Use this docker Options in run
2842
# --cap-add SYS_ADMIN --device /dev/fuse --security-opt apparmor:unconfined

rclone-mount/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
Rclone Mount Container
66
---
77

8-
Lightweight and simple Container Image (`alpine:latest - 44MB`) with compiled rclone (https://github.com/ncw/rclone master). Mount your cloudstorage like amazon cloud drive inside a container and make it available to other containers like your Plex Media Server or on your hostsystem (mountpoint on host is shared). You need a working rclone.conf (from another host or create it inside the container). all rclone remotes can be used.
8+
Lightweight and simple Container Image (`alpine:latest - 160MB`) with compiled rclone (https://github.com/ncw/rclone master). Mount your cloudstorage like amazon cloud drive inside a container and make it available to other containers like your Plex Media Server or on your hostsystem (mountpoint on host is shared). You need a working rclone.conf (from another host or create it inside the container with entrypoint /bin/sh). all rclone remotes can be used.
99

1010

11-
The Container uses a tiny trap function, to handle docker stop/restart ( fusermount -uz $MountPoint is applied on SIGTERM signal or app crashes also) on PID 1.
11+
The Container uses S6 Overlay, to handle docker stop/restart ( fusermount -uz $MountPoint is applied on app crashes also) and also preparing the mountpoint.
1212

1313

1414
# Usage Example:

rclone-mount/rootfs/etc/colors.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env sh
2+
3+
Color_Off='\033[0m' # Text Reset
4+
# Regular Colors
5+
Black='\033[0;30m' # Black
6+
Red='\033[0;31m' # Red
7+
Green='\033[0;32m' # Green
8+
Yellow='\033[0;33m' # Yellow
9+
Blue='\033[0;34m' # Blue
10+
Purple='\033[0;35m' # Purple
11+
Cyan='\033[0;36m' # Cyan
12+
White='\033[0;37m' # White
13+
# Bold
14+
BBlack='\033[1;30m' # Black
15+
BRed='\033[1;31m' # Red
16+
BGreen='\033[1;32m' # Green
17+
BYellow='\033[1;33m' # Yellow
18+
BBlue='\033[1;34m' # Blue
19+
BPurple='\033[1;35m' # Purple
20+
BCyan='\033[1;36m' # Cyan
21+
BWhite='\033[1;37m' # White
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/with-contenv sh
2+
3+
source /etc/colors.sh
4+
5+
PREFFIX="[cont-finish.d] $(s6-basename ${0}):"
6+
7+
#s6-svc -d /var/run/s6/services/rclone-mount
8+
#s6-svc -wD /var/run/s6/services/rclone-mount
9+
10+
echo -e "${PREFFIX} ${Yellow}waiting for shutdown of all services${Color_Off}"
11+
#wait for all services to be down
12+
s6-svwait -D /var/run/s6/services/*
13+
14+
#awk '/efsgoogle:/ && /\'$ENVIRON["MountPoint"]'/ {print; exit 1}' /proc/mounts
15+
16+
#check if rclone gracefully unmounted
17+
if grep -Eq ''$RemotePath'.*'$MountPoint'|'$MountPoint'.*'$RemotePath'' /proc/mounts; then
18+
echo -e "${PREFFIX} ${Red}force unmounting with fusermount $UnmountCommands at: $(date +%Y.%m.%d-%T)${Color_Off}"
19+
fusermount $UnmountCommands $MountPoint
20+
wait ${!}
21+
exit 1
22+
else
23+
#cleanup of mount namespace
24+
umount $MountPoint
25+
echo -e "${PREFFIX} ${Green}successful unmounted${Color_Off}"
26+
exit 0
27+
fi
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/usr/bin/with-contenv sh
2+
3+
source /etc/colors.sh
4+
5+
PREFFIX="[cont-init.d] $(s6-basename ${0}):"
6+
7+
#ENV
8+
OS=""
9+
ConfigPath=""
10+
11+
#Functions
12+
DetectOS(){
13+
if [ -e /etc/alpine-release ]; then
14+
OS="alpine"
15+
elif [ -e /etc/os-release ]; then
16+
if /bin/grep -q "NAME=\"Ubuntu\"" /etc/os-release ; then
17+
OS="ubuntu"
18+
fi
19+
fi
20+
}
21+
22+
AutoUpgrade(){
23+
if [ "${OS}" == "alpine" ]; then
24+
/sbin/apk --no-cache upgrade
25+
/bin/rm -rf /var/cache/apk/*
26+
elif [ "${OS}" == "ubuntu" ]; then
27+
export DEBIAN_FRONTEND=noninteractive
28+
/usr/bin/apt-get update
29+
/usr/bin/apt-get -y --no-install-recommends dist-upgrade
30+
/usr/bin/apt-get -y autoclean
31+
/usr/bin/apt-get -y clean
32+
/usr/bin/apt-get -y autoremove
33+
/bin/rm -rf /var/lib/apt/lists/*
34+
fi
35+
}
36+
37+
#fix Mountpoint Syntax
38+
#remove / at the end #todo
39+
40+
#create folders
41+
mkdir -p \
42+
$MountPoint \
43+
$ConfigDir
44+
45+
#export ConfigPath="$ConfigDir/$ConfigName env"
46+
printf "$ConfigDir/$ConfigName" > /var/run/s6/container_environment/ConfigPath
47+
48+
echo -e "${PREFFIX} ${Blue}installing system updates${Color_Off}"
49+
DetectOS
50+
AutoUpgrade
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/with-contenv sh
2+
3+
source /etc/colors.sh
4+
5+
PREFFIX="[cont-init.d] $(s6-basename ${0}):"
6+
7+
#check if the MountPoint is empty
8+
if [ "$(ls -A ${MountPoint})" ]; then
9+
echo -e "${PREFFIX} ${Red}MountPoint folder not empty[ERROR]${Color_Off}"
10+
#todo
11+
fi
12+
13+
#check for other fsmounts, stop mounting if other MountPoint exists
14+
#mount | grep -c $MountPoint
15+
16+
if grep -Eq ''$RemotePath'.*'$MountPoint'|'$MountPoint'.*'$RemotePath'' /proc/mounts; then
17+
#exit container here
18+
echo -e "${PREFFIX} ${Red}found other MountPoint in /proc/mounts${Color_Off}"
19+
#cleanup mountpoint
20+
exit 1
21+
else
22+
echo -e "${PREFFIX} ${Green}MountPoint $MountPoint is ready${Color_Off}"
23+
exit 0
24+
fi

0 commit comments

Comments
 (0)