Unified repository for both the API and the front-end
Go to file
Eliot Berriot fba9a5c97e
Merge tag '0.8' into develop
0.8 (2018-04-02)
----------------

Features:

- Add a detail page for radios (#64)
- Implemented page title binding (#1)
- Previous Track button restart playback after 3 seconds (#146)

Enhancements:

- Added credits to Francis Gading for the logotype (#101)
- API endpoint for fetching instance activity and updated timeline to use this
  new endpoint (#141)
- Better error messages in case of missing environment variables (#140)
- Implemented a @test@yourfunkwhaledomain bot to ensure federation works
  properly. Send it "/ping" and it will answer back :)
- Queue shuffle now apply only to tracks after the current one (#97)
- Removed player from queue tab and consistently show current track in queue
  (#131)
- We now restrict some usernames from being used during signup (#139)

Bugfixes:

- Better error handling during file import (#120)
- Better handling of utf-8 filenames during file import (#138)
- Converted favicon from .ico to .png (#130)
- Upgraded to Python 3.6 to fix weird but harmless weakref error on django task
  (#121)

Documentation:

- Documented the upgrade process (#127)

Preparing for federation
^^^^^^^^^^^^^^^^^^^^^^^^

Federation of music libraries is one of the most asked feature.
While there is still a lot of work to do, this version includes
the foundation that will enable funkwhale servers to communicate
between each others, and with other federated software, such as
Mastodon.

Funkwhale will use ActivityPub as it's federation protocol.

In order to prepare for federation (see #136 and #137), new API endpoints
have been added under /federation and /.well-known/webfinger.

For these endpoints to work, you will need to update your nginx configuration,
and add the following snippets::

    location /federation/ {
        include /etc/nginx/funkwhale_proxy.conf;
        proxy_pass   http://funkwhale-api/federation/;
    }

    location /.well-known/webfinger {
        include /etc/nginx/funkwhale_proxy.conf;
        proxy_pass   http://funkwhale-api/.well-known/webfinger;
    }

This will ensure federation endpoints will be reachable in the future.
You can of course skip this part if you know you will not federate your instance.

A new ``FEDERATION_ENABLED`` env var have also been added to control wether
federation is enabled or not on the application side. This settings defaults
to True, which should have no consequencies at the moment, since actual
federation is not implemented and the only available endpoints are for
testing purposes.

Add ``FEDERATION_ENABLED=false`` to your .env file to disable federation
on the application side.

The last step involves generating RSA private and public keys for signing
your instance requests on the federation. This can be done via::

    # on docker setups
    docker-compose run --rm api python manage.py generate_keys --no-input

    # on non-docker setups
    source /srv/funkwhale/virtualenv/bin/activate
    source /srv/funkwhale/load_env
    python manage.py generate_keys --no-input

To test and troobleshoot federation, we've added a bot account. This bot is available at @test@yourinstancedomain,
and sending it "/ping", for example, via Mastodon, should trigger
a response.
2018-04-02 20:05:09 +02:00
api Removed factory import 2018-04-02 19:46:25 +02:00
changes Version bump and Changelog 2018-04-02 20:04:38 +02:00
demo Demo is back 2018-03-06 21:33:50 +01:00
deploy Nginx conf and upgrade notes to prepare federation 2018-03-29 23:45:19 +02:00
docker/nginx Set host properly on nginx dev container 2018-03-31 17:47:15 +02:00
docs Minor tweaks to upgrade documentation 2018-03-23 12:15:21 +01:00
front Merge branch 'previous-button' into 'develop' 2018-04-01 18:15:25 +00:00
.dockerignore Initial commit that merge both the front end and the API in the same repository 2017-06-23 23:00:42 +02:00
.editorconfig Initial commit that merge both the front end and the API in the same repository 2017-06-23 23:00:42 +02:00
.env.dev Moved duplicated dev variables to env file 2018-03-31 13:20:42 +02:00
.gitattributes Initial commit that merge both the front end and the API in the same repository 2017-06-23 23:00:42 +02:00
.gitignore Local .env logic for webpack custom port 2018-03-29 19:55:24 +02:00
.gitlab-ci.yml Use redis in CI 2018-04-02 19:24:01 +02:00
CHANGELOG Version bump and Changelog 2018-04-02 20:04:38 +02:00
CONTRIBUTORS.txt Initial commit that merge both the front end and the API in the same repository 2017-06-23 23:00:42 +02:00
LICENSE Initial commit that merge both the front end and the API in the same repository 2017-06-23 23:00:42 +02:00
README.rst Local .env logic for webpack custom port 2018-03-29 19:55:24 +02:00
dev.yml Moved duplicated dev variables to env file 2018-03-31 13:20:42 +02:00
pyproject.toml Version bump and Changelog 2018-04-02 20:04:38 +02:00

README.rst

Funkwhale
=============

A self-hosted tribute to Grooveshark.com.

LICENSE: BSD

Getting help
------------

We offer various Matrix.org rooms to discuss about funkwhale:

- `#funkwhale:matrix.org <https://riot.im/app/#/room/#funkwhale:matrix.org>`_ for general questions about funkwhale
- `#funkwhale-dev:matrix.org <https://riot.im/app/#/room/#funkwhale-dev:matrix.org>`_ for development-focused discussion

Please join those rooms if you have any questions!

Running the development version
-------------------------------

If you want to fix a bug or implement a feature, you'll need
to run a local, development copy of funkwhale.

We provide a docker based development environment, which should
be both easy to setup and work similarly regardless of your
development machine setup.

Instructions for bare-metal setup will come in the future (Merge requests
are welcome).

Installing docker and docker-compose
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

This is already cover in the relevant documentations:

- https://docs.docker.com/install/
- https://docs.docker.com/compose/install/

Cloning the project
^^^^^^^^^^^^^^^^^^^

Visit https://code.eliotberriot.com/funkwhale/funkwhale and clone the repository using SSH or HTTPS. Exemple using SSH::

    git clone ssh://git@code.eliotberriot.com:2222/funkwhale/funkwhale.git
    cd funkwhale


A note about branches
^^^^^^^^^^^^^^^^^^^^^

Next release development occurs on the "develop" branch, and releases are made on the "master" branch. Therefor, when submitting Merge Requests, ensure you are merging on the develop branch.


Working with docker
^^^^^^^^^^^^^^^^^^^

In developpement, we use the docker-compose file named ``dev.yml``, and this is why all our docker-compose commands will look like this::

    docker-compose -f dev.yml logs

If you do not want to add the ``-f dev.yml`` snippet everytime, you can run this command before starting your work::

    export COMPOSE_FILE=dev.yml


Building the containers
^^^^^^^^^^^^^^^^^^^^^^^

On your initial clone, or if there have been some changes in the
app dependencies, you will have to rebuild your containers. This is done
via the following command::

    docker-compose -f dev.yml build


Creating your env file
^^^^^^^^^^^^^^^^^^^^^^

We provide a working .env.dev configuration file that is suitable for
development. However, to enable customization on your machine, you should
also create a .env file that will hold your personal environment
variables (those will not be commited to the project).

Create it like this::

    touch .env


Database management
^^^^^^^^^^^^^^^^^^^

To setup funkwhale's database schema, run this::

    docker-compose -f dev.yml run --rm api python manage.py migrate

This will create all the tables needed for the API to run proprely.
You will also need to run this whenever changes are made on the database
schema.

It is safe to run this command multiple times, so you can run it whenever
you fetch develop.


Development data
^^^^^^^^^^^^^^^^

You'll need at least an admin user and some artists/tracks/albums to work
locally.

Create an admin user with the following command::

    docker-compose -f dev.yml run --rm api python manage.py createsuperuser

Injecting fake data is done by running the fllowing script::

    artists=25
    command="from funkwhale_api.music import fake_data; fake_data.create_data($artists)"
    echo $command | docker-compose -f dev.yml run --rm api python manage.py shell -i python

The previous command will create 25 artists with random albums, tracks
and metadata.


Launch all services
^^^^^^^^^^^^^^^^^^^

Then you can run everything with::

    docker-compose -f dev.yml up

This will launch all services, and output the logs in your current terminal window.
If you prefer to launch them in the background instead, use the ``-d`` flag, and access the logs when you need it via ``docker-compose -f dev.yml logs --tail=50 --follow``.

Once everything is up, you can access the various funkwhale's components:

- The Vue webapp, on http://localhost:8080
- The API, on http://localhost:8080/api/v1/
- The django admin, on http://localhost:8080/api/admin/


Running API tests
^^^^^^^^^^^^^^^^^

To run the pytest test suite, use the following command::

    docker-compose -f dev.yml run --rm api pytest

This is regular pytest, so you can use any arguments/options that pytest usually accept::

    # get some help
    docker-compose -f dev.yml run --rm api pytest -h
    # Stop on first failure
    docker-compose -f dev.yml run --rm api pytest -x
    # Run a specific test file
    docker-compose -f dev.yml run --rm api pytest tests/test_acoustid.py


Running front-end tests
^^^^^^^^^^^^^^^^^^^^^^^

To run the front-end test suite, use the following command::

    docker-compose -f dev.yml run --rm front yarn run unit

We also support a "watch and test" mode were we continually relaunch
tests when changes are recorded on the file system::

    docker-compose -f dev.yml run --rm front yarn run unit-watch

The latter is especially useful when you are debugging failing tests.

.. note::

    The front-end test suite coverage is still pretty low


Stopping everything
^^^^^^^^^^^^^^^^^^^

Once you're down with your work, you can stop running containers, if any, with::

    docker-compose -f dev.yml stop


Removing everything
^^^^^^^^^^^^^^^^^^^

If you want to wipe your development environment completely (e.g. if you want to start over from scratch), just run::

    docker-compose -f dev.yml down -v

This will wipe your containers and data, so please be careful before running it.

You can keep your data by removing the ``-v`` flag.


Typical workflow for a merge request
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

0. Fork the project if you did not already or if you do not have access to the main repository
1. Checkout the development branch and pull most recent changes: ``git checkout develop && git pull``
2. Create a dedicated branch for your work ``42-awesome-fix``. It is good practice to prefix your branch name with the ID of the issue you are solving.
3. Work on your stuff
4. Commit small, atomic changes to make it easier to review your contribution
5. Add a changelog fragment to summarize your changes: ``echo "Implemented awesome stuff (#42)" > changes/changelog.d/42.feature"``
6. Push your branch
7. Create your merge request
8. Take a step back and enjoy, we're really grateful you did all of this and took the time to contribute!