Uberspace / lab

The Uberlab provides various tutorials - written by you! - on how to run software and tools on Uberspace 7.
https://lab.uberspace.de
Other
309 stars 407 forks source link

[funkwhale] Add guide for funkwhale #839

Open Stunkymonkey opened 3 years ago

Stunkymonkey commented 3 years ago

https://funkwhale.audio/

Systemsemaphore commented 3 years ago

According to https://docs.funkwhale.audio/installation/ there is a Quick install method:

To install the latest version of Funkwhale on a recent Debian or Ubuntu server, run:

sudo apt-get update
sudo apt-get install curl
sudo sh -c "$(curl -sSL https://get.funkwhale.audio/)"

Correct me if I'm wrong, but to my knowledge this won't work. So I had a look at Alternative installation methods, starting with External dependencies:

On Debian-like systems, you would install the database server like this:

sudo apt-get install postgresql postgresql-contrib

On Arch Linux and its derivatives:

sudo pacman -S postgresql

See above, to my knowledge this won't work with Uberspace, you would need a VPS or something similar for this. Same goes for Debian and Arch Linux installation and Docker installation.

There is one last method called Systemd configuration ( https://docs.funkwhale.audio/installation/systemd.html ) which uses services. To my knowledge, you can create services on your Uberspace, but I haven't tested this installation method yet.

Nevermind that though, because the hardware requirements for funkwhale are quite high:

Funkwhale is not especially CPU hungry. On a dockerized instance with 2 CPUs and a few active users, the memory footprint is around ~500Mb:

I don't know if there are any rules in place considering RAM usage per user, but I guess it might cause problems if multiple users use funkwhale on a single host.

owzim commented 2 years ago

Any update on this? Is it possible? Is it not? A response from ubernauten would be cool.

thisven commented 2 years ago

To install the latest version of Funkwhale on a recent Debian or Ubuntu server, run:

sudo apt-get update
sudo apt-get install curl
sudo sh -c "$(curl -sSL https://get.funkwhale.audio/)"

Correct me if I'm wrong, but to my knowledge this won't work. So I had a look at Alternative installation methods, starting with External dependencies: On Debian-like systems, you would install the database server like this: sudo apt-get install postgresql postgresql-contrib On Arch Linux and its derivatives: sudo pacman -S postgresql

See above, to my knowledge this won't work with Uberspace, you would need a VPS or something similar for this. Same goes for Debian and Arch Linux installation and Docker installation.

Yeah, all of those needs root priviledges to install packages, but I found udocker with fake chroot as used in LibreOffice Online guide. The docker image funkwhale/all-in-one, also found in docker hub, seems to be deprecated since version 1.3, but there's a funkwhale/funkwhale image.

thisven commented 2 years ago

So far I've managed to install udocker release 1.3.1 as described and setup the container using:

udocker pull funkwhale/funkwhale
udocker create --name=funkwhale funkwhale/funkwhale

And it seems that I'd be able to run it with udocker run funkwhale, if e.g. _FUNKWHALEHOSTNAME environment variable is set. So next part is to investigate this, setup PostgreSQL as well as Redis and configure the container to use them as I assume that the funkwhale/funkwhale image at docker hub is the funkwhale main compoment without those services and I don't know if the instructions for Multi-Container installation apply and/or are feasible, if the both services can run natively.

thisven commented 2 years ago

After some fiddling I tried another approach based on the Debian install method to get Funkwhale running on and it seems to be running, but I can't open it's web frontend due to an internal server error (Error code 500).

thisven commented 2 years ago

Anyway I'd like to share how I got so far and maybe somebody else can proceed and find the problem:

The following steps are based on the Debian installation method.

TODO: Dependency check?

  1. Create an installation directory and subfolders:

    mkdir ~/funkwhale
    cd ~/funkwhale
    mkdir -p config api data/static data/media data/music front
  2. Obtain and extract current API files:

    curl -L -o "api-1.1.4.zip" "https://dev.funkwhale.audio/funkwhale/funkwhale/-/jobs/artifacts/1.1.4/download?job=build_api"
    unzip "api-1.1.4.zip" -d extracted
    mv extracted/api/* api/
    rm -rf extracted
  3. Obtain and extract frontend files:

    curl -L -o "front-1.1.4.zip" "https://dev.funkwhale.audio/funkwhale/funkwhale/-/jobs/artifacts/1.1.4/download?job=build_front"
    unzip "front-1.1.4.zip" -d extracted
    mv extracted/front .
    rm -rf extracted
  4. Create and load a virtual python environment:

    python3 -m venv ~/funkwhale/virtualenv
    source ~/funkwhale/virtualenv/bin/activate
  5. Upgrade pip to the latest version to avoid "Cache entry deserialization failed, entry ignored": pip3 install --upgrade pip

  6. Install python dependencies:

    pip3 install wheel
    pip3 install -r api/requirements.txt
  7. Clone sample configuration file: curl -L -o config/.env "https://dev.funkwhale.audio/funkwhale/funkwhale/raw/master/deploy/env.prod.sample"

  8. Generate and note a secret for django: openssl rand -base64 45

  9. Restrict access to config file and edit it:

    chmod 600 ~/funkwhale/config/.env
    nano ~/funkwhale/config/.env
  10. Uncomment and change the following values in the config file (replace "isabell" in paths):

    FUNKWHALE_API_IP=0.0.0.0
    FUNKWHALE_WEB_WORKERS=1
    FUNKWHALE_HOSTNAME=isabell.uber.space
    DATABASE_URL=postgresql://funkwhale:<postgresql-user-password>@localhost:5432/funkwhale
    CACHE_URL=redis:///home/isabell/.redis/sock?db=1
    CELERY_BROKER_URL=redis+socket:///home/isabell/.redis/sock?virtual_host=1
    CELERYD_CONCURRENCY=1
    MEDIA_ROOT=/home/isabell/funkwhale/data/media
    STATIC_ROOT=/home/isabell/funkwhale/data/static
    DJANGO_SECRET_KEY=012345678901234567890123456789012345678901234567890123456789
    MUSIC_DIRECTORY_PATH=/home/isabell/funkwhale/data/music
    MUSIC_DIRECTORY_SERVE_PATH=/home/isabell/funkwhale/data/music
    FUNKWHALE_FRONTEND_PATH=/home/isabell/funkwhale/front/dist
  11. Enable database extensions as described in external dependencies guide by following the lab guide: Check extensions availability:

    ls -rtl /usr/pgsql-13/share/extension/unaccent*
    ls -rtl /usr/pgsql-13/share/extension/citext*

    Setup PostgreSQL, create funkwhale database and user as described in lab guide:

    createuse -P funkwhale
    createdb --encoding=UTF8 --owner=funkwhale --template=template0 funkwhale

    Enable extension as database cluster admin:

    psql funkwhale -c 'CREATE EXTENSION "unaccent";'
    psql funkwhale -c 'CREATE EXTENSION "citext";'
  12. Refer to the lab guide for redis setup.

  13. Create database, superuser and collect static files:

    python api/manage.py migrate
    python api/manage.py createsuperuser
    python api/manage.py collectstatic
  14. Setup services based on systemd units in official documentation, but use supervisord as described in Uberspace manual. Additional options may be found in supervisord documentation.

~/etc/services.d/funkwhale-server.ini

[program:funkwhale-server]
directory=%(ENV_HOME)s/funkwhale/api
command=/bin/bash -c "source %(ENV_HOME)s/funkwhale/config/.env && %(ENV_HOME)s/funkwhale/virtualenv/bin/gunicorn config.asgi:application -w ${FUNKWHALE_WEB_WORKERS} -k uvicorn.workers.UvicornWorker -b ${FUNKWHALE_API_IP}:${FUNKWHALE_API_PORT}"
autostart=yes
autorestart=yes
stopasgroup=true
killasgroup=true

~/etc/services.d/funkwhale-worker.ini

[program:funkwhale-worker]
directory=%(ENV_HOME)s/funkwhale/api
command=/bin/bash -c "source %(ENV_HOME)s/funkwhale/config/.env && %(ENV_HOME)s/funkwhale/virtualenv/bin/celery -A funkwhale_api.taskapp worker -l INFO --concurrency=${CELERYD_CONCURRENCY}"
autostart=yes
autorestart=yes
stopasgroup=true
killasgroup=true

~/etc/services.d/funkwhale-beat.ini

[program:funkwhale-beat]
directory=%(ENV_HOME)s/funkwhale/api
command=/bin/bash -c "source %(ENV_HOME)s/funkwhale/config/.env && %(ENV_HOME)s/funkwhale/virtualenv/bin/celery -A funkwhale_api.taskapp beat -l INFO"
autostart=yes
autorestart=yes
stopasgroup=true
killasgroup=true
  1. Reread and update supervisord services
    supervisorctl reread
    supervisorctl update
    supervisorctl status
  2. A domain must be configured, check with uberspace web domain list.
  3. Set a web backend for port 5000 (replace domain parameter): uberspace web backend set --http --port 5000 isabell.uber.space