blackcandy

blackcandy-orgMIT活跃维护

自托管的音乐流媒体服务器,把本地音乐库变成可在线播放的私人音乐服务,支持浏览器和移动端随时听歌。

A self hosted music streaming server

v3.2.1发布于 2026-08-26 07:39 UTC4,432star +1 / 7 天229fork同步于 2026-11-10 17:39 UTC

怎么上手

由 README 提炼,执行前请确认
docker run -p 80:80 ghcr.io/blackcandy-org/blackcandy:latest
硬件要求按 README 说明

README 未说明硬件要求,只要求能运行 Docker;开发环境需要 Ruby 4.0、Node.js 20、libvips 和 FFmpeg。

有 Docker 镜像
下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

自托管的个人音乐流媒体服务器,用 Docker 一条命令就能把音乐库变成可在线播放的私人音乐中心

自托管的音乐流媒体服务器,把本地音乐库变成可在线播放的私人音乐服务,支持浏览器和移动端随时听歌。

核心能力

  • 用 Docker 镜像一键部署,默认监听容器内 80 端口
  • 挂载本地媒体目录并用 MEDIA_PATH 指定音乐路径
  • 默认用 SQLite,可切换 PostgreSQL 作为数据库
  • 提供 iOS、Android、F-Droid 官方移动客户端
  • 可通过 Discogs API 获取艺人和专辑封面图

容易踩的坑

