dist: initial dist files for alpine, archlinux and debian

This commit is contained in:
Jesse Chan
2021-01-31 13:00:18 +08:00
parent c98ba918cd
commit fec2ce8547
17 changed files with 365 additions and 0 deletions

66
distribution/README.md Normal file
View File

@@ -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.

View File

@@ -0,0 +1,26 @@
# Maintainer: Jesse Chan <jc@linux.com>
# Contributor: Jesse Chan <jc@linux.com>
_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"
}

View File

@@ -0,0 +1,39 @@
# Maintainer: Jesse Chan <jc@linux.com>
# Contributor: Jesse Chan <jc@linux.com>
_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"
}

View File

View File

@@ -0,0 +1,25 @@
Source: flood
Maintainer: Jesse Chan <jc@linux.com>
Uploaders: Jesse Chan <jc@linux.com>
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.

View File

@@ -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 <tpot@hpe.com>
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 <https://www.gnu.org/licenses/>.
.
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.

View File

@@ -0,0 +1,3 @@
README.md
CHANGELOG.md
SECURITY.md

View File

@@ -0,0 +1,5 @@
[DEFAULT]
pristine-tar = True
[import-orig]
filter = [ '.gitignore', '.travis.yml', '.git*' ]

View File

@@ -0,0 +1,2 @@
bin
lib

View File

@@ -0,0 +1 @@
flood/bin/flood /usr/bin/flood

View File

@@ -0,0 +1,8 @@
#!/usr/bin/make -f
# -*- makefile -*-
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
%:
dh $@ --with nodejs

View File

@@ -0,0 +1 @@
3.0 (quilt)

View File

@@ -0,0 +1,5 @@
if [ -d bin ]; then
./bin/flood --version
else
flood --version
fi

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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:
<pre>
/usr/lib/node_modules/flood<b>/dist/assets</b>
</pre>
## Serve from the root
For example:
<pre>
<b>subdomain</b>.your-domain.com
</pre>
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:
<pre>
your-domain.com<b>/flood/</b>
<b></b>
</pre>
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;
```