-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #46 from balenablocks/V2
V2
- Loading branch information
Showing
15 changed files
with
747 additions
and
307 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
sha256bca9ad158da383a9af76908776cf6cd8b06359a8a1529c4862fd17fd3f2fc7b3 | ||
Dockerfile.raspberrypi3 | ||
Dockerfile.raspberrypi4-64 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
||
# Start app | ||
CMD ["bash", "/usr/src/app/start.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 <phil@balena.io>", | ||
"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" | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"HomepageLocation": "www.balea.io", | ||
"ExtensionInstallForcelist": [ | ||
"aleakchihdccplidncghkekgioiakgal", | ||
"cfhdojbkjhnklbpkdaibdccddilifddb" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.