diff --git a/distribution/README.md b/distribution/README.md new file mode 100644 index 00000000..f84b1c49 --- /dev/null +++ b/distribution/README.md @@ -0,0 +1,66 @@ +# Distributing Flood + +This directory contains files related to distribution of Flood. Some are being used by continuous integration scripts of this project to release a certain version of Flood. Some are merely examples that have been created to make it easier for potential contributors to maintain a package of Flood for their distributions. + +In general, Flood has two release channels: `master` and `latest`: + +- `master` (rolling) channel is handled by CI scripts that are triggered whenever there is a push to `master` branch. +- `latest` (release) channel is versioned (eg. `4.0.0`), in accordance with [semver](https://semver.org/). + +### npm (Node Package Manager) + +`npm` is the primary method of distribution. Flood is published to two packages: + +- `master` -> [npmjs.com/@jesec/flood](https://www.npmjs.com/@jesec/flood) +- `latest` -> [npmjs.com/flood](https://www.npmjs.com/flood) + +Other distribution methods may rely on builds published on `npm`. + +### Standalone executables + +Flood uses [pkg](https://github.com/jesec/pkg) to generate self-contained executables that bundles Flood with Node.js runtime. Generated executables are published to two locations: + +- `master` -> [Github Actions](https://github.com/jesec/flood/actions?query=workflow%3A%22Publish+rolling+build%22) ([permalink via nightly.link](https://nightly.link/jesec/flood/workflows/publish-rolling/master)) +- `latest` -> [Github Releases](https://github.com/jesec/flood/releases) + +Other distribution methods may rely on generated standalone executables. + +### Containers + +`containers` folder hosts files required to build a container image. Currently there are three variants that are published in two stages: + +**Variants:** + +- Default (`latest`, `master`, versioned tags): Node.js Current on Alpine Linux (parent image: `node:alpine`) +- Debugging (`*-dbg`): Node.js Current on Alpine Linux (parent image: `node:alpine`) + - Contains full sources (not minimized) and development dependencies +- Distroless (`*-distroless`): Node.js Active LTS (no parent image) + - Contains only `flood` and its runtime dependencies + - No shell, no package manager, no libc, no coreutils + +**Stages:** + +- `flood` ([jesec/flood](https://hub.docker.com/r/jesec/flood)) +- `rtorrent-flood` ([jesec/rtorrent-flood](https://hub.docker.com/r/jesec/rtorrent-flood)) + - Bundles [rtorrent](https://hub.docker.com/r/jesec/rtorrent) + +### Misc + +`shared` folder hosts files that may be useful in a package, in addition to: + +``` +CHANGELOG.md +LICENSE +README.md +SECURITY.md +``` + +However, there might be more recent ones in user-contributed [wiki](https://github.com/jesec/flood/wiki) of this project. + +### Links to downstream repositories of packages + +TBD. + +### Contributing + +Contributions are welcome. diff --git a/distribution/alpine/flood/APKBUILD b/distribution/alpine/flood/APKBUILD new file mode 100644 index 00000000..f652d772 --- /dev/null +++ b/distribution/alpine/flood/APKBUILD @@ -0,0 +1,26 @@ +# Maintainer: Jesse Chan +# Contributor: Jesse Chan +_npmname=flood +_npmver=4.3.1 +pkgname=flood +pkgver=$_npmver +pkgrel=0 +pkgdesc="A modern web UI for various torrent clients" +arch="noarch !mips !mips64" # blocked by nodejs +url="https://flood.js.org" +license="GPL-3.0-only" +depends="nodejs" +makedepends="npm" +source="https://registry.npmjs.org/$_npmname/-/$_npmname-$_npmver.tgz" +options="!check" +builddir="$srcdir/package" + +unpack() { + # skipping unpacking, installing archive directly + verify +} + +package() { + npm install -g --user root --prefix "$pkgdir"/usr "$srcdir"/$_npmname-$_npmver.tgz + chown -R root "$pkgdir" +} diff --git a/distribution/archlinux/flood/PKGBUILD b/distribution/archlinux/flood/PKGBUILD new file mode 100644 index 00000000..7a7dba87 --- /dev/null +++ b/distribution/archlinux/flood/PKGBUILD @@ -0,0 +1,39 @@ +# Maintainer: Jesse Chan +# Contributor: Jesse Chan +_npmname=flood +_npmver=4.3.1 +pkgname=flood +pkgver=$_npmver +pkgrel=0 +pkgdesc="A modern web UI for various torrent clients" +arch=(any) +url="https://flood.js.org" +license=('GPL3') +depends=('nodejs') +makedepends=('jq' 'npm') +optdepends=('mediainfo') +source=(https://registry.npmjs.org/$_npmname/-/$_npmname-$_npmver.tgz) +sha1sums=(.) +noextract=("$_npmname-$_npmver.tgz") + +package() { + # Thanks jeremejevs and je-vv for the pointers on these! + npm install -g --user root --cache "${srcdir}/npm-cache" --prefix "$pkgdir/usr" "$srcdir/$_npmname-$pkgver.tgz" + + # Fix permissions + find "$pkgdir"/usr -type d -exec chmod 755 {} + + + # npm gives ownership of ALL FILES to build user + # https://bugs.archlinux.org/task/63396 + chown -R root:root "${pkgdir}" + + # Remove references to pkgdir + find "$pkgdir" -type f -name package.json -print0 | xargs -0 sed -i "/_where/d" + + # Remove references to srcdir + local tmppackage="$(mktemp)" + local pkgjson="$pkgdir/usr/lib/node_modules/$_npmname/package.json" + jq '.|=with_entries(select(.key|test("_.+")|not))' "$pkgjson" > "$tmppackage" + mv "$tmppackage" "$pkgjson" + chmod 644 "$pkgjson" +} diff --git a/distribution/debian/flood/changelog b/distribution/debian/flood/changelog new file mode 100644 index 00000000..e69de29b diff --git a/distribution/debian/flood/control b/distribution/debian/flood/control new file mode 100644 index 00000000..7ee16dbb --- /dev/null +++ b/distribution/debian/flood/control @@ -0,0 +1,25 @@ +Source: flood +Maintainer: Jesse Chan +Uploaders: Jesse Chan +Section: javascript +Priority: optional +Testsuite: autopkgtest-pkg-nodejs +Build-Depends: debhelper-compat (= 12), + pkg-js-tools (>= 0.9.20~) +Standards-Version: 4.5.0 +Vcs-Browser: https://github.com/jesec/flood +Vcs-Git: https://github.com/jesec/flood.git +Homepage: https://github.com/jesec/flood +Rules-Requires-Root: no + +Package: flood +Architecture: all +Depends: ${misc:Depends}, + nodejs +Recommends: mediainfo +Description: modern web user interface for various torrent clients + Flood is a modern web user interface for various torrent clients + with a Node.js backend and React frontend. + . + Flood uses a command line interface for configuration. Run Flood + with --help argument for more details. diff --git a/distribution/debian/flood/copyright b/distribution/debian/flood/copyright new file mode 100644 index 00000000..a0c4c0c0 --- /dev/null +++ b/distribution/debian/flood/copyright @@ -0,0 +1,50 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: flood +Upstream-Contact: https://github.com/jesec/flood/issues +Source: https://github.com/jesec/flood + +Files: * +Copyright: 2015-2021 Contributors to the Flood project +License: GPL-3.0-only + +Files: distribution/debian/flood/* +Copyright: 2016 Tim Potter + 2021 Contributors to the Flood project +License: Expat + +License: GPL-3.0-only + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation, version 3. + . + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + Public License for more details. + . + You should have received a copy of the GNU General Public License along + with this program. If not, see . + . + On Debian systems, the complete text of the GNU General Public License + version 3 license can be found in "/usr/share/common-licenses/GPL-3". + +License: Expat + 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/distribution/debian/flood/docs b/distribution/debian/flood/docs new file mode 100644 index 00000000..be4e2193 --- /dev/null +++ b/distribution/debian/flood/docs @@ -0,0 +1,3 @@ +README.md +CHANGELOG.md +SECURITY.md diff --git a/distribution/debian/flood/gbp.conf b/distribution/debian/flood/gbp.conf new file mode 100644 index 00000000..b7133565 --- /dev/null +++ b/distribution/debian/flood/gbp.conf @@ -0,0 +1,5 @@ +[DEFAULT] +pristine-tar = True + +[import-orig] +filter = [ '.gitignore', '.travis.yml', '.git*' ] diff --git a/distribution/debian/flood/nodejs/files b/distribution/debian/flood/nodejs/files new file mode 100644 index 00000000..57b480f4 --- /dev/null +++ b/distribution/debian/flood/nodejs/files @@ -0,0 +1,2 @@ +bin +lib diff --git a/distribution/debian/flood/nodejs/links b/distribution/debian/flood/nodejs/links new file mode 100644 index 00000000..b09d45d5 --- /dev/null +++ b/distribution/debian/flood/nodejs/links @@ -0,0 +1 @@ +flood/bin/flood /usr/bin/flood diff --git a/distribution/debian/flood/rules b/distribution/debian/flood/rules new file mode 100755 index 00000000..20809a47 --- /dev/null +++ b/distribution/debian/flood/rules @@ -0,0 +1,8 @@ +#!/usr/bin/make -f +# -*- makefile -*- + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +%: + dh $@ --with nodejs diff --git a/distribution/debian/flood/source/format b/distribution/debian/flood/source/format new file mode 100644 index 00000000..163aaf8d --- /dev/null +++ b/distribution/debian/flood/source/format @@ -0,0 +1 @@ +3.0 (quilt) diff --git a/distribution/debian/flood/tests/pkg-js/test b/distribution/debian/flood/tests/pkg-js/test new file mode 100644 index 00000000..fe09f89c --- /dev/null +++ b/distribution/debian/flood/tests/pkg-js/test @@ -0,0 +1,5 @@ +if [ -d bin ]; then + ./bin/flood --version +else + flood --version +fi diff --git a/distribution/debian/flood/upstream/metadata b/distribution/debian/flood/upstream/metadata new file mode 100644 index 00000000..1dc8c0e7 --- /dev/null +++ b/distribution/debian/flood/upstream/metadata @@ -0,0 +1,6 @@ +--- +Archive: GitHub +Bug-Database: https://github.com/jesec/flood/issues +Repository: https://github.com/jesec/flood.git +Repository-Browse: https://github.com/jesec/flood +Bug-Submit: https://github.com/jesec/flood/issues/new diff --git a/distribution/debian/flood/watch b/distribution/debian/flood/watch new file mode 100644 index 00000000..1d0f44e9 --- /dev/null +++ b/distribution/debian/flood/watch @@ -0,0 +1,5 @@ +version=3 +opts=\ +dversionmangle=s/\+(debian|dfsg|ds|deb)(\.\d+)?$//,\ +filenamemangle=s/.*\/v?([\d\.-]+)\.tar\.gz/flood-$1.tar.gz/ \ + https://github.com/jesec/flood/tags .*/archive/v?([\d\.]+).tar.gz diff --git a/distribution/shared/flood@.service b/distribution/shared/flood@.service new file mode 100644 index 00000000..dd9271f2 --- /dev/null +++ b/distribution/shared/flood@.service @@ -0,0 +1,15 @@ +[Unit] +Description=Flood service for %I +After=network.target + +[Service] +User=%I +Group=%I +Type=simple +KillMode=process +ExecStart=/usr/bin/env flood +Restart=on-failure +RestartSec=3 + +[Install] +WantedBy=multi-user.target diff --git a/distribution/shared/nginx.md b/distribution/shared/nginx.md new file mode 100644 index 00000000..81a1526c --- /dev/null +++ b/distribution/shared/nginx.md @@ -0,0 +1,108 @@ +In order to use Flood behind a reverse proxy: + +- Forward `/api` requests to Flood's NodeJS backend server. +- Serve static assets. +- Redirects client routes (`/overview`, `/register` and `/login`) to `index.html`. + +Alternatively you may let Flood's server handle all requests. However, if you want better performance, serve static assets from the web server. + +This tutorial assumes that Flood is running at `127.0.0.1:3000`. This is configurable by `--host` and `--port` arguments. + +This tutorial assumes that Flood is installed in `/usr/lib/node_modules/flood` and as such assets are located in: + +
+/usr/lib/node_modules/flood/dist/assets
+
+ +## Serve from the root + +For example: + +
+subdomain.your-domain.com
+
+ +Your nginx config should contain these rules: + +```nginx +server_name subdomain.your-domain.com; +root /usr/lib/node_modules/flood/dist/assets; + +location /api { + proxy_pass http://127.0.0.1:3000; +} + +location / { + try_files $uri /index.html; +} +``` + +## Serve from a nested route + +Often people want to expose multiple web applications with a single nginx config. This is possible using Flood's `--baseuri` option. + +For example, when `--baseuri=/flood`, you may access Flood at: + +
+your-domain.com/flood/
+                     
+
+ +Flood frontend uses relative path so there has to be a slash at the end when you access the nested route. + +You may configure your web server to redirect users from `/flood` to `/flood/`. It is not covered by this tutorial. + +Your nginx config should contain these rules: + +```nginx +server_name your-domain.com; + +location /flood/api { + proxy_pass http://127.0.0.1:3000; +} + +location /flood/ { + alias /usr/lib/node_modules/flood/dist/assets/; + try_files $uri /flood/index.html; +} +``` + +## Disable caching for API endpoints + +API requests should not be cached. You can disable caching in nginx by adding these lines in your `location /api` block: + +```nginx +proxy_buffering off; +proxy_cache off; +``` + +## Compression + +Static assets of Flood are large. Compression can save bandwidth and make the page loading faster. + +Note that to enable compression, you must serve static assets from web server. + +```nginx +gzip on; +gzip_vary on; +gzip_proxied any; +gzip_comp_level 6; +gzip_types text/plain text/css text/xml application/json application/javascript image/x-icon; +``` + +You may also use other compression methods such as `brotli`. + +## HTTP Basic Auth + +You may opt to use HTTP basic auth. To avoid double authentication, use `auth=none` option of Flood and pre-configure client connection settings. + +https://docs.nginx.com/nginx/admin-guide/security-controls/configuring-http-basic-authentication + +``` +satisfy any; +allow 192.168.1.0/24; # Allows unauthenticated access from local network +deny all; + +auth_basic "Private Server"; +auth_basic_user_file /etc/nginx/.passwords.list; +```