From d63c2a00f96d9c0391704fd7e9735d47717087b9 Mon Sep 17 00:00:00 2001 From: "B. Stack" Date: Sun, 18 Jun 2023 16:05:33 -0400 Subject: initial commit --- .gitignore | 3 +++ Dockerfile | 36 ++++++++++++++++++++++++++++++++++++ README.md | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ docker-compose.yml | 21 +++++++++++++++++++++ entrypoint.sh | 32 ++++++++++++++++++++++++++++++++ 5 files changed, 140 insertions(+) create mode 100644 .gitignore create mode 100644 Dockerfile create mode 100644 README.md create mode 100644 docker-compose.yml create mode 100755 entrypoint.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..986e34b --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +instance/ +.*.swp +git/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..7b90a2c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,36 @@ +# Startdate: 2023-06-15-5 11:49 +# Purpose: docker image for newspipe +# Usage: +# docker build . --tag newspipe:latest +# docker run -p 5938:8081 --mount type=bind,source=./instance,destination=/newspipe/instance -it --rm newspipe:latest +FROM devuan/devuan:unstable +MAINTAINER bgstack15@gmail.com + +ENV NEWSPIPE_CONFIG=sqlite.py +ENV FLASK_APP=runserver.py +ENV FLASK_DEBUG=1 +ENV PATH="${PATH}":/ +# Instructions from https://git.sr.ht/~cedric/newspipe +RUN apt-get update && \ + apt-get -y install --no-install-recommends git npm python3-poetry python3-babel python3-flask && \ + rm -rf /var/lib/apt/lists/* || : ; \ + git clone https://bgstack15.ddns.net/cgit/newspipe /newspipe && \ + git config --global --add safe.directory /newspipe && \ + cd newspipe && \ + git checkout ldap-auth && \ + npm install && \ + npm ci +WORKDIR /newspipe +# ldap3 line is required for only branch ldap-auth +RUN poetry install --no-dev && \ + poetry run pip3 install ldap3 dnspython && \ + poetry run pybabel compile -d newspipe/translations && \ + poetry run flask db_create || : ; \ + poetry run flask db_init ; \ + cp -prf instance orig + # if you want to hardcode this in the image: + #cp -prf instance orig && \ + #poetry run flask create_admin --nickname "admin" --password "1234567890" +COPY entrypoint.sh / +EXPOSE 8081 +CMD [ "/entrypoint.sh" ] diff --git a/README.md b/README.md new file mode 100644 index 0000000..80bd986 --- /dev/null +++ b/README.md @@ -0,0 +1,48 @@ + + +# Overview +This project consists of the elements to assemble a [docker](https://www.docker.com/) image and [docker-compose](https://docs.docker.com/compose/) instructions of [newspipe](https://git.sr.ht/~cedric/newspipe), the rss feed aggregator web app. + +# Why this project exists +Of category [awesome-selfhosted#feed-readers](https://github.com/awesome-selfhosted/awesome-selfhosted#feed-readers), only so many projects where written in Python/Flask, and of those (including [JARR](https://1pxsolidblack.pl/jarr-en.html) and [Temboz](https://github.com/fazalmajid/temboz)), newspipe was the only one I could get installed at all, which I did in a container because I didn't want to contaminate any real system with the likes of npm and some of the other dependencies of this app. + +# Using +Basic docker experience should suffice. You can make a directory, e.g., `instance`, to mount inside the container which will receive the initial configurations from the app, which you can then configure before restarting. + + docker run -p 5004:5004 --mount type=bind,source=./instance,destination=/newspipe/instance -it --rm newspipe:latest entrypoint.sh create_admin admin "1234567890" + +# Operations +## Create admin user +If you are using bare docker: + + docker run -p 5004:5004 --mount type=bind,source=./instance,destination=/newspipe/instance -it --rm newspipe:latest entrypoint.sh create_admin admin "1234567890" + +Or if it is currently running in docker-compose: + + docker-compose exec newspipe entrypoint.sh create_admin admin "123456789" + +# Improve +Future improvements include: + +* add option for using postgresql in networked container +* (underlying project: add ldap auth) + +# References + +1. +2. +3. FreeIPA auth (ldap+kerberos) for a different rss reader, in a different language diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..492dc69 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,21 @@ +version: '3.5' +# File: docker-compose.yml +# Project: newspipe-docker +# Startdate: 2023-06-15-5 14:52 +# +services: + newspipe: + build: . + image: newspipe:latest + ports: + - 5004:5004 + environment: + ADMIN_NICKNAME: "admin" + ADMIN_PASSWORD: "1234567890" + NEWSPIPE_HOST: "0.0.0.0" + NEWSPIPE_PORT: 5004 + NEWSPIPE_BRANCH: "stackrpms-branding" + volumes: + # Enable this if you wish to develop the app live, after git cloning to this ./git directory. + #- "./git:/newspipe" + - "./instance:/newspipe/instance" diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..7e67c87 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,32 @@ +#!/bin/sh +# File: entrypoint.sh +# Project: newspipe-docker +# Startdate: 2023-06-15 + +# For first run: +test ! -f /newspipe/instance/config.py && { cp -pf /newspipe/orig/config.py /newspipe/instance/ 2>/dev/null ; } +test ! -f /newspipe/instance/sqlite.py && { cp -pf /newspipe/orig/sqlite.py /newspipe/instance/ 2>/dev/null ; } +test ! -f /newspipe/instance/newspipe.db && { cp -pf /newspipe/orig/newspipe.db /newspipe/instance/ 2>/dev/null ; } +test -z "${NEWSPIPE_BRANCH}" && NEWSPIPE_BRANCH=ldap-auth + +# Options +case "${1}" in + "init" | "create_admin") + _nick="${2:-${ADMIN_NICKNAME}}" + _pass="${3:-${ADMIN_PASSWORD}}" + poetry run flask create_admin --nickname "${_nick}" --password "${_pass}" + ;; + *) + cd /newspipe + git fetch || : ; + git checkout "${NEWSPIPE_BRANCH}" || { echo "Invalid branch ${NEWSPIPE_BRANCH}" 1>&2 ; exit 1 ; } + git pull || : ; + _host="${1:-${NEWSPIPE_HOST}}" + _port="${2:-${NEWSPIPE_PORT}}" + set -x + # If you need to add new pip packages quickly: + #poetry run pip3 install dnspython + poetry run flask db_init || : + poetry run flask run -h "${_host:-0.0.0.0}" -p "${_port:-8081}" + ;; +esac -- cgit