Install Funkwhale using Docker
Funkwhale is available as a containerized application. This enables you to run each service in containers rather than install them on your server. You can run Funkwhale using Docker.
Note
This guide assumes you are using a Debian-based system.
Before you begin
Set a
FUNKWHALE_VERSION
variable to the version you want to install. You will use this version for all commands in this guide.export FUNKWHALE_VERSION=1.4.0
Install Docker and the compose plugin.
Install
curl
.sudo apt update # update apt cache sudo apt install curl
1. Create a Funkwhale user
It’s good practice to create a user on your server for Funkwhale administration. Doing this makes it easy to make sure you’re running commands from the right place. Follow these steps to set up your user.
Create the
funkwhale
user and set its shell tobash
and its home directory to/srv/funkwhale
.sudo useradd --system --shell /bin/bash --create-home --home-dir /srv/funkwhale funkwhale
Note
To perform any tasks as the funkwhale
user, prefix your commands with sudo -u funkwhale
.
sudo -u funkwhale <command>
Or log in as funkwhale
with sudo su funkwhale
before running your commands.
sudo su funkwhale
<command>
That’s it! You’ve created your funkwhale
user.
2. Download the project files
Create the project directory structure.
mkdir /srv/funkwhale /srv/funkwhale/nginx
Navigate to the project directory
cd /srv/funkwhale
Download the
docker compose
template. This contains information about the containers and how they work together.curl -L -o /srv/funkwhale/docker-compose.yml "https://dev.funkwhale.audio/funkwhale/funkwhale/raw/${FUNKWHALE_VERSION}/deploy/docker-compose.yml"
That’s it! You’ve set up your project files.
3. Set up your environment file
The environment file contains options you can use to control your Funkwhale pod. Follow these steps to get a working environment up and running.
Download the
.env
template to your/srv/funkwhale
directory.curl -L -o /srv/funkwhale/.env "https://dev.funkwhale.audio/funkwhale/funkwhale/raw/${FUNKWHALE_VERSION}/deploy/env.prod.sample"
Update
FUNKWHALE_VERSION
in the.env
file to the$FUNKWHALE_VERSION
variable you set earlier.sed -i "s/FUNKWHALE_VERSION=latest/FUNKWHALE_VERSION=$FUNKWHALE_VERSION/" .env
Reduce the permissions on your
.env
file to600
. This means that only your user can read and write this file.chmod 600 /srv/funkwhale/.env
Generate a secret key for Django. This keeps your Funkwhale data secure. Do not share this key with anybody.
openssl rand -base64 45
Open the
.env
file in a text editor. For this example, we will usenano
.nano /srv/funkwhale/.env
Update the following settings:
Paste the secret key in the
DJANGO_SECRET_KEY
field.Populate the
FUNKWHALE_HOSTNAME
field with the URL of your server.
Hit ctrl + x then y to save the file and close
nano
.
You’re done! Your environment file is now ready to go. You can check out a full list of configuration options in our Environment file guide.
4. Set up Funkwhale
Once you’ve filled in your environment file, you can set up Funkwhale. Follow these steps to create your database and create a superuser.
Pull the containers to download all the required services.
cd /srv/funkwhale docker compose pull
Bring up the database container so you can run the database migrations.
docker compose up -d postgres
Run the database migrations.
docker compose run --rm api funkwhale-manage migrate
Note
You may see the following warning when applying migrations:
"Your models have changes that are not yet reflected in a migration, and so won't be applied."
You can safely ignore this warning.
Create your superuser.
docker compose run --rm api funkwhale-manage fw users create --superuser
Launch all the containers to bring up your pod.
docker compose up -d
That’s it! Your Funkwhale pod is now up and running.
5. Set up your reverse proxy
Funkwhale requires a reverse proxy to serve content to users. We recommend using Nginx to handle requests to your container. Follow this guide to install an Nginx configuration using details from your .env
file.
Note
Before you begin Nginx isn’t preinstalled on Debian. You can install it by running the following commands:
$ sudo apt update
$ sudo apt install nginx
Log in to a root shell to make changes to the config files
$ sudo su
Download the new Nginx templates from Funkwhale
# curl -L -o /etc/nginx/funkwhale_proxy.conf "https://dev.funkwhale.audio/funkwhale/funkwhale/raw/$FUNKWHALE_VERSION/deploy/funkwhale_proxy.conf" # curl -L -o /etc/nginx/sites-available/funkwhale.template "https://dev.funkwhale.audio/funkwhale/funkwhale/raw/$FUNKWHALE_VERSION/deploy/docker.proxy.template"
Update the Nginx configuration with details from your
.env
file# set -a && source /srv/funkwhale/config/.env && set +a envsubst "`env | awk -F = '{printf \" $%s\", $$1}'`" \ < /etc/nginx/sites-available/funkwhale.template \ > /etc/nginx/sites-available/funkwhale.conf
Check the configuration file to make sure the template values have been updated properly
# grep '${' /etc/nginx/sites-available/funkwhale.conf
Create a symbolic link to the
sites-enabled
directory to enable your configuration# ln -s /etc/nginx/sites-available/funkwhale.conf /etc/nginx/sites-enabled/
Reload Nginx
# systemctl reload nginx
That’s it! You’ve created your Nginx file.
Override default Nginx templates
The frontend container ships default Nginx templates which serve content to the reverse proxy. These files read variables from your .env
file to correctly serve content. In some cases, you might want to override these defaults. To do this:
Create a
/srv/funkwhale/nginx
directory to house your files.mkdir /srv/funkwhale/nginx
Download the Nginx template files to the
/srv/funkwhale/nginx
directory.curl -L -o /srv/funkwhale/nginx/funkwhale.template "https://dev.funkwhale.audio/funkwhale/funkwhale/raw/${FUNKWHALE_VERSION}/front/docker/funkwhale.conf.template" curl -L -o /srv/funkwhale/nginx/funkwhale_proxy.conf "https://dev.funkwhale.audio/funkwhale/funkwhale/raw/${FUNKWHALE_VERSION}/front/docker/funkwhale_proxy.conf"
Make any changes you want to make to these files.
Open your
docker-compose.yml
file in a text editor. For this example, we will usenano
.nano /srv/funkwhale/docker-compose.yml
Uncomment the lines in the
volumes
section of thefront
service by deleting the#
in front of them.version: "3" services: front: volumes: # Uncomment if you want to use your previous nginx config, please let us # know what special configuration you need, so we can support it with out # upstream nginx configuration! - "./nginx/funkwhale.template:/etc/nginx/conf.d/funkwhale.template:ro" - "./nginx/funkwhale_proxy.conf:/etc/nginx/funkwhale_proxy.conf:ro"
Bring the
front
container up again to pick up the changes.docker compose up -d front
That’s it! The container mounts your custom nginx files and uses its values to serve Funkwhale content. To revert to the default values, comment out the volumes by adding a #
in front of them and bring the front
container back up.
6. Set up TLS
To enable your users to connect to your pod securely, you need to set up TLS. To do this, we recommend using certbot.
Install certbot
sudo apt-get update sudo apt-get install certbot python3-certbot-nginx
Run certbot
sudo certbot --nginx -d $FUNKWHALE_HOSTNAME
That’s it! certbot renews your certificate every 60 days, so you don’t need to worry about renewing it.