Skip to content

Commit ffe748d

Browse files
Merge pull request #196 from balena-io-experimental/mtoman/deb13
Update to Debian 13 and enable vulkan
2 parents 2a79288 + 303749d commit ffe748d

5 files changed

Lines changed: 47 additions & 16 deletions

File tree

Dockerfile.template

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:20.19.2-bookworm
1+
FROM debian:13
22

33
ENV DEBIAN_FRONTEND=noninteractive
44

@@ -7,11 +7,33 @@ COPY ./build /usr/src/build
77
RUN chmod a+x /usr/src/build/install_chromium
88
RUN /usr/src/build/install_chromium "%%BALENA_MACHINE_NAME%%"
99

10+
# Install node
11+
WORKDIR /usr/local
12+
13+
# renovate: datasource=node-version depName=node
14+
ARG NODE_VERSION=22.21.1
15+
16+
RUN curl "https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-$(dpkg --print-architecture | sed -e 's/amd/x/' -e 's/armhf/armv7l/').tar.gz" \
17+
| tar xz --strip-components=1 \
18+
&& ./bin/node --version
19+
20+
# renovate: datasource=npm depName=npm
21+
ARG NPM_VERSION=11.6.3
22+
23+
# install npm
24+
RUN npm install -g "npm@${NPM_VERSION}" \
25+
&& rm -rf /root/.npm/_cacache \
26+
&& npm cache clear --force \
27+
&& rm -rf /tmp/*
28+
1029
WORKDIR /usr/src/app
1130

1231
# install node dependencies
1332
COPY ./package.json /usr/src/app/package.json
14-
RUN JOBS=MAX npm install --unsafe-perm --production && npm cache clean --force
33+
RUN JOBS=MAX npm install --unsafe-perm --production \
34+
&& rm -rf /root/.npm/_cacache \
35+
&& npm cache clear --force \
36+
&& rm -rf /tmp/*
1537

1638
COPY ./src /usr/src/app/
1739

build/install_chromium

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
# * The Raspberry Pi 5 needs patched versions of mesa and X to work
1111

1212
BASE_DIR="/usr/src/build"
13-
CHROMIUM_PACKAGE="chromium"
14-
1513
MACHINE_NAME="$1"
1614

1715
# FORCE_RPI_REPO=0 never includes the repo
@@ -24,23 +22,21 @@ then
2422

2523
cp -a "${BASE_DIR}/rpi/raspi.list" "/etc/apt/sources.list.d/"
2624
cp -a "${BASE_DIR}/rpi/raspberrypi-archive-stable.gpg" "/etc/apt/trusted.gpg.d/"
27-
28-
# The RPi-patched chromium package is called chromium-browser
29-
CHROMIUM_PACKAGE="chromium-browser"
30-
else
31-
echo "Defaulting to vanilla chromium"
32-
# The node library launches /usr/bin/chromium-browser
33-
# which is not provided by the upstream package
34-
ln -s /usr/bin/chromium /usr/bin/chromium-browser
3525
fi
3626

27+
# The node library launches /usr/bin/chromium-browser
28+
# which is not provided by the upstream package
29+
ln -sf /usr/bin/chromium /usr/bin/chromium-browser
30+
3731
# mimic previous balenalib "install_packages" behavior:
3832
apt-get update && apt-get install -y --no-install-recommends \
39-
${CHROMIUM_PACKAGE} \
33+
chromium \
4034
chromium-common \
41-
libgles2-mesa \
35+
ca-certificates \
36+
curl \
4237
lsb-release \
4338
mesa-vdpau-drivers \
39+
mesa-vulkan-drivers \
4440
scrot \
4541
x11-xserver-utils \
4642
xserver-xorg-input-evdev \

build/rpi/raspi.list

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
deb http://archive.raspberrypi.com/debian/ bookworm main
1+
deb http://archive.raspberrypi.com/debian/ trixie main
22
# Uncomment line below then 'apt-get update' to enable 'apt-get source'
3-
#deb-src http://archive.raspberrypi.com/debian/ bookworm main
3+
#deb-src http://archive.raspberrypi.com/debian/ trixie main

readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ The following environment variables allow configuration of the `browser` block:
8888
|`ROTATE_DELAY`|`n`|`3`|Add an artificial delay (in seconds) before applying display rotation|
8989
|`TOUCHSCREEN`|`string`|N\A|Name of Touch Input to rotate|
9090
|`ENABLE_GPU`|`0`, `1`|0|Enables the GPU rendering. Necessary for Pi3B+ to display YouTube videos. <br/> `0` = off, `1` = on|
91+
|`FORCE_VULKAN`|`0`, `1`|undefined|In combination with `ENABLE_GPU`, forces vulkan to either be enabled or disabled in chromium. If undefined or an invalid value, vulkan is only automatically enabled on the Raspberry Pi 5|
9192
|`WINDOW_SIZE`|`x,y`|Detected screen resolution|Sets the browser window size, such as `800,600`. <br/> **Note:** Reverse the dimensions if you also rotate the display to `left` or `right` |
9293
|`WINDOW_POSITION`|`x,y`|`0,0`|Specifies the browser window position on the screen|
9394
|`API_PORT`|port number|5011|Specifies the port number the API runs on|

src/server.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const FLAGS = process.env.FLAGS || null;
2323
const EXTRA_FLAGS = process.env.EXTRA_FLAGS || null;
2424
const HTTPS_REGEX = /^https?:\/\//i //regex for HTTP/S prefix
2525
const AUTO_REFRESH = process.env.AUTO_REFRESH || 0;
26+
const FORCE_VULKAN = process.env.FORCE_VULKAN || "-1";
2627

2728
// Environment variables which can be overriden from the API
2829
let kioskMode = process.env.KIOSK || '0';
@@ -141,6 +142,17 @@ let launchChromium = async function(url) {
141142
'--enable-gpu-rasterization',
142143
];
143144

145+
// Enable vulkan
146+
// This only seems to make a difference on the Raspberry Pi 5,
147+
// it enables HW accelerated video decoding at the cost of some OpenGL performance
148+
// * If FORCE_VULKAN is 0, never enable vulkan
149+
// * If FORCE_VULKAN is 1, always enable vulkan
150+
// * If FORCE_VULKAN is anything else or undefined, enable vulkan if the device is a RPi5
151+
if (FORCE_VULKAN === "1" || (process.env.BALENA_DEVICE_TYPE === "raspberrypi5" && FORCE_VULKAN !== "0"))
152+
{
153+
gpuFlags.push('--enable-features=Vulkan');
154+
}
155+
144156
flags = flags.concat(gpuFlags);
145157
}
146158
}

0 commit comments

Comments
 (0)