Skip to content

Commit

Permalink
Merge pull request #24 from PlusMinus0/dev
Browse files Browse the repository at this point in the history
v3
  • Loading branch information
PlusMinus0 committed Nov 21, 2018
2 parents 371c74b + f39eb31 commit 5952411
Show file tree
Hide file tree
Showing 12 changed files with 164 additions and 58 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*\~
.\#*
\#*\#
.config/
23 changes: 23 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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
23 changes: 0 additions & 23 deletions Dockerfile

This file was deleted.

21 changes: 14 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
# headless-jd2-docker
Headless JDownloader 2 Docker Container
[![Build Status](https://travis-ci.com/PlusMinus0/headless-jd2-docker.svg?branch=master)](https://travis-ci.com/PlusMinus0/headless-jd2-docker)
# 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:

```
Expand Down Expand Up @@ -33,10 +40,10 @@ Headless JDownloader 2 Docker Container
docker start jd2
```

## Optional environment variables
# Optional environment variables
|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.|
|GID|Specifies the GID for all created files. This only works in combination with the 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 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 changes: 19 additions & 0 deletions alpine.Dockerfile
Original file line number Diff line number Diff line change
@@ -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 changes: 21 additions & 0 deletions build-n-test.sh
Original file line number Diff line number Diff line change
@@ -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 changes: 32 additions & 0 deletions common/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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
File renamed without changes.
File renamed without changes.
23 changes: 23 additions & 0 deletions debian.Dockerfile
Original file line number Diff line number Diff line change
@@ -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 changes: 28 additions & 0 deletions goss.yaml
Original file line number Diff line number Diff line change
@@ -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
28 changes: 0 additions & 28 deletions startJD2.sh

This file was deleted.

0 comments on commit 5952411

Please sign in to comment.