Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Build and push Docker image

on:
push:
branches:
- main
paths:
- 'resources/build/libreelec/Dockerfile.amd64'
- 'resources/build/libreelec/create_standalone_moonlight_qt.sh'
- '.github/workflows/docker-build.yml'
workflow_dispatch:

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest
type=raw,value=${{ vars.MOONLIGHT_VERSION }}

- name: Build and push
uses: docker/build-push-action@v5
with:
context: resources/build/libreelec
file: resources/build/libreelec/Dockerfile.amd64
push: true
tags: ${{ steps.meta.outputs.tags }}
build-args: |
MOONLIGHT_VERSION=${{ vars.MOONLIGHT_VERSION }}
cache-from: type=gha
cache-to: type=gha,mode=max
59 changes: 45 additions & 14 deletions resources/build/libreelec/Dockerfile.amd64
Original file line number Diff line number Diff line change
@@ -1,43 +1,74 @@
# Use latest compatible Debian version
ARG DEBIAN_RELEASE=bookworm
FROM debian:${DEBIAN_RELEASE}-slim
FROM debian:${DEBIAN_RELEASE}-slim@sha256:1def178129dfb5f24db43afbf2fcac04530012e3264ba4ff81c71184e17a9ee4

# Install required packages and download Moonligh-qt AppImage version
# Install build dependencies and runtime libraries.
# We build moonlight-qt from source rather than extracting the upstream AppImage
# so that it is compiled against Debian's libsdl2-dev, which has SDL_VIDEO_DRIVER_KMSDRM
# defined. The upstream AppImage was built without this flag, which caused
# vaapi.cpp's KMSDRM display path to be compiled out, preventing hardware-accelerated
# video decoding on KMS/DRM displays (e.g. LibreELEC on generic x86_64).
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y \
build-essential \
git \
pkg-config \
qt5-qmake \
qtbase5-dev \
qtbase5-private-dev \
qtdeclarative5-dev \
libqt5svg5-dev \
libqt5quickcontrols2-5 \
qml-module-qtquick-controls2 \
qml-module-qtquick-layouts \
qml-module-qtquick-window2 \
qml-module-qtquick2 \
libsdl2-dev \
libva-dev \
libdrm-dev \
libavcodec-dev \
libavutil-dev \
libswscale-dev \
libswresample-dev \
libopus-dev \
libssl-dev \
libcurl4-openssl-dev \
libatomic1 \
libfuse2 \
libgl1 \
libgl1-mesa-dri \
libgles2 \
libglib2.0-dev \
libgudev-1.0-0 \
libinput10 \
libqt5core5a \
libqt5gui5 \
libqt5network5 \
libqt5qml5 \
libqt5quickcontrols2-5 \
libqt5svg5 \
libsm6 \
libva-wayland2 \
libvdpau-va-gl1 \
libvdpau1 \
libxcb-cursor0 \
libxcursor1 \
libxi6 \
qml-module-qtquick-controls2 \
qml-module-qtquick-layouts \
qml-module-qtquick-window2 \
qml-module-qtquick2 \
wget \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& DOWNLOAD_URL=$(wget --quiet --header "Accept: application/vnd.github.v3+json" --output-document - https://api.github.com/repos/moonlight-stream/moonlight-qt/releases/latest | grep -o '"browser_download_url": "[^"]*' | grep -o '[^"]*$' | grep ".AppImage") \
&& wget "${DOWNLOAD_URL}" -O /tmp/Moonlight-downloaded.AppImage \
&& chmod a+x /tmp/Moonlight-downloaded.AppImage
&& rm -rf /var/lib/apt/lists/*

# Clone and build moonlight-qt from source.
# MOONLIGHT_VERSION can be overridden at build time, e.g. --build-arg MOONLIGHT_VERSION=v6.1.0
ARG MOONLIGHT_VERSION=v6.1.0
RUN git clone --depth 1 --branch ${MOONLIGHT_VERSION} \
https://github.com/moonlight-stream/moonlight-qt.git /tmp/moonlight-qt-src \
&& cd /tmp/moonlight-qt-src \
&& git submodule update --init --recursive \
&& qmake moonlight-qt.pro \
&& make -j$(nproc) \
&& install -m 755 app/moonlight /usr/bin/moonlight-qt \
&& rm -rf /tmp/moonlight-qt-src

# Script to extract the needed libraries
COPY create_standalone_moonlight_qt.sh /tmp/
RUN chmod a+x /tmp/create_standalone_moonlight_qt.sh

ENTRYPOINT [ "/tmp/create_standalone_moonlight_qt.sh" ]
ENTRYPOINT [ "/tmp/create_standalone_moonlight_qt.sh" ]
16 changes: 12 additions & 4 deletions resources/build/libreelec/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,24 @@ if [ "${PLATFORM_DISTRO_RELEASE%%.*}" -le 10 ]; then
BUILD_ARG="--build-arg DEBIAN_RELEASE=bullseye"
fi

# Clean up
GHCR_IMAGE="ghcr.io/echocabinet/plugin.program.moonlight-qt:latest"

# Clean up any previous container/image
docker rm --force moonlight-qt &> /dev/null || true
docker rmi --force moonlight-qt &> /dev/null || true

# Build
docker build --file "./Dockerfile.${BUILD_FLAVOR}" --compress --tag moonlight-qt --platform "linux/${BUILD_ARCH}" $BUILD_ARG .
# Try pulling the pre-built image from GHCR — much faster than building locally.
# Falls back to a local build if the pull fails (offline, image not yet published, etc).
if docker pull --platform "linux/${BUILD_ARCH}" "$GHCR_IMAGE" 2>/dev/null; then
echo "Using pre-built image from GHCR."
docker tag "$GHCR_IMAGE" moonlight-qt
else
echo "GHCR pull failed or unavailable — building locally (this will take a while)..."
docker build --file "./Dockerfile.${BUILD_FLAVOR}" --compress --tag moonlight-qt --platform "linux/${BUILD_ARCH}" $BUILD_ARG .
fi

# Run and get files
mkdir -p "$LOCAL_PATH"
docker create --name moonlight-qt moonlight-qt
docker run --volume "$LOCAL_PATH":/tmp/moonlight-qt moonlight-qt

# Clean up
Expand Down
4 changes: 4 additions & 0 deletions resources/build/libreelec/create_standalone_moonlight_qt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,16 @@ fi
USR_DEPENDENCIES="
libEGL.so*
libGL.so*
libGLESv2.so*
libGLX.so*
libGLdispatch.so*
libICE.so*
libOpenCL.so*
libOpenGL.so*
libQt5*
libQt6*
libSDL2.so*
libSDL2-*.so*
libSM.so*
libSvtAv1Enc.so*
libX11-xcb.so*
Expand All @@ -55,6 +58,7 @@ USR_DEPENDENCIES="
libcrypto.so*
libdatrie.so*
libdav1d.so*
libdrm.so*
libdouble-conversion.so*
libffi.so*
libfribidi.so*
Expand Down
Loading