Merge pull request #24 from PlusMinus0/dev

v3
This commit is contained in:
PlusMinus0 2018-11-21 16:13:27 +01:00 committed by GitHub
commit 9dc7ce329a
12 changed files with 164 additions and 58 deletions

4
.gitignore vendored Normal file
View file

@ -0,0 +1,4 @@
*\~
.\#*
\#*\#
.config/

23
.travis.yml Normal file
View file

@ -0,0 +1,23 @@
sudo: required
language: generic
services:
- docker
jobs:
include:
- stage: "Build and Test"
before_script:
- curl -fsSL https://goss.rocks/install | sudo sh
script:
- ./build-n-test.sh
notifications:
webhooks:
urls:
- https://registry.hub.docker.com/u/plusminus/jdownloader2-headless/trigger/e50efaab-36ed-4900-b08d-3cf8944ca9cd/
on_success: always
on_failure: never
on_start: never
on_cancel: never
on_error: never

View file

@ -1,23 +0,0 @@
FROM openjdk:8-jre-alpine
MAINTAINER PlusMinus <piddlpiddl@gmail.com>
# Create directory, and start JD2 for the initial update and creation of config files.
RUN \
apk add --no-cache --quiet tini su-exec bash && \
mkdir -p /opt/JDownloader/libs && \
wget -O /opt/JDownloader/JDownloader.jar --user-agent="https://hub.docker.com/r/plusminus/jdownloader2-headless/" http://installer.jdownloader.org/JDownloader.jar && \
java -Djava.awt.headless=true -jar /opt/JDownloader/JDownloader.jar && \
apk add --update ffmpeg
# Beta sevenzipbindings
COPY sevenzip* /opt/JDownloader/
COPY startJD2.sh /opt/JDownloader/
RUN chmod +x /opt/JDownloader/startJD2.sh
ENTRYPOINT ["/sbin/tini", "-g", "--", "/opt/JDownloader/startJD2.sh"]
# Run this when the container is started
CMD ["java", "-Djava.awt.headless=true", "-jar", "/opt/JDownloader/JDownloader.jar"]

View file