默认不设置 SECRET_KEY_BASE 时每次启动都会重新生成,导致已有会话全部失效;容器内端口是 80,映射到主机其他端口需用 -p 3000:80 这类写法;挂载卷时可能出现宿主机与容器权限不一致,需用 --user 指定 UID:GID;升级前要先读升级指南,新版本可能有破坏性变更。

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本v3.2.1
  1. v3.2.1最新正式版2026-08-26 · 2026-08-26 07:39 UTC

    What's Changed

    Fixed

    Fix: unload html5 audio nodes when switching songs by @aidewoode in https://github.com/blackcandy-org/blackcandy/pull/502

    Full Changelog: https://github.com/blackcandy-org/blackcandy/compare/v3.2.0...v3.2.1

  2. v3.2.02026-05-07 · 2026-05-07 11:29 UTC
    查看更新说明

    What's Changed

    [!IMPORTANT] Please check the v3.1-v3.2 upgrade guide when you do upgrade.

    Black Candy v3.2.0 requires the mobile app v2.0 or above. Please upgrade your mobile app after upgrading the server.

    Breaking change:

    • The working directory inside the Docker container has changed from /app to /rails. You need to update your volume mount path for persistent storage data after upgrading.

    New

    Improved

    Fixed

    New Contributors

    Full Changelog: https://github.com/blackcandy-org/blackcandy/compare/v3.1.0...v3.2.0

  3. v3.1.02025-06-18 · 2025-06-18 11:05 UTC
    查看更新说明

    What's Changed

    [!IMPORTANT] Please check the v3.0-v3.1 upgrade guide when you do upgrade.

    Breaking change:

    • The default export port changed from 3000 to 80. You need to remap your port after upgrading.

    New

    Improved

    Fixed

    Full Changelog: https://github.com/blackcandy-org/blackcandy/compare/v3.0.0...v3.1.0

  4. v3.0.02024-05-31 · 2024-05-31 15:01 UTC
    查看更新说明

    Hi, It's been a long time since the last stable release. Thank you to everyone who tried and gave feedback on the edge version of Black Candy. You helped a lot with this release.

    There are a lot of improvements since v2. Most importantly, the official Black Candy mobile apps are finally released with Black Candy v3. You can go to the README to see download options.

    If you upgrade from v2 release, please check V3 upgrade guide to upgrade.

    If you upgrade from edge release, please check Edge upgrade guide to upgrade to stable v3.

    Full Changelog: https://github.com/blackcandy-org/blackcandy/compare/v2.1.1...v3.0.0

  5. v2.1.12022-08-09 · 2022-08-09 06:32 UTC
    查看更新说明

    What's Changed

    Improved

    Fixed

    New Contributors

    Full Changelog: https://github.com/blackcandy-org/black_candy/compare/v2.1.0...v2.1.1

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    Black Candy

    CI Coverage Status Docker Pulls

    Screenshot

    Black Candy is a self-hosted music streaming server, your personal music center.

    Try The Demo

    Please visit https://demo.blackcandy.org and use demo user (email: [email protected], password: foobar) to log in. And feel free to try it.

    [!NOTE] This demo user does not have administrator privileges. So you cannot experience all the features in Black Candy. And all music in the demo are from Free Music Archive. You can check their licenses.

    Installation

    Black Candy uses docker image to install easily. You can run Black Candy like this.

    docker run -p 80:80 ghcr.io/blackcandy-org/blackcandy:latest 
    
    # Or pull from Docker Hub.
    docker run -p 80:80 blackcandy/blackcandy:latest 
    

    That's all. Now, you can access either http://localhost or http://host-ip in a browser, and use initial admin user to log in (email: [email protected], password: foobar).

    Upgrade

    [!IMPORTANT] If you upgrade to a new version, you need to read the upgrade guide carefully before upgrade. Because there are may some breaking changes in a new version.

    Please Check the Upgrade Guide for upgrading to a new version

    Upgrade Black Candy is pull new image from remote. Then remove an old container and create a new one.

    docker stop <your_blackcandy_container>
    docker rm <your_blackcandy_container>
    docker pull ghcr.io/blackcandy-org/blackcandy:latest
    docker run <OPTIONS> ghcr.io/blackcandy-org/blackcandy:latest 
    

    With docker compose, you can upgrade Black Candy like this:

    docker-compose down
    docker pull ghcr.io/blackcandy-org/blackcandy:latest
    docker-compose up
    

    Mobile Apps

    Black Candy mobile apps are available in the following app stores:

    For Android app, you can also download APK from GitHub Release

    Configuration

    Port Mapping

    Black Candy exports the 80 port. If you want to be able to access it from the host, you can use the -p option to map the port.

    docker run -p 3000:80 ghcr.io/blackcandy-org/blackcandy:latest
    

    Media Files Mounts

    You can mount media files from host to container and use MEDIA_PATH environment variable to set the media path for black candy.

    docker run -v /media_data:/media_data -e MEDIA_PATH=/media_data ghcr.io/blackcandy-org/blackcandy:latest   
    

    Use PostgreSQL As Database

    Black Candy use SQLite as database by default. Because SQLite can simplify the process of installation, and it's an ideal choice for self-hosted small server. If you think SQLite is not enough, or you are using some cloud service like heroku to host Black Candy, you can also use PostgreSQL as database.

    docker run -e DB_ADAPTER=postgresql -e DB_URL=postgresql://yourdatabaseurl ghcr.io/blackcandy-org/blackcandy:latest 
    

    How to Persist Data

    All the data that need to persist in Black Candy are stored in /rails/storage, So you can mount this directory to host to persist data.

    mkdir storage_data
    
    docker run -v ./storage_data:/rails/storage ghcr.io/blackcandy-org/blackcandy:latest 
    

    Running as an Arbitrary User

    When mounting volumes, you may encounter permission issues between the host and the Docker container. To resolve this issue, pass the UID and GID with the --user to set the same UID and GID as your host user.

    docker run --user 2000:2000 -v ./storage_data:/rails/storage ghcr.io/blackcandy-org/blackcandy:latest 
    

    Logging

    Black Candy logs to STDOUT by default. So if you want to control the log, Docker already supports a lot of options to handle the log in the container. See: https://docs.docker.com/config/containers/logging/configure/.

    Secret Key Base

    Black Candy uses cryptography to protect sessions and other security-sensitive data, and needs a secret value as the basis of those secrets. This value can be anything, but it should be unguessable, and specific to your instance.

    You can use any long random string for this. One way to generate one is with openssl:

    openssl rand -hex 64
    

    Once you have one, set it in the SECRET_KEY_BASE environment variable:

    docker run -e SECRET_KEY_BASE=your_generated_secret ghcr.io/blackcandy-org/blackcandy:latest
    

    If SECRET_KEY_BASE is not set, Black Candy will generate a new one on each startup, which will invalidate all existing sessions.

    Example

    And if you would like to use docker compose to run Black Candy. Here is an example docker-compose.yml file.

    services:
      app:
        image: ghcr.io/blackcandy-org/blackcandy:latest
        restart: unless-stopped
        ports:
          - "3000:80"
        volumes:
          - storage_data:/app/storage
          - ./media_data:/media_data
        environment:
          SECRET_KEY_BASE: fake_secret_key
          MEDIA_PATH: /media_data
    
    volumes:
      storage_data:
    

    Environment Variables

    NameDefaultDescription
    DB_URLThe URL of PostgreSQL database. You must set this environment variable if you use PostgreSQL as database.
    CABLE_DB_URLThe URL of Pub/Sub database. You must set this environment variable if you use PostgreSQL as database.
    QUEUE_DB_URLThe URL of background job database. You must set this environment variable if you use PostgreSQL as database.
    CACHE_DB_URLThe URL of cache database. You must set this environment variable if you use PostgreSQL as database.
    MEDIA_PATHYou can use this environment variable to set media path for Black Candy, otherwise you can set media path in settings page.
    DB_ADAPTER"sqlite"There are two adapters are supported, "sqlite" and "postgresql".
    SECRET_KEY_BASEWhen the SECRET_KEY_BASE environment variable is not set, Black candy will generate SECRET_KEY_BASE environment variable every time when service start up. This will cause old sessions invalid, You can set your own SECRET_KEY_BASE environment variable on docker service to avoid it.
    FORCE_SSLfalseForce all access to the app over SSL.
    DEMO_MODEfalseWhether to enable demo mode, when demo mode is on, all users cannot access administrator privileges, even user is admin. And also users cannot change their profile.
    HTTP_PORT80The port that Black Candy listens on inside the container. Useful when you want to run Black Candy on a port other than 80.

    Edge Version

    The edge version of Black Candy base on master branch, which means it's not stable, you may encounter data loss or other issues. However, I don't recommend normal user using an edge version. But if you are a developer who wants to test or contribute to Black Candy, you can use the edge version.

    docker pull ghcr.io/blackcandy-org/blackcandy:edge
    

    Development

    Requirements

    • Ruby 4.0
    • Node.js 20
    • libvips
    • FFmpeg

    Make sure you have installed all those dependencies.

    Install gem dependencies

    bundle install
    

    Install JavaScript dependencies

    npm install
    

    Database Configuration

    rails db:prepare
    rails db:seed
    

    Start all services

    After you’ve set up everything, now you can run ./bin/dev to start all services you need to develop. Then visit http://localhost:3000 use initial admin user to log in (email: [email protected], password: foobar).

    Running tests

    # Running all test
    $ rails test:all 
    
    # Running lint
    $ rails lint:all
    

    Integrations

    Black Candy support get artist and album image from Discogs API. You can create an API token from Discogs and set Discogs token on Setting page to enable it.

    Sponsorship

    This project is supported by: