commit 9ceb56b06b54efd6b69c2305bd2365ecfca0bdd2 Author: Winston Astrachan Date: Sat Mar 16 19:52:36 2019 -0400 Created docker-flexget diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..09f69d8 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,18 @@ +# EditorConfig is awesome: https://EditorConfig.org + +# top-most EditorConfig file +root = true + +# Unix-style newlines with a newline ending every file +[*] +end_of_line = lf +insert_final_newline = true + +# 4 space indentation +[*.sh] +indent_style = space +indent_size = 4 + +# Tab indentation (no size specified) +[Makefile] +indent_style = tab diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..eadf98e --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +config/ +download/ +*.img diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..68a6c2b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,29 @@ +FROM python:3-alpine +LABEL maintainer="Winston Astrachan" +LABEL description="FlexGet on Alpine Linux" + +ARG FLEXGET_VERSION="2.20.11" + +RUN addgroup -g 101 -S flexget && \ + adduser -u 100 -S -G flexget flexget + +RUN mkdir /config && \ + mkdir /download + +VOLUME /config +VOLUME /download + +COPY overlay/ / +ADD https://github.com/Flexget/Flexget/tarball/${FLEXGET_VERSION} flexget.tar.gz +RUN \ + # Extract and install FlexGet + mkdir flexget && \ + tar --strip-components=1 -xzvf flexget.tar.gz -C flexget && \ + cd flexget && \ + python3 setup.py install && \ + \ + # Clean up build files, deps + rm -rf /flexget /flexget.tar.gz + +ENTRYPOINT ["/docker-entrypoint.sh"] +CMD ["su", "-p", "-s", "/bin/sh", "flexget", "-c", "/usr/local/bin/flexget -c /config/config.yml --loglevel verbose execute"] diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..9a721c6 --- /dev/null +++ b/LICENSE @@ -0,0 +1,20 @@ +Copyright (c) 2019 Winston Astrachan + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..678b6ea --- /dev/null +++ b/Makefile @@ -0,0 +1,46 @@ +# Docker FlexGet Image +# +# Winston Astrachan 2019 +# +help: + @echo "" + @echo "Usage: make COMMAND" + @echo "" + @echo "Docker FlexGet image makefile" + @echo "" + @echo "Commands:" + @echo " build Build and tag image" + @echo " run Start container in the background with locally mounted volume" + @echo " stop Stop and remove container running in the background" + @echo " clean Mark image for rebuild" + @echo " delete Delete image and mark for rebuild" + @echo "" + +build: .flexget.img + +.flexget.img: + docker build -t wastrachan/flexget:latest . + @touch $@ + +.PHONY: run +run: build + docker run -v "$(CURDIR)/config:/config" \ + --name flexget \ + -e PUID=1111 \ + -e PGID=1112 \ + --restart unless-stopped \ + -d \ + wastrachan/flexget:latest + +.PHONY: stop +stop: + docker stop flexget + docker rm flexget + +.PHONY: clean +clean: + rm -f .flexget.img + +.PHONY: delete +delete: clean + docker rmi -f wastrachan/flexget diff --git a/README.md b/README.md new file mode 100644 index 0000000..083aacb --- /dev/null +++ b/README.md @@ -0,0 +1,85 @@ +FlexGet Docker Image +==================== + +FlexGet in a Docker container, with configuration in a volume, and a configurable UID/GID for said files. + +[![](https://img.shields.io/github/tag/wastrachan/docker-flexget.svg)](https://github.com/wastrachan/docker-flexget/releases) +[![](https://images.microbadger.com/badges/image/wastrachan/docker-flexget.svg)](https://microbadger.com/images/wastrachan/docker-flexget) +[![](https://img.shields.io/docker/pulls/wastrachan/docker-flexget.svg)](https://hub.docker.com/r/wastrachan/docker-flexget) + +## Install + +#### Docker Hub +Pull the latest image from Docker Hub: + +```shell +docker pull wastrachan/flexget +``` + +#### Manually +Clone this repository, and run `make build` to build an image: + +```shell +git clone https://github.com/wastrachan/docker-flexget +cd docker-flexget +make build +``` + +If you need to rebuild the image, run `make clean build`. + + +## Run + +#### Docker +Run this image with the `make run` shortcut, or manually with `docker run`. + + +```shell +docker run -v "$(pwd)/config:/config" \ + --name flexget \ + -e PUID=1111 \ + -e PGID=1112 \ + --restart unless-stopped \ + wastrachan/flexget:latest +``` + + +#### Docker Compose +If you wish to run this image with docker-compose, an example `docker-compose.yml` might read as follows: + +```yaml +--- +version: "2" + +services: + bind: + image: wastrachan/flexget + container_name: flexget + environment: + - PUID=1111 + - PGID=1112 + volumes: + - :/config + restart: unless-stopped +``` + + +## Configuration +Configuration files are stored in the `/config` volume. You may wish to mount this volume as a local directory, as shown in the examples above. + +The main config file for FlexGet is `config.yml`, and will be created automatically if the container is started without a config file present. Please review the [FlexGet docs](https://flexget.com/Configuration) for more information. + + +#### User / Group Identifiers +If you'd like to override the UID and GID of the `{{ program }}` process, you can do so with the environment variables `PUID` and `PGID`. This is helpful if other containers must access your configuration volume. + +#### Volumes +Volume | Description +----------------|------------- +`/config` | Configuration directory + + +## License +The content of this project itself is licensed under the [MIT License](LICENSE). + +View [license information](https://github.com/Flexget/Flexget/blob/develop/LICENSE) for the software contained in this image. diff --git a/overlay/defaults/config.yml b/overlay/defaults/config.yml new file mode 100644 index 0000000..0f4ab5b --- /dev/null +++ b/overlay/defaults/config.yml @@ -0,0 +1,8 @@ +tasks: + test task: + rss: http://mysite.com/myfeed.rss + series: + - My Favorite Show + - Another Good Show: + quality: 720p + download: /download diff --git a/overlay/docker-entrypoint.sh b/overlay/docker-entrypoint.sh new file mode 100755 index 0000000..b300ccc --- /dev/null +++ b/overlay/docker-entrypoint.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env sh +set -e + +PUID="${PUID:-100}" +PGID="${PGID:-101}" + +echo "" +echo "----------------------------------------" +echo " Starting FlexGet, using the following: " +echo " " +echo " UID: $PUID " +echo " GID: $PGID " +echo "----------------------------------------" +echo "" + +# Copy default config files +if [ ! -f "/config/config.yml" ]; then + cp /defaults/config.yml /config/config.yml +fi + +# Set UID/GID of user +sed -i "s/^flexget\:x\:100\:101/flexget\:x\:$PUID\:$PGID/" /etc/passwd +sed -i "s/^flexget\:x\:101/flexget\:x\:$PGID/" /etc/group + +# Set permissions +chown -R $PUID:$PGID /config + +exec "$@"