Files
biliup/Dockerfile
Noah e4fb9c01df feat(desktop): bundle ffmpeg and run external tools without console windows (#1735)
* feat(cli): locate ffmpeg via ffmpeg_path / host / PATH and start child processes without console windows

- New `tools` module in both crates. `tools::command()` starts external
  programs with CREATE_NO_WINDOW on Windows; every ffmpeg, streamlink,
  yt-dlp, ytarchive and hook shell process now goes through it.
- ffmpeg is looked up in this order: the new optional `ffmpeg_path`
  setting, then `ServeOptions::ffmpeg` (for an ffmpeg shipped by the
  embedding host), then `ffmpeg` on PATH. Unset keeps today's behaviour.
- `ffmpeg_path` is global (not overridable per streamer) and visible in
  the redacted configuration.

* feat(api): GET /v1/tools reports ffmpeg availability, version and license

Read-only, allowed for every logged-in role. Returns whether the ffmpeg
that would be used runs, where it came from (config / bundled / path),
the first line of `ffmpeg -version` (cached per program; failures are
retried) and the license derived from its configure flags. Errors say
what to fix.

* feat(desktop): bundle ffmpeg in the Windows installer, same BtbN build as Docker

- desktop-publish.yml downloads the BtbN win64 GPL static zip of the tag
  and version the Dockerfile pins (read by .github/scripts/ffmpeg-version.sh),
  checks its SHA-256 and ships only ffmpeg.exe, LICENSE.txt and a README
  with the source links as bundle resources (tauri.ffmpeg.conf.json),
  installed under ffmpeg\.
- The shell passes resource_dir()/ffmpeg/ffmpeg.exe to ServeOptions::ffmpeg
  when the file exists. The ffmpeg_path setting still wins; builds without
  the overlay keep using PATH.

* ci(desktop): attach the FFmpeg corresponding source and download notes to releases

- New ffmpeg-source job: FFmpeg at the pinned commit, the BtbN build
  scripts at the pinned tag, and the source of every library those
  scripts build (fetched by their own download.sh at the commits pinned
  in scripts.d/), plus a README and SHA256SUMS. Uploaded on release
  events only; manual runs just list the files.
- On release events, append .github/desktop-release-notes.md to the
  release body once: setup.exe is the recommended download, and how to
  get past the browser warning and SmartScreen while it is unsigned.

* fix(cli): only use CREATE_NO_WINDOW when biliup has no console

`biliup server` in a Windows terminal keeps sharing its console with the
programs it starts, as before: Ctrl+C and their output still reach the
terminal. Only a process without a console window (the desktop app)
starts them with CREATE_NO_WINDOW. The choice is logged at startup and
covered by a Windows-only test that runs itself as a child with and
without a console.

* ci(desktop): link to the upstream FFmpeg source instead of uploading it to releases

Drop the ffmpeg-source job that packed about 2 GB of FFmpeg and dependency
source into every release. The installer's ffmpeg/README.txt and the release
notes now point to the FFmpeg commit and the BtbN/FFmpeg-Builds tree of the
bundled build (full commit hashes, resolved at build time), whose scripts.d/
pins the version and source URL of every library. The Docker image uses the
same BtbN tag, so the same links cover it.
2026-09-24 09:50:42 +00:00

139 lines
3.6 KiB
Docker
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Build biliup's web-ui
FROM node:lts AS webui-builder
ARG repo_url=https://github.com/biliup/biliup
ARG branch_name=master
COPY . /biliup
RUN set -eux; \
\
if [ ! -f /biliup/crates/stream-gears/pyproject.toml ]; then \
rm -rf /biliup; \
git clone --depth 1 --branch "$branch_name" "$repo_url" /biliup; \
fi;
WORKDIR /biliup
RUN set -eux; \
npm install; \
npm run build;
# Build biliup's python wheel
FROM rust:latest AS wheel-builder
ARG repo_url=https://github.com/biliup/biliup
ARG branch_name=master
COPY . /biliup
RUN set -eux; \
\
apt-get update; \
apt-get install -y --no-install-recommends python3-pip g++ patchelf; \
pip3 install maturin --break-system-packages; \
if [ ! -f /biliup/crates/stream-gears/pyproject.toml ]; then \
rm -rf /biliup; \
git clone --depth 1 --branch "$branch_name" "$repo_url" /biliup; \
fi;
COPY --from=webui-builder /biliup/out /biliup/out
WORKDIR /biliup
RUN set -eux; \
maturin build --release -m crates/stream-gears/Cargo.toml;
# Deploy Biliup
FROM python:3.13-slim AS biliup
ENV TZ="Asia/Shanghai"
ENV LANG="C.UTF-8"
ENV LANGUAGE="C.UTF-8"
ENV LC_ALL="C.UTF-8"
EXPOSE 19159/tcp
VOLUME /opt
# 需要遵守 wheel 文件名规范
COPY --from=wheel-builder /biliup/target/wheels/* /tmp/
RUN set -eux; \
\
whl=$(ls /tmp/biliup*.whl); \
pip3 install --no-cache-dir "$whl"; \
pip3 cache purge; \
rm -rf /tmp/*;
RUN set -eux; \
\
savedAptMark="$(apt-mark showmanual)"; \
useApt=false; \
apt-get update; \
apt-get install -y --no-install-recommends \
wget \
curl \
xz-utils \
; \
apt-mark auto '.*' > /dev/null; \
apt-mark manual curl wget; \
\
arch="$(dpkg --print-architecture)"; arch="${arch##*-}"; \
# 固定 FFmpeg 到确定版本并校验 SHA-256:
# latest 是滚动 tag,资产每日重建,既不可复现也无法防篡改。
# 只能固定到「每月最后一天」的 autobuild:BtbN 长期保留月末构建,
# 其余每日构建约两周后删除,固定到它们会让镜像构建 404。
# Windows 桌面版打包同一构建的 win64 版:.github/scripts/ffmpeg-version.sh 从下面这行读取
# tag 与版本号;改版本时同步更新 desktop-publish.yml 里的 FFMPEG_WIN64_SHA256。
url='https://github.com/BtbN/FFmpeg-Builds/releases/download/autobuild-2026-08-31-13-27/ffmpeg-n8.1.2-50-g1a748fe2cd-'; \
case "$arch" in \
'amd64') \
url="${url}linux64-gpl-8.1.tar.xz"; \
sha256='c733b4b2951e5957e15505f788b2c65a7a41b6da4b289e295852cc38079b4d2b'; \
;; \
'arm64') \
url="${url}linuxarm64-gpl-8.1.tar.xz"; \
sha256='ae5da4f51b9052390f414005f8ab26c1eed1268f327cce7cb79aa076b29bd66e'; \
;; \
*) \
useApt=true; \
;; \
esac; \
\
if [ "$useApt" = true ] ; then \
apt-get install -y --no-install-recommends \
ffmpeg \
; \
else \
wget -O ffmpeg.tar.xz "$url" --progress=dot:giga; \
echo "$sha256 ffmpeg.tar.xz" | sha256sum -c -; \
tar -xJf ffmpeg.tar.xz -C /usr/local --strip-components=1; \
rm -rf \
/usr/local/doc \
/usr/local/man; \
rm -rf \
/usr/local/bin/ffprobe \
/usr/local/bin/ffplay; \
rm -rf \
ffmpeg*; \
chmod a+x /usr/local/* ; \
fi; \
\
# Clean up \
[ -z "$savedAptMark" ] || apt-mark manual $savedAptMark; \
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
rm -rf \
/tmp/* \
/usr/share/doc/* \
/var/cache/* \
/var/lib/apt/lists/* \
/var/tmp/* \
/var/log/* \
;
WORKDIR /opt
ENTRYPOINT ["biliup"]
# 容器内必须监听 0.0.0.0,否则宿主机的端口映射无法转发进容器。
# CLI 默认的 127.0.0.1 只适用于直接在本机运行的场景。
CMD ["server", "--bind", "0.0.0.0", "--auth"]