@ -1,7 +1,14 @@
# headless-jd2-docker [![Build Status](https://travis-ci.com/PlusMinus0/headless-jd2-docker.svg?branch=master)](https://travis-ci.com/PlusMinus0/headless-jd2-docker)
Headless JDownloader 2 Docker Container # Supported tags
* [`latest`, `debian`, `v3-debian` (debian.Dockerfile)](https://github.com/PlusMinus0/headless-jd2-docker/blob/master/debian.Dockerfile)
* [`alpine`, `v3-alpine` (alpine.Dockerfile)](https://github.com/PlusMinus0/headless-jd2-docker/blob/master/alpine.Dockerfile)
* [`dev-debian` (debian.Dockerfile)](https://github.com/PlusMinus0/headless-jd2-docker/blob/dev/debian.Dockerfile)
* [`dev-alpine` (alpine.Dockerfile)](https://github.com/PlusMinus0/headless-jd2-docker/blob/dev/alpine.Dockerfile)
* [`v2.1` (Dockerfile)](https://github.com/PlusMinus0/headless-jd2-docker/blob/v2.1/Dockerfile)
* [`v2.0` (Dockerfile)](https://github.com/PlusMinus0/headless-jd2-docker/blob/v2.0/Dockerfile)
## Running the container
# Running the container
0. Become root if your user is not part of the docker group: 0. Become root if your user is not part of the docker group:
``` ```
@ -33,10 +40,10 @@ Headless JDownloader 2 Docker Container
docker start jd2 docker start jd2
``` ```
## Optional environment variables # Optional environment variables
|Environment Variable|Description| |Environment Variable|Description|
|--------------------|-----------| |--------------------|-----------|
|UID|Specifies the UID the daemon should run as. All created files will be owned by this UID. Defaults to 0 for root.| |UID|Specifies the UID the daemon should run as. All created files will be owned by this UID. Defaults to 1000.|
|GID|Specifies the GID for all created files. This only works in combination with the UID. Defaults to 0 for root.| |GID|Specifies the GID for all created files. This only works in combination with the UID. Defaults to 100 for users.|
Not setting these will default to root:root. If you are required to set all environment varibles, setting these to 0 will fall back to the default. Not setting these will default to 1000:100.

19
alpine.Dockerfile Normal file
View file

@ -0,0 +1,19 @@
FROM openjdk:8-jre-alpine
MAINTAINER PlusMinus <piddlpiddl@gmail.com>
# Create directory, and start JD2 for the initial update and creation of config files.
RUN apk update && apk upgrade && \
apk add --no-cache --quiet tini su-exec shadow ffmpeg && \
mkdir -p /opt/JDownloader/libs && \
wget -O /opt/JDownloader/JDownloader.jar --user-agent="https://hub.docker.com/r/plusminus/jdownloader2-headless/" http://installer.jdownloader.org/JDownloader.jar && \
java -Djava.awt.headless=true -jar /opt/JDownloader/JDownloader.jar
# Beta sevenzipbindings and entrypoint
COPY common/* /opt/JDownloader/
RUN chmod +x /opt/JDownloader/entrypoint.sh
ENTRYPOINT ["tini", "-g", "--", "/opt/JDownloader/entrypoint.sh"]
# Run this when the container is started
CMD ["java", "-Djava.awt.headless=true", "-jar", "/opt/JDownloader/JDownloader.jar"]

21
build-n-test.sh Executable file
View file

@ -0,0 +1,21 @@
#!/bin/bash
set -e
images=('alpine' 'debian')
if [ "$(docker version --format '{{.Server.Experimental}}')" = 'true' ]; then
export DOCKER_BUILDKIT=1
fi
for image in "${images[@]}"; do
tag="jd2dev:${image}"
echo "Building $tag"
docker build -t $tag -f $image.Dockerfile .
echo "Testing image"
dgoss run $tag
done

32
common/entrypoint.sh Executable file
View file

@ -0,0 +1,32 @@
#!/bin/sh
# Set defaults for uid and gid to not be root
if [ -n $GID ]; then GID=100; fi
if [ -n $UID ]; then UID=1000; fi
if [ "$GID" -ne "0" ]; then
GROUP=jdownloader
groupadd -g $GID $GROUP
else
GROUP=root
fi
if [ "$UID" -ne "0" ]; then
USER=jdownloader
# Create user without home (-M) and remove login shell
useradd -M -s /bin/false -g $GID -u $UID $USER
else
USER=root
usermod -ag $GID
fi
chown -R $UID:$GID /opt/JDownloader
# Sometimes this gets deleted. Just copy it every time.
cp /opt/JDownloader/sevenzip* /opt/JDownloader/libs/
su-exec ${UID}:${GID} "$@"
# Keep container alive when jd2 restarts
while sleep 3600; do :; done

23
debian.Dockerfile Normal file
View file

@ -0,0 +1,23 @@
FROM openjdk:11-jre-slim-sid
MAINTAINER PlusMinus <piddlpiddl@gmail.com>
# Create directory, and start JD2 for the initial update and creation of config files.
RUN apt-get update && apt-get dist-upgrade -yqq && \
apt-get install -yqq tini ffmpeg wget make gcc && \
mkdir -p /opt/JDownloader/libs && \
wget -O /opt/JDownloader/JDownloader.jar --user-agent="https://hub.docker.com/r/plusminus/jdownloader2-headless/" http://installer.jdownloader.org/JDownloader.jar && \
java -Djava.awt.headless=true -jar /opt/JDownloader/JDownloader.jar && \
mkdir -p /tmp/ && \
wget -O /tmp/su-exec.tar.gz https://github.com/ncopa/su-exec/archive/v0.2.tar.gz && \
cd /tmp/ && tar -xf su-exec.tar.gz && cd su-exec-0.2 && make && cp su-exec /usr/bin &&\
apt-get purge -yqq wget make gcc && apt-get autoremove -yqq && cd / && rm -rf tmp
# Beta sevenzipbindings and entrypoint
COPY common/* /opt/JDownloader/
RUN chmod +x /opt/JDownloader/entrypoint.sh
ENTRYPOINT ["tini", "-g", "--", "/opt/JDownloader/entrypoint.sh"]
# Run this when the container is started
CMD ["java", "-Djava.awt.headless=true", "-jar", "/opt/JDownloader/JDownloader.jar"]

28
goss.yaml Normal file
View file

@ -0,0 +1,28 @@
file:
/opt/JDownloader/JDownloader.jar:
exists: true
mode: "0644"
filetype: file
contains: []
/opt/JDownloader/sevenzipjbinding1509.jar:
exists: true
mode: "0664"
filetype: file
contains: []
/opt/JDownloader/sevenzipjbinding1509Linux.jar:
exists: true
mode: "0664"
filetype: file
contains: []
package:
ffmpeg:
installed: true
user:
jdownloader:
exists: true
uid: 1000
gid: 100
groups:
- users
home: []
shell: /bin/false

View file

@ -1,28 +0,0 @@
#!/bin/bash
if [ "$GID" ] && [ "$GID" -ne "0" ]
then
GROUP=jdownloader
addgroup -g $GID $GROUP
else
GROUP=root
fi
if [ "$UID" ] && [ "$UID" -ne "0" ]
then
USER=jdownloader
adduser -S -D -s /bin/false -u $UID $USER
else
USER=root
fi
adduser -G $GROUP $USER
chown -R $USER:$GROUP /opt/JDownloader
# Sometimes this gets deleted. Just copy it every time.
cp /opt/JDownloader/sevenzip* /opt/JDownloader/libs/
su-exec ${USER}:${GROUP} "$@"
# Keep container alive when jd2 restarts
while sleep 3600; do :; done