diff --git a/Dockerfile b/Dockerfile index 1f865ac..99c6a37 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,22 +1,26 @@ -FROM debian:bookworm - -COPY start.sh . -RUN export DEBIAN_FRONTEND=noninteractive && \ - apt-get update && \ +FROM debian:trixie AS builder +COPY build.sh . +RUN apt-get update && \ apt-get upgrade -y -q && \ - apt-get install -y wget curl sudo gpg apt-transport-https lsb-release && \ - wget -qO /tmp/hyperion.pub.key https://releases.hyperion-project.org/hyperion.pub.key && \ - gpg --dearmor -o /usr/share/keyrings/hyperion.pub.gpg /tmp/hyperion.pub.key && \ - echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/hyperion.pub.gpg] https://apt.releases.hyperion-project.org/ $(lsb_release -cs) main" > /etc/apt/sources.list.d/hyperion.list && \ - apt-get update && \ - apt-get install -y hyperion && \ + chmod +x build.sh && \ + bash build.sh + + +FROM debian:trixie +COPY start.sh . +COPY --from=builder /usr/bin/hyperiond /usr/bin/hyperiond +RUN apt-get update && \ + apt-get upgrade -y -q && \ + apt-get install -y sudo tzdata libfontconfig1 libglib-2.0 libproxy1v5 libcec-dev && \ + chmod 755 /usr/bin/hyperiond && \ groupadd -f hyperion && \ useradd -r -s /bin/bash -g hyperion hyperion && \ chmod 777 /start.sh && \ mkdir /config && \ + chmod 777 /config && \ apt-get clean && \ - rm -rf /var/cache/apk/* - + rm -rf /var/cache/apk/* && \ + rm -rf /usr/share/man # Flatbuffers Server port EXPOSE 19400 @@ -42,3 +46,4 @@ ENV GID=1000 SHELL ["/bin/bash", "-c"] ENTRYPOINT bash start.sh uid="$UID" gid="$GID" +#ENTRYPOINT tail -f /dev/null diff --git a/README.md b/README.md index 661a859..9c74da8 100644 --- a/README.md +++ b/README.md @@ -1,30 +1,24 @@ # hyperion-docker -This repository is based on the work of [psychowood](https://github.com/psychowood/hyperion.ng-docker) although it has suffered some modifications. - ![Hyperion](https://github.com/hyperion-project/hyperion.ng/blob/master/doc/logo_dark.png?raw=true#gh-dark-mode-only) ![Hyperion](https://github.com/hyperion-project/hyperion.ng/blob/master/doc/logo_light.png?raw=true#gh-light-mode-only) -This is a simple repository containining some the source files that enable you tu run [hyperiong.ng](https://github.com/hyperion-project/hyperion.ng/#readme) in a docker container. -You can choose between building the image yourself or using the image that's published in this repositoru. +This is a simple repository containing the source files that enable you tu run [hyperiong.ng](https://github.com/hyperion-project/hyperion.ng/#readme) in a docker container. +You can choose between building the image yourself or using the image that's published in this repository. -The image is quite simple: +This repository initially was based on the work of [psychowood](https://github.com/psychowood/hyperion.ng-docker). +Upon putting further thought into it seemed necesasary to use a custom build instead of the official deb packages. -1. It's based on the [official Debian 12 (bookworm) docker image](https://hub.docker.com/_/debian) -2. It downloads the hyperion official package from the [official hyperion apt package repository](https://apt.releases.hyperion-project.org/) + +The image has the following characteristics: + +1. It's based on the [official Debian 13 (trixie) docker image](https://hub.docker.com/_/debian) +2. It includes a custom build of hyperion designed to take away uncecesarry dependencies 3. Maps the `/config` dirctory as an external volume, to keep your settings 4. Runs hyperiond service as non-root user. Default UID:GID are 1000:1000 but they can be easily changed through environment variables -Sadly, the resulting image is not exaclty slim at ~500MB, because hyperion has lots of dependencies. Since many of them are for the Desktop/Qt UI, it should be possible to slim the image up by cherry picking the ones not used but the cli service, but that's probably not really worth it. - -On the other hand, the running service does not need lots of RAM (on my system takes ~64MB without the cache). - -You have different options to run this image, after starting the container you can reach the web ui going either to http://youdockerhost:8090 or https://youdockerhost:8092 - ### Standard configuration - -``` start the container with `docker compose up -d` with the following `docker-compose.yml` : ```yaml version: '3.3' diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..80b17b3 --- /dev/null +++ b/build.sh @@ -0,0 +1,32 @@ +#!/bin/bash +BUILD_DEPENDENCIES="git nano cmake ninja-build devscripts build-essential lintian python3 python3-dev python3-pip python3-jsonschema python3-jinja2 qt6-base-dev qt6-serialport-dev qt6-websockets-dev libudev-dev libxkbcommon-dev libvulkan-dev libgl1-mesa-dev libusb-1.0-0-dev libasound2-dev libturbojpeg0-dev libjpeg-dev libssl-dev pkg-config libftdi1-dev libcec-dev libp8-platform-dev libudev-dev libdrm-dev libxcb-randr0-dev libxcb-shm0-dev libxcb-image0-dev libx11-dev libxrandr-dev libxrender-dev libxcb-util0-dev libxcb-render0-dev" +HYPERION_RELEASE_TAG="2.1.1" +HYPERION_GIT_REPO_URL="https://github.com/hyperion-project/hyperion.ng.git" +BUILD_TYPE="Release" +ARCHITECTURE="amd64" +BUILD_PLATFORM="" +CODE_DIR="/source" +BUILD_DIR="/build" +BIN_DIR="/usr/bin/hyperiond" +BUILD_ARGS="" + +# determine platform cmake parameter +if [[ ! -z "$BUILD_PLATFORM" ]]; then + PLATFORM="-DPLATFORM=${BUILD_PLATFORM}" +fi + +echo "Installing build dependencies" +apt-get install -y -q $BUILD_DEPENDENCIES +pip install jsonschema + +echo "Cloning source code from Hyperion repository with ${HYPERION_RELEASE_TAG} tag" +git clone --depth 1 --recurse-submodules -q --branch ${HYPERION_RELEASE_TAG} ${HYPERION_GIT_REPO_URL} ${CODE_DIR} + +mkdir -p ${BUILD_DIR} +echo "Compiling application" +cmake -S ${CODE_DIR} -B ${BUILD_DIR} -G Ninja -DCMAKE_INSTALL_PREFIX=${BIN_DIR} -DENABLE_QT=OFF -DCMAKE_BUILD_TYPE=${BUILD_TYPE} ${PLATFORM} ${BUILD_ARGS} +cd ${BUILD_DIR} +cmake --build . +cmake --build . --target install/strip +#remove desktop components +rm -rf /usr/bin/hyperiond/share/hyperion/desktop \ No newline at end of file diff --git a/start.sh b/start.sh index 3f99d42..304477e 100644 --- a/start.sh +++ b/start.sh @@ -12,4 +12,4 @@ done groupmod -g $gid hyperion usermod -u $uid hyperion chown -R hyperion:hyperion /config -sudo -u hyperion /usr/bin/hyperiond -i --userdata /config \ No newline at end of file +sudo -u hyperion /usr/bin/hyperiond/bin/hyperiond -i --userdata /config \ No newline at end of file