From 6e67729d61af463aa579bb55b32d61aeea7b9677 Mon Sep 17 00:00:00 2001 From: Dominique Barton Date: Wed, 20 Jan 2016 21:15:46 +0100 Subject: [PATCH 1/5] update --- Dockerfile | 35 +++++++++++++++++++++------ couchpotato.sh | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+), 7 deletions(-) create mode 100644 couchpotato.sh diff --git a/Dockerfile b/Dockerfile index f1387f5..2190f3f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,10 @@ FROM debian:8 MAINTAINER Dominique Barton +# +# Install all required dependencies. +# + RUN apt-get -q update \ && apt-get install -qy git python-pip python-dev libz-dev libxml2-dev libxslt1-dev gcc \ && pip install cheetah lxml pyopenssl \ @@ -10,21 +14,38 @@ RUN apt-get -q update \ && rm -rf /var/lib/apt/lists/* \ && rm -rf /tmp/* +# +# Create user and group for CouchPotato. +# + RUN groupadd -r -g 666 couchpotato \ && useradd -r -u 666 -g 666 -d /couchpotato couchpotato +# +# Get CouchPotato repository. +# + RUN git clone -b master https://github.com/RuudBurger/CouchPotatoServer.git /couchpotato \ && chown -R couchpotato: /couchpotato -ADD start.sh /start.sh -RUN chown couchpotato: /start.sh \ - && chmod 755 /start.sh +# +# Add CouchPotato init script. +# -VOLUME ["/datadir", "/media"] +ADD couchpotato.sh /couchpotato.sh +RUN chmod 755 /couchpotato.sh -EXPOSE 8080 +# +# Define container settings. +# -USER couchpotato +VOLUME ["/datadir", "/download"] + +EXPOSE 5000 + +# +# Start CouchPotato. +# WORKDIR /couchpotato -CMD ["/start.sh"] +CMD ["/couchpotato.sh"] diff --git a/couchpotato.sh b/couchpotato.sh new file mode 100644 index 0000000..2d82de0 --- /dev/null +++ b/couchpotato.sh @@ -0,0 +1,65 @@ +#!/bin/sh +set -e + +# +# Display settings on standard out. +# + +USER="couchpotato" + +echo "CouchPotato settings" +echo "====================" +echo +echo " User: ${USER}" +echo " UID: ${CP_UID:=666}" +echo " GID: ${CP_GID:=666}" +echo +echo " Config: ${CONFIG:=/datadir/config.ini}" +echo " Version: ${VERSION:=master}" +echo + +# +# Change UID / GID of CouchPotato user. +# + +printf "Updating UID / GID... " +[[ $(id -u ${USER}) == ${CP_UID} ]] || usermod -o -u ${CP_UID} ${USER} +[[ $(id -g ${USER}) == ${CP_GID} ]] || groupmod -o -g ${CP_GID} ${USER} +echo "[DONE]" + +# +# Set directory permissions. +# + +printf "Set permissions... " +touch ${CONFIG} +chown -R ${USER}: /couchpotato +chown ${USER}: /datadir /media $(dirname ${CONFIG}) +echo "[DONE]" + +# +# Update CouchPotato and checkout requested version. +# + +printf "Updating CouchPotato git repository... " +git pull -q +echo "[DONE]" + +printf "Getting current version... " +CURRENT_VERSION=$(git rev-parse --abbrev-ref HEAD) +echo "[${CURRENT_VERSION}]" + +if [[ "${CURRENT_VERSION}" == "${VERSION}" ]] +then + printf "Checking out CouchPotato version '${VERSION}'... " + git checkout -q ${VERSION} + echo "[DONE]" +fi + +# +# Finally, start CouchPotato. +# + +CONFIG=${CONFIG:-/datadir/config.ini} +echo "Starting CouchPotato..." +exec ./CouchPotato.py --data_dir=$(dirname ${CONFIG}) --config_file=${CONFIG} From b3c11bb71d59cee012016a66e8392552a3b086d0 Mon Sep 17 00:00:00 2001 From: Dominique Barton Date: Wed, 20 Jan 2016 21:15:57 +0100 Subject: [PATCH 2/5] removed start --- start.sh | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 start.sh diff --git a/start.sh b/start.sh deleted file mode 100644 index 4a7b9c9..0000000 --- a/start.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh - -echo "Updating CouchPotato git repository..." -git pull - -if [ -n "${VERSION}" ] -then - echo "Checking out SABnzbd version '${VERSION}'..." - git checkout ${VERSION} -fi - -CONFIG=${CONFIG:-/datadir/config.ini} -echo "Starting CouchPotato with config '${CONFIG}'..." -exec ./CouchPotato.py --data_dir=/datadir --config_file=${CONFIG} From c01c9a6d515fd1cbdb2c8b1467325c3f0a99feea Mon Sep 17 00:00:00 2001 From: Dominique Barton Date: Wed, 20 Jan 2016 21:23:12 +0100 Subject: [PATCH 3/5] Update --- Dockerfile | 2 +- couchpotato.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2190f3f..d748bf7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -41,7 +41,7 @@ RUN chmod 755 /couchpotato.sh VOLUME ["/datadir", "/download"] -EXPOSE 5000 +EXPOSE 5050 # # Start CouchPotato. diff --git a/couchpotato.sh b/couchpotato.sh index 2d82de0..2967f1b 100644 --- a/couchpotato.sh +++ b/couchpotato.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash set -e # From 26f04ef33617f35aa8cf9669431ce9bf7df5db1e Mon Sep 17 00:00:00 2001 From: Dominique Barton Date: Wed, 20 Jan 2016 21:26:59 +0100 Subject: [PATCH 4/5] readme update --- README.md | 92 ++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 64 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 5a25961..d0aa147 100644 --- a/README.md +++ b/README.md @@ -2,50 +2,86 @@ This is a Docker image for [CouchPotato](https://couchpota.to/) - the awesome movie PVR for usenet and torrents. +The Docker image currently supports: + +* running CouchPotato under its __own user__ (not `root`) +* changing of the __UID and GID__ for the CouchPotato user +* __automatic update__ of CouchPotato on container restart +* instant __switching between different CouchPotato versions__ +* support for OpenSSL / HTTPS encryption + +## Run + +### Run via Docker CLI client + +To run the CouchPotato container you can execute: + +```bash +docker run --name couchpotato -v :/datadir -v :/media -p 5050:5050 couchpotato/couchpotato +``` + +Open a browser and point it to [http://my-docker-host:5050](http://my-docker-host:5050) + +### Run via Docker Compose + +You can also run the CouchPotato container by using [Docker Compose](https://www.docker.com/docker-compose). + +If you've cloned the [git repository](https://github.com/domibarton/docker-couchpotato) you can build and run the Docker container locally (without the Docker Hub): + +```bash +docker-compose up -d +``` + +If you want to use the Docker Hub image within your existing Docker Compose file you can use the following YAML snippet: + +```yaml +couchpotato: + image: "couchpotato/couchpotato" + container_name: "couchpotato" + volumes: + - ":/datadir" + - ":/media" + ports: + - "5050:5050" + restart: always +``` + ## Configuration ### Volumes -Mount the following volumes inside your container: +Please mount the following volumes inside your CouchPotato container: -* `:/datadir` -* `:/media` +* `/datadir`: Holds all the CouchPotato data files (e.g. config, postProcessing) +* `/media`: Directory for TV shows ### Configuration file -By default the CouchPotato configuration is located on: +By default the CouchPotato configuration is located on `/datadir/config.ini`. +If you want to change this you've to set the `CONFIG` environment variable, for example: ``` -/datadir/config.ini +CONFIG=/datadir/couchpotato.ini ``` -If you want to change this, set the `CONFIG` environment variable. - ### CouchPotato Version -By default the latest CouchPotato version will be used by pointing at the `master` tree of the [CouchPotato git repository](https://github.com/RuudBurger/CouchPotatoServer). -If you want a different version you've set the `VERSION` environment variable to a valid git branch or tag. +By default the latest CouchPotato version will be used. This is achieved by pointing at the `master` tree of the [CouchPotato git repository](https://github.com/RuudBurger/CouchPotatoServer/tree/master). If you want a different version you've set the `VERSION` environment variable to a valid git [branch](https://github.com/RuudBurger/CouchPotatoServer/branches) or [tag](https://github.com/RuudBurger/CouchPotatoServer/tags), for example: -_Please note that CouchPotato will automatically be updated when you restart your container._ - -## Run - -### Run via docker CLI - -```bash -docker run --name couchpotato -v :/datadir -v :/media dbarton/couchpotato +``` +VERSION=devel ``` -### Run via docker-compose +Please note that `VERSION=master` always points to the latest stable version, while `VERSION=devel` points to the bleeding-edge version of CouchPotato. -```yaml -sabnzbd: - image: "dbarton/couchpotato" - container_name: "couchpotato" - volumes: - - ":/datadir" - - ":/media" - tty: true - stdin_open: true - restart: always +_CouchPotato will automatically be updated and switched to your defined version when you restart your container._ + +### UID and GID + +By default CouchPotato runs with user ID and group ID `666`. +If you want to run CouchPotato with different ID's you've to set the `UID` and/or `GID` environment variables, for example: + +``` +UID=1234 +GID=1234 ``` \ No newline at end of file From 27dbd0ff5a1944ebe972cc2ac9767c0c2d0e363b Mon Sep 17 00:00:00 2001 From: Dominique Barton Date: Wed, 20 Jan 2016 21:27:42 +0100 Subject: [PATCH 5/5] another update --- docker-compose.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 docker-compose.yml diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..989db56 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,10 @@ +--- +couchpotato: + build: . + container_name: 'couchpotato' + environment: + VERSION: 'master' + volumes: + - './data/datadir:/datadir' + - './data/media:/media' + restart: 'always' \ No newline at end of file