6.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_VERSION
variable 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-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.
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
.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.
- Paste the secret key in the
-
Hit {kbd}
ctrl + x
then {kbd}y
to 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 migrate
You may see the following warning when applying migrations: ```{code} "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 uses a reverse proxy to serve content to users. We use Nginx to serve this proxy. Follow this guide to install an Nginx configuration using details from your .env
file.
-
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
.env
file.# 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
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/certs
folder to store the certificates.mkdir /etc/certs
-
Download and run
acme.sh
. Replacemy@example.com
with your email address.curl https://get.acme.sh | sh -s email=my@example.com
-
Generate a certificate. Replace
example.com
with your Funkwhale pod name. Use/srv/funkwhale/front
as your web root folder.acme.sh --issue -d example.com -w /srv/funkwhale/front
-
Install the certificate to your Nginx config. Replace
example.com
with 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.