FunkWhale Docker Deployment

0. Background

FunkWhale is a community-driven project that lets you listen and share music and audio within a decentralized, open network.
FunkWhale now supports both AMD64 and ARM64.

1. Pull Source

mkdir /srv/funkwhale
cd /srv/funkwhale
mkdir nginx
curl -L -o nginx/funkwhale.template "https://dev.funkwhale.audio/funkwhale/funkwhale/raw/1.2.4/deploy/docker.nginx.template"
curl -L -o nginx/funkwhale_proxy.conf "https://dev.funkwhale.audio/funkwhale/funkwhale/raw/1.2.4/deploy/docker.funkwhale_proxy.conf"
curl -L -o docker-compose.yml "https://dev.funkwhale.audio/funkwhale/funkwhale/raw/1.2.4/deploy/docker-compose.yml"
curl -L -o .env "https://dev.funkwhale.audio/funkwhale/funkwhale/raw/1.2.4/deploy/env.prod.sample"

Note: Do not change /srv/funkwhale directory

2. Edit env

nano .env
FUNKWHALE_VERSION=1.2.4
FUNKWHALE_HOSTNAME=funkwhale.example.com
DJANGO_SECRET_KEY=
MUSIC_DIRECTORY_PATH=/music
MUSIC_DIRECTORY_SERVE_PATH=/srv/funkwhale/data/music
NGINX_MAX_BODY_SIZE=800M

The value of DJANGO_SECRET_KEY can be generated with the following command:

openssl rand -base64 45

3. Run docker-compose

Initialization

docker-compose pull
docker-compose up -d postgres 
docker-compose run --rm api python manage.py migrate

Create admin account

docker-compose run --rm api python manage.py createsuperuser

Run container

docker-compose up -d

Check if 6 containers are all up

docker-compose ps

4. Set up Nginx

Get nginx proxy conf file to Nginx. You don’t need to modify this file

curl -L -o /etc/nginx/funkwhale_proxy.conf "https://dev.funkwhale.audio/funkwhale/funkwhale/raw/1.2.4/deploy/funkwhale_proxy.conf"

Create funkwhale.conf

nano /etc/nginx/conf.d/funkwhale.conf
server {
        listen 80; 
        server_name funkwhale.example.com;
        if ($host = funkwhale.example.com) {
                return 301 https://$host$request_uri;
        }
        return 404;
}

upstream fw {
    server 127.0.0.1:5000;
}

map $http_upgrade $connection_upgrade {
    default upgrade;
    ''      close;
}

server {
    listen 443 ssl http2;
    server_name funkwhale.example.com;
    ssl_certificate       /home/ubuntu/keys/fullchain.pem; #specify your path
    ssl_certificate_key   /home/ubuntu/keys/privkey.pem; #specify your path

    gzip on;
    gzip_comp_level    5;
    gzip_min_length    256;
    gzip_proxied       any;
    gzip_vary          on;

    gzip_types
        application/javascript
        application/vnd.geo+json
        application/vnd.ms-fontobject
        application/x-font-ttf
        application/x-web-app-manifest+json
        font/opentype
        image/bmp
        image/svg+xml
        image/x-icon
        text/cache-manifest
        text/css
        text/plain
        text/vcard
        text/vnd.rim.location.xloc
        text/vtt
        text/x-component
        text/x-cross-domain-policy;

    location / {
        include /etc/nginx/funkwhale_proxy.conf;
        client_max_body_size 500M;
        proxy_pass   http://fw/;
    }
}
nginx -t
systemctl restart nginx

Copyright statement: Unless otherwise stated, all articles on this blog adopt the CC BY-NC-SA 4.0 license agreement. For non-commercial reprints and citations, please indicate the author: Henry, and original article URL. For commercial reprints, please contact the author for authorization.