Funkwhale tutoriel about docker

Pre-Introduction

Enfin, une des grandes nouveautés de ces dernières années, c’est à mon avis Docker qui réduit grandement les difficultés à installer un service tel que Funkwhale.

Tout le monde n’est pas forcément convaincu par cette techno, qui a aussi ses problèmes, mais la simplicité pour les déploiements est quand même un atout assez fort.

Très concrètement, si tu consultes la doc d’installation de Funkwhale sur Docker, tu pourras constater qu’il suffit d’une dizaine de commandes à exécuter pour installer Funkwhale sur son serveur.

Introduction

Docker is the easiest way to get a Funkwhale instance up and running.

We support two types of Docker deployments:

  • Mono-container: all processes live in the same container (database, nginx, redis, etc.). It’s easier to deploy and to integrate with container management systems like Portainer. However, it’s not possible to scale this type of deployment on multiple servers.

  • Multi-container: each process lives in a dedicated container. This setup is more involved but also more flexible and scalable.

Mono-container Dockerfile

FROM alpine:3.8
MAINTAINER thetarkus


#
# Installation
#

ARG arch=amd64
RUN \
    echo 'installing dependencies' && \
    apk add                \
    shadow             \
    gettext            \
    git                \
    postgresql         \
    postgresql-contrib \
    postgresql-dev     \
    python3-dev        \
    py3-psycopg2       \
    py3-pillow         \
    redis              \
    nginx              \
    musl-dev           \
    gcc                \
    unzip              \
    libldap            \
    libsasl            \
    ffmpeg             \
    libpq              \
    libmagic           \
    libffi-dev         \
    zlib-dev           \
    openldap-dev && \
    \
    \
    echo 'creating directories' && \
    mkdir -p /app /run/nginx /run/postgresql /var/log/funkwhale && \
    \
    \
    echo 'creating users' && \
    adduser -s /bin/false -D -H funkwhale funkwhale && \
    \
    \
    echo 'downloading archives' && \
    wget https://github.com/just-containers/s6-overlay/releases/download/v1.21.7.0/s6-overlay-$arch.tar.gz -O /tmp/s6-overlay.tar.gz && \
    \
    \
    echo 'extracting archives' && \
    cd /app && \
    tar -C / -xzf /tmp/s6-overlay.tar.gz && \
    \
    \
    echo 'setting up nginx' && \
    rm /etc/nginx/conf.d/default.conf && \
    \
    \
    echo 'removing temp files' && \
    rm /tmp/*.tar.gz

COPY ./src/api /app/api

RUN \
    ln -s /usr/bin/python3 /usr/bin/python && \
    echo 'fixing requirements file for alpine' && \
    sed -i '/Pillow/d' /app/api/requirements/base.txt && \
    \
    \
    echo 'installing pip requirements' && \
    pip3 install --upgrade pip && \
    pip3 install setuptools wheel && \
    pip3 install -r /app/api/requirements.txt

COPY ./src/front /app/front


#
# Environment
# https://dev.funkwhale.audio/funkwhale/funkwhale/blob/develop/deploy/env.prod.sample
# (Environment is at the end to avoid busting build cache on each ENV change)
#

ENV FUNKWHALE_HOSTNAME=yourdomain.funkwhale \
    FUNKWHALE_PROTOCOL=http \
    DJANGO_SETTINGS_MODULE=config.settings.production \
    DJANGO_SECRET_KEY=funkwhale \
    DJANGO_ALLOWED_HOSTS='127.0.0.1,*' \
    DATABASE_URL=postgresql://funkwhale@:5432/funkwhale \
    MEDIA_ROOT=/data/media \
    MUSIC_DIRECTORY_PATH=/music \
    NGINX_MAX_BODY_SIZE=100M \
    STATIC_ROOT=/app/api/staticfiles \
    FUNKWHALE_SPA_HTML_ROOT=http://localhost/front/

#
# Entrypoint
#

COPY ./root /
COPY ./src/funkwhale_nginx.template /etc/nginx/funkwhale_nginx.template
ENTRYPOINT ["/init"]

https://dev.funkwhale.audio/funkwhale/funkwhale/blob/develop/deploy/env.prod.sample

# If you have any doubts about what a setting does,
# check https://docs.funkwhale.audio/configuration.html#configuration-reference

# If you're tweaking this file from the template, ensure you edit at least the
# following variables:
# - DJANGO_SECRET_KEY
# - FUNKWHALE_HOSTNAME
# - EMAIL_CONFIG and DEFAULT_FROM_EMAIL if you plan to send emails)
# On non-docker setup **only**, you'll also have to tweak/uncomment those variables:
# - DATABASE_URL
# - CACHE_URL
#
# You **don't** need to update those variables on pure docker setups.
#
# Additional options you may want to check:
# - MUSIC_DIRECTORY_PATH and MUSIC_DIRECTORY_SERVE_PATH if you plan to use
#   in-place import
#
# Docker only
# -----------

# The tag of the image we should use
# (it will be interpolated in docker-compose file)
# You can comment or ignore this if you're not using docker
FUNKWHALE_VERSION=latest

# End of Docker-only configuration

# General configuration
# ---------------------

# Set this variables to bind the API server to another interface/port
# example: FUNKWHALE_API_IP=0.0.0.0
# example: FUNKWHALE_API_PORT=5678
FUNKWHALE_API_IP=127.0.0.1
FUNKWHALE_API_PORT=5000

# Replace this by the definitive, public domain you will use for
# your instance
FUNKWHALE_HOSTNAME=yourdomain.funkwhale
FUNKWHALE_PROTOCOL=https

# Configure email sending using this variale
# By default, funkwhale will output emails sent to stdout
# here are a few examples for this setting
# EMAIL_CONFIG=consolemail://         # output emails to console (the default)
# EMAIL_CONFIG=dummymail://          # disable email sending completely
# On a production instance, you'll usually want to use an external SMTP server:
# EMAIL_CONFIG=smtp://user@:password@youremail.host:25
# EMAIL_CONFIG=smtp+ssl://user@:password@youremail.host:465
# EMAIL_CONFIG=smtp+tls://user@:password@youremail.host:587

# The email address to use to send system emails.
# DEFAULT_FROM_EMAIL=noreply@yourdomain

# Depending on the reverse proxy used in front of your funkwhale instance,
# the API will use different kind of headers to serve audio files
# Allowed values: nginx, apache2
REVERSE_PROXY_TYPE=nginx

# API/Django configuration

# Database configuration
# Examples:
#  DATABASE_URL=postgresql://<user>:<password>@<host>:<port>/<database>
#  DATABASE_URL=postgresql://funkwhale:passw0rd@localhost:5432/funkwhale_database
# Use the next one if you followed Debian installation guide
# DATABASE_URL=postgresql://funkwhale@:5432/funkwhale

# Cache configuration
# Examples:
#  CACHE_URL=redis://<host>:<port>/<database>
#  CACHE_URL=redis://localhost:6379/0c
#  With a password:
#  CACHE_URL=redis://:password@localhost:6379/0
#  (the extra semicolon is important)
# Use the next one if you followed Debian installation guide
# CACHE_URL=redis://127.0.0.1:6379/0

# Where media files (such as album covers or audio tracks) should be stored
# on your system?
# (Ensure this directory actually exists)
MEDIA_ROOT=/srv/funkwhale/data/media

# Where static files (such as API css or icons) should be compiled
# on your system?
# (Ensure this directory actually exists)
STATIC_ROOT=/srv/funkwhale/data/static

# which settings module should django use?
# You don't have to touch this unless you really know what you're doing
DJANGO_SETTINGS_MODULE=config.settings.production

# Generate one using `openssl rand -base64 45`, for example
DJANGO_SECRET_KEY=

# You don't have to edit this, but you can put the admin on another URL if you
# want to
# DJANGO_ADMIN_URL=^api/admin/

# Sentry/Raven error reporting (server side)
# Enable Raven if you want to help improve funkwhale by
# automatically sending error reports our Sentry instance.
# This will help us detect and correct bugs
RAVEN_ENABLED=false
RAVEN_DSN=https://44332e9fdd3d42879c7d35bf8562c6a4:0062dc16a22b41679cd5765e5342f716@sentry.eliotberriot.com/5

# In-place import settings
# You can safely leave those settings uncommented if you don't plan to use
# in place imports.
# Typical docker setup:
#   MUSIC_DIRECTORY_PATH=/music  # docker-only
#   MUSIC_DIRECTORY_SERVE_PATH=/srv/funkwhale/data/music
# Typical non-docker setup:
#   MUSIC_DIRECTORY_PATH=/srv/funkwhale/data/music
#   # MUSIC_DIRECTORY_SERVE_PATH= # stays commented, not needed

MUSIC_DIRECTORY_PATH=/srv/funkwhale/data/music
MUSIC_DIRECTORY_SERVE_PATH=/srv/funkwhale/data/music

# LDAP settings
# Use the following options to allow authentication on your Funkwhale instance
# using a LDAP directory.
# Have a look at https://docs.funkwhale.audio/installation/ldap.html for
# detailed instructions.

# LDAP_ENABLED=False
# LDAP_SERVER_URI=ldap://your.server:389
# LDAP_BIND_DN=cn=admin,dc=domain,dc=com
# LDAP_BIND_PASSWORD=bindpassword
# LDAP_SEARCH_FILTER=(|(cn={0})(mail={0}))
# LDAP_START_TLS=False
# LDAP_ROOT_DN=dc=domain,dc=com

FUNKWHALE_FRONTEND_PATH=/srv/funkwhale/front/dist

# Nginx related configuration
NGINX_MAX_BODY_SIZE=100M