8.5 KiB
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 and Docker-Compose.
This guide assumes you are using a [Debian](https://debian.org)-based system.
:local:
Before you begin
-
Set a
FUNKWHALE_VERSIONvariable to the version you want to install. You will use this version for all commands in this guide.export FUNKWHALE_VERSION={sub-ref}`version` -
Install Docker and Docker Compose.
-
Install
curl.sudo apt update # update apt cache sudo apt install curl
1. 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-composetemplate. 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.
2. 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
.envtemplate to your/srv/funkwhaledirectory.curl -L -o /srv/funkwhale/.env "https://dev.funkwhale.audio/funkwhale/funkwhale/raw/${FUNKWHALE_VERSION}/deploy/env.prod.sample" -
Update
FUNKWHALE_VERSIONin the.envfile to the$FUNKWHALE_VERSIONvariable you set earlier.sed -i "s/FUNKWHALE_VERSION=latest/FUNKWHALE_VERSION=$FUNKWHALE_VERSION/" .env -
Reduce the permissions on your
.envfile 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
.envfile 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_KEYfield. - Populate the
FUNKWHALE_HOSTNAMEfield with the URL of your server.
- Paste the secret key in the
-
Hit {kbd}
ctrl + xthen {kbd}yto save the file and closenano.
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.
3. 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 python manage.py migrateYou may see the following warning when applying migrations: ```{code-block} text "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 python manage.py createsuperuser -
Launch all the containers to bring up your pod.
docker-compose up -d
That's it! Your Funkwhale pod is now up and running.
4. 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. To do this:
-
Install Nginx.
sudo apt-get update sudo apt-get install nginx -
Download the Nginx templates from Funkwhale.
sudo curl -L -o /etc/nginx/funkwhale_proxy.conf "https://dev.funkwhale.audio/funkwhale/funkwhale/raw/$FUNKWHALE_VERSION/deploy/funkwhale_proxy.conf" sudo curl -L -o /etc/nginx/sites-available/funkwhale.template "https://dev.funkwhale.audio/funkwhale/funkwhale/raw/$FUNKWHALE_VERSION/deploy/docker.proxy.template" -
Create an Nginx template with details from your
.envfile.# Log in to a root shell. sudo su # Create an Nginx configuration using the Funkwhale template with details from your `.env` file. set -a && source /srv/funkwhale/.env && set +a envsubst "`env | awk -F = '{printf \" $%s\", $$1}'`" \ < /etc/nginx/sites-available/funkwhale.template \ > /etc/nginx/sites-available/funkwhale.conf # Enable the configuration so that Nginx serves it. ln -s /etc/nginx/sites-available/funkwhale.conf /etc/nginx/sites-enabled/ # Exit the root shell. exit
That's it! You've created your Nginx file. Run the following command to check the .env details populated correctly.
grep '${' /etc/nginx/sites-enabled/funkwhale.conf
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/nginxdirectory to house your files.mkdir /srv/funkwhale/nginx -
Download the Nginx template files to the
/srv/funkwhale/nginxdirectory.curl -L -o /srv/funkwhale/nginx/funkwhale.template "https://dev.funkwhale.audio/funkwhale/funkwhale/raw/${FUNKWHALE_VERSION}/deploy/docker.nginx.template" curl -L -o /srv/funkwhale/nginx/funkwhale_proxy.conf "https://dev.funkwhale.audio/funkwhale/funkwhale/raw/${FUNKWHALE_VERSION}/deploy/docker.funkwhale_proxy.conf" -
Make any changes you want to make to these files.
-
Open your
docker-compose.ymlfile in a text editor. For this example, we will usenano.nano /srv/funkwhale/docker-compose.yml -
Uncomment the lines in the
volumessection of thefrontservice 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
frontcontainer 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.
5. Set up TLS
To enable your users to connect to your pod securely, you need to set up {abbr}TLS (Transport Layer Security). To do this, we recommend using the <acme.sh> script.
-
Log in as the superuser account to run these commands.
su -
Create the
/etc/certsfolder to store the certificates.mkdir /etc/certs -
Download and run
acme.sh. Replacemy@example.comwith your email address.curl https://get.acme.sh | sh -s email=my@example.com -
Generate a certificate. Replace
example.comwith your Funkwhale pod name. Use/srv/funkwhale/frontas your web root folder.acme.sh --issue -d example.com -w /srv/funkwhale/front -
Install the certificate to your Nginx config. Replace
example.comwith your Funkwhale pod name.acme.sh --install-cert -d example.com \ --key-file /etc/certs/key.pem \ --fullchain-file /etc/certs/cert.pem \ --reloadcmd "service nginx force-reload"
That's it! acme.sh renews your certificate every 60 days, so you don't need to worry about renewing it.