Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V2 #46

Merged
merged 47 commits into from
Apr 6, 2021
Merged

V2 #46

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
7f35d2b
First push to v2 branch
phil-d-wilson Dec 16, 2020
e0dd0ef
Many changes
phil-d-wilson Dec 17, 2020
dcf08f4
display rotation & cursor control added
phil-d-wilson Dec 17, 2020
ad34707
Added FLAGS option
phil-d-wilson Dec 17, 2020
717aecd
Implemented service discovery and default flags
phil-d-wilson Dec 21, 2020
4fc186e
RPI dockerfile + fixes
phil-d-wilson Jan 4, 2021
87f3a10
Readme and API endpoint changes
phil-d-wilson Jan 4, 2021
97ddb7a
readme tweaks
phil-d-wilson Jan 5, 2021
59f5113
Fixed kiosk bug. Removed sandbox warning dialogue
phil-d-wilson Jan 5, 2021
97e68c3
Fixes and API features
phil-d-wilson Jan 10, 2021
9e8b3b1
readme fixes
phil-d-wilson Jan 11, 2021
1571a09
Latest
phil-d-wilson Jan 28, 2021
d0b4140
hub meta
phil-d-wilson Jan 29, 2021
ac32efa
Merge pull request #47 from balenablocks/hub
phil-d-wilson Jan 29, 2021
feae1c4
logo
phil-d-wilson Feb 1, 2021
72859d6
Update balena.yml
phil-d-wilson Feb 2, 2021
7095a7b
post-review changes
phil-d-wilson Feb 2, 2021
2a3de83
gitignore trim
phil-d-wilson Feb 2, 2021
e15db43
Move to node 12
phil-d-wilson Feb 5, 2021
c85eedc
meta: add versionist
tmigone Feb 25, 2021
91afc91
Merge pull request #49 from balenablocks/add-versionist
tmigone Feb 25, 2021
8db9048
v1.0.0
balena-ci Feb 25, 2021
b7b7455
meta: run versionist to update balena.yml version
tmigone Mar 1, 2021
2c3b819
Merge pull request #50 from balenablocks/balena-yml-version
Mar 1, 2021
4676a02
v1.0.1
balena-ci Mar 1, 2021
36fd686
build changes
phil-d-wilson Mar 23, 2021
b6dd417
patch: Window size fix and build script bug
phil-d-wilson Apr 2, 2021
466d84e
patch: build script update for manifest
phil-d-wilson Apr 5, 2021
a1c82ee
First push to v2 branch
phil-d-wilson Dec 16, 2020
82d2af6
Many changes
phil-d-wilson Dec 17, 2020
2d191bb
display rotation & cursor control added
phil-d-wilson Dec 17, 2020
02fe96c
Added FLAGS option
phil-d-wilson Dec 17, 2020
53267c8
Implemented service discovery and default flags
phil-d-wilson Dec 21, 2020
1bb4fe8
RPI dockerfile + fixes
phil-d-wilson Jan 4, 2021
ffb2278
Readme and API endpoint changes
phil-d-wilson Jan 4, 2021
55d5af6
readme tweaks
phil-d-wilson Jan 5, 2021
f0f6b87
Fixed kiosk bug. Removed sandbox warning dialogue
phil-d-wilson Jan 5, 2021
83cbe7b
Fixes and API features
phil-d-wilson Jan 10, 2021
27173ae
readme fixes
phil-d-wilson Jan 11, 2021
966f513
Latest
phil-d-wilson Jan 28, 2021
9e6702d
post-review changes
phil-d-wilson Feb 2, 2021
c4f2b5d
gitignore trim
phil-d-wilson Feb 2, 2021
864bc18
Move to node 12
phil-d-wilson Feb 5, 2021
47c2315
build changes
phil-d-wilson Mar 23, 2021
b466336
patch: Window size fix and build script bug
phil-d-wilson Apr 2, 2021
6778388
patch: build script update for manifest
phil-d-wilson Apr 5, 2021
5120608
Merge branch 'V2' of https://github.com/balenablocks/browser into V2
phil-d-wilson Apr 6, 2021
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sha256bca9ad158da383a9af76908776cf6cd8b06359a8a1529c4862fd17fd3f2fc7b3
Dockerfile.raspberrypi3
Dockerfile.raspberrypi4-64

33 changes: 33 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Change Log

All notable changes to this project will be documented in this file
automatically by Versionist. DO NOT EDIT THIS FILE MANUALLY!
This project adheres to [Semantic Versioning](http://semver.org/).

# v1.0.1
## (2021-03-01)

* meta: run versionist to update balena.yml version [Tomás Migone]

# v1.0.0
## (2021-02-25)

* meta: add versionist [Tomás Migone]
* logo [Phil Wilson]
* hub meta [Phil Wilson]
* Updated readme to remove DEBUG and add some display troubleshooting items [Phil Wilson]
* audio: add code to make browser block play nicely with the audio block [Tomás Migone]
* typo: wesite -> website [Matthew McGinn]
* readme: some spelling fixups for consistency [Matthew McGinn]
* minor fix to ROTATE_DISPLAY [Phil Wilson]
* A bucket of issues fixed [Phil Wilson]
* Fixes from Chris's testing. Readme. Build script. [Phil]
* change amd base image [Phil Wilson]
* Added amd64 support [Phil Wilson]
* Removed TV control, changed entrypoint [Phil Wilson]
* html fixes [Phil Wilson]
* If no LAUNCH_URL is set, tries to detect local HTTP service, or displays default HTML page. [Phil Wilson]
* Fixed the cursor control [Phil Wilson]
* Made non-kiosk mode the default [Phil Wilson]
* Added value to DISABLE_GPU setting [Phil Wilson]
* Added remaining variables and rationalised the flags. [Phil Wilson]
51 changes: 51 additions & 0 deletions Dockerfile.raspberrypi
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
ARG NODEJS_VERSION="12"

FROM balenalib/%%BALENA_MACHINE_NAME%%-node:${NODEJS_VERSION}-run
# install required packages
RUN install_packages \
chromium-browser \
rpi-chromium-mods \
libgles2-mesa \
lsb-release \
mesa-vdpau-drivers \
wget \
x11-xserver-utils \
xserver-xorg-input-evdev \
xserver-xorg-legacy \
xserver-xorg-video-fbdev \
xserver-xorg xinit \
xterm

WORKDIR /usr/src/app

# install node dependencies
COPY ./package.json /usr/src/app/package.json
RUN JOBS=MAX npm install --unsafe-perm --production && npm cache clean --force

COPY ./src /usr/src/app/

RUN mkdir -p /etc/chromium/policies
RUN mkdir /etc/chromium/policies/managed
COPY ./policy.json /etc/chromium/policies/managed/my_policy.json

RUN chmod +x ./*.sh

ENV UDEV=1

# Add chromium user
RUN useradd chromium -m -s /bin/bash -G root || true && \
groupadd -r -f chromium && id -u chromium || true \
&& chown -R chromium:chromium /home/chromium || true

COPY ./public-html /home/chromium

# udev rule to set specific permissions
RUN echo 'SUBSYSTEM=="vchiq",GROUP="video",MODE="0660"' > /etc/udev/rules.d/10-vchiq-permissions.rules
RUN usermod -a -G audio,video,tty chromium

# # Set up the audio block. This won't have any effect if the audio block is not being used.
RUN curl -skL https://raw.githubusercontent.com/balenablocks/audio/master/scripts/alsa-bridge/debian-setup.sh| sh
ENV PULSE_SERVER=tcp:audio:4317

# Start app
CMD ["bash", "/usr/src/app/start.sh"]
52 changes: 52 additions & 0 deletions Dockerfile.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
ARG NODEJS_VERSION="12"

FROM balenalib/%%BALENA_MACHINE_NAME%%-node:${NODEJS_VERSION}-run
# install required packages
RUN install_packages \
chromium \
libgles2-mesa \
lsb-release \
mesa-vdpau-drivers \
wget \
x11-xserver-utils \
xserver-xorg-input-evdev \
xserver-xorg-legacy \
xserver-xorg-video-fbdev \
xserver-xorg xinit \
xterm

WORKDIR /usr/src/app

# install node dependencies
COPY ./package.json /usr/src/app/package.json
RUN JOBS=MAX npm install --unsafe-perm --production && npm cache clean --force

COPY ./src /usr/src/app/

RUN chmod +x ./*.sh

ENV UDEV=1

RUN mkdir -p /etc/chromium/policies
RUN mkdir -p /etc/chromium/policies/recommended
COPY ./policy.json /etc/chromium/policies/recommended/my_policy.json

# Add chromium user
RUN useradd chromium -m -s /bin/bash -G root || true && \
groupadd -r -f chromium && id -u chromium || true \
&& chown -R chromium:chromium /home/chromium || true

COPY ./public-html /home/chromium

# udev rule to set specific permissions
RUN echo 'SUBSYSTEM=="vchiq",GROUP="video",MODE="0660"' > /etc/udev/rules.d/10-vchiq-permissions.rules
RUN usermod -a -G audio,video,tty chromium

RUN ln -s /usr/bin/chromium /usr/bin/chromium-browser || true

# Set up the audio block. This won't have any effect if the audio block is not being used.
RUN curl -skL https://raw.githubusercontent.com/balenablocks/audio/master/scripts/alsa-bridge/debian-setup.sh| sh
ENV PULSE_SERVER=tcp:audio:4317
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you test the integration with the audio block? If not let me know and I can do it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tmigone I haven't yet. If you wouldn't mind testing the block in general, and the audio link specifically, that would be much appreciated.


# Start app
CMD ["bash", "/usr/src/app/start.sh"]
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.0.1
25 changes: 25 additions & 0 deletions balena.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: browser
description: >-
a hardware accelerated web browser to present internal and external URLs on a
connected display
version: 1.0.1
type: sw.application
assets:
repository:
type: blob.asset
data:
url: 'https://github.com/balenablocks/browser'
logo:
type: blob.asset
data:
url: 'https://raw.githubusercontent.com/balenablocks/browser/master/logo.png'
data:
defaultDeviceType: raspberrypi3
supportedDeviceTypes:
- raspberrypi4-64
- fincm3
- raspberrypi3
- raspberrypi3-64
- raspberrypi400-64
- intel-nuc
- genericx86-64-ext
55 changes: 31 additions & 24 deletions build-images.sh
Original file line number Diff line number Diff line change
@@ -1,50 +1,57 @@
#!/bin/bash
set -e

function build_and_push_image () {
BLOCK_NAME="browser"

function build_image () {
local DOCKER_REPO=$1
local BALENA_MACHINE_NAME=$2
local DOCKER_ARCH=$3
local DOCKERFILE_DIR=./generic

echo "Building for machine name $BALENA_MACHINE_NAME, platform $DOCKER_ARCH, pushing to $DOCKER_REPO/$BLOCK_NAME"

# The RPIs all use the same dockerfile for now
if [[ $BALENA_MACHINE_NAME = raspberry* ]]; then
DOCKERFILE_DIR=./rpi
sed "s/%%BALENA_MACHINE_NAME%%/$BALENA_MACHINE_NAME/g" ./Dockerfile.raspberrypi > ./Dockerfile.$BALENA_MACHINE_NAME
else
sed "s/%%BALENA_MACHINE_NAME%%/$BALENA_MACHINE_NAME/g" ./Dockerfile.template > ./Dockerfile.$BALENA_MACHINE_NAME
fi

docker buildx build -t $DOCKER_REPO/$BLOCK_NAME:$BALENA_MACHINE_NAME --push --platform $DOCKER_ARCH --file Dockerfile.$BALENA_MACHINE_NAME .

echo "Building for machine name $BALENA_MACHINE_NAME, platform $DOCKER_ARCH using dockerfile from $DOCKERFILE_DIR, pushing to $DOCKER_REPO/browser"

sed "s/%%BALENA_MACHINE_NAME%%/$BALENA_MACHINE_NAME/g" $DOCKERFILE_DIR/Dockerfile.template > ./Dockerfile.$BALENA_MACHINE_NAME
docker buildx build -t $DOCKER_REPO/browser:$BALENA_MACHINE_NAME --platform $DOCKER_ARCH --file Dockerfile.$BALENA_MACHINE_NAME .

echo "Publishing..."
docker push $DOCKER_REPO/browser:$BALENA_MACHINE_NAME

echo "Cleaning up..."
echo "Cleaning up temporary dockerfiles..."
rm Dockerfile.$BALENA_MACHINE_NAME
}

function retag_and_push_image () {
function retag_image () {
local DOCKER_REPO=$1
local BUILT_TAG=$2
local NEW_TAG=$3

echo "Taging $DOCKER_REPO/browser:$BUILT_TAG as $DOCKER_REPO/browser:$NEW_TAG"
docker tag $DOCKER_REPO/browser:$BUILT_TAG $DOCKER_REPO/browser:$NEW_TAG
echo "Taging $DOCKER_REPO/$BLOCK_NAME:$BUILT_TAG as $DOCKER_REPO/$BLOCK_NAME:$NEW_TAG"
docker tag $DOCKER_REPO/$BLOCK_NAME:$BUILT_TAG $DOCKER_REPO/$BLOCK_NAME:$NEW_TAG

echo "Publishing..."
docker push $DOCKER_REPO/browser:$NEW_TAG
# echo "Publishing..."
docker push $DOCKER_REPO/$BLOCK_NAME:$NEW_TAG
}

function create_and_push_manifest() {
local DOCKER_REPO=$1
docker manifest rm $DOCKER_REPO/$BLOCK_NAME:latest || true
docker manifest create $DOCKER_REPO/$BLOCK_NAME:latest --amend $DOCKER_REPO/$BLOCK_NAME:raspberrypi3 --amend $DOCKER_REPO/$BLOCK_NAME:raspberrypi4-64 --amend $DOCKER_REPO/$BLOCK_NAME:genericx86-64-ext
docker manifest annotate --arch arm64 $DOCKER_REPO/$BLOCK_NAME:latest $DOCKER_REPO/$BLOCK_NAME:raspberrypi4-64
docker manifest annotate --variant v8 $DOCKER_REPO/$BLOCK_NAME:latest $DOCKER_REPO/$BLOCK_NAME:raspberrypi4-64
docker manifest push $DOCKER_REPO/$BLOCK_NAME:latest
}

# YOu can pass in a repo (such as a test docker repo) or accept the default
DOCKER_REPO=${1:-balenablocks}

#RPI4 is built as ARMv7 because the base Raspian image is 32-bit
build_and_push_image $DOCKER_REPO "raspberrypi3" "linux/arm/v7"

#only need to build once per arch, and retag & push for clones
retag_and_push_image $DOCKER_REPO "raspberrypi3" "raspberrypi4-64"
retag_and_push_image $DOCKER_REPO "raspberrypi3" "raspberrypi3-64"
retag_and_push_image $DOCKER_REPO "raspberrypi3" "fincm3"
build_image $DOCKER_REPO "raspberrypi3" "linux/arm/v7"
#RPI4 is built as ARMv7 because there are currently (jan 2021) no 64-bit chromium sources from RPI
retag_image $DOCKER_REPO "raspberrypi3" "raspberrypi4-64"

build_image $DOCKER_REPO "genericx86-64-ext" "linux/amd64"

build_and_push_image $DOCKER_REPO "genericx86-64-ext" "linux/amd64"
create_and_push_manifest $DOCKER_REPO
13 changes: 13 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: '2'

volumes:
settings: # Only required if using PERSISTENT flag (see below)

services:

browser:
image: balenablocks/browser
privileged: true # required for UDEV to find plugged in peripherals such as a USB mouse
network_mode: host
volumes:
- 'settings:/data' # Only required if using PERSISTENT flag (see below)
42 changes: 0 additions & 42 deletions generic/Dockerfile.template

This file was deleted.

Binary file added logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 38 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"name": "browserV2",
"version": "0.0.1",
"description": "balenaBlock that provides a chromium browser wrapped in some balena genius",
"main": "index.js",
"scripts": {

},
"repository": {
"type": "git",
"url": "git+https://github.com/balenablocks/browser.git"
},
"keywords": [
"balena",
"browser",
"chromium"
],
"author": "Phil Wilson <[email protected]>",
"license": "Apache-2.0",
"jshintConfig": {
"esversion": 8
},
"bugs": {
"url": "https://github.com/balenablocks/browser/issues"
},
"homepage": "https://github.com/balenablocks/browser#readme",
"dependencies": {
"chrome-launcher": "^0.13.4",
"body-parser": "^1.19.0",
"compression": "^1.7.4",
"dateformat": "^3.0.3",
"debug": "^4.1.1",
"express": "^4.17.1",
"bent": "7.3.10",
"set-interval-async": "^1.0.34"
}
}

7 changes: 7 additions & 0 deletions policy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"HomepageLocation": "www.balea.io",
"ExtensionInstallForcelist": [
"aleakchihdccplidncghkekgioiakgal",
"cfhdojbkjhnklbpkdaibdccddilifddb"
]
}
7 changes: 4 additions & 3 deletions public-html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<header class="my-auto bg-primary text-white">
<div class="container text-center ">
<h1>balenalabs-browser</h1>
<p class="lead">A primitive block for browsing HTML</p>
<p class="lead">A balena block for browsing HTML</p>
</div>
</header>

Expand All @@ -44,8 +44,9 @@ <h1>balenalabs-browser</h1>
<h2>Choosing what to display</h2>
<p class="lead">You have a few options for choosing what to display here:</p>
<ul>
<li>You can create a service on this device serving HTTP over port 80, and it'll display here automatically! **</li>
<li>You can create a service on this device serving HTTP over port 80 or 8080, or HTTPS over 443, and it'll display here automatically! **</li>
<li>You can set a Device Variable called <code>LAUNCH_URL</code></li>
<li>You can use the API on port 5011 to set the URL (see project readme for details)</li>
</ul>
<blockquote>** The balenalabs-browser service will need <code>network_mode: host</code> set.</blockquote>
</div>
Expand All @@ -56,7 +57,7 @@ <h2>Choosing what to display</h2>
<footer class="py-5 bg-dark">
<div class="container">
<p class="m-0 text-center text-white">
Copyright 2020 Balena |
Copyright 2021 Balena |
All Rights Reserved</p>
</div>
<!-- /.container -->
Expand Down
Loading