Skip to content

Commit

Permalink
add community node flavor
Browse files Browse the repository at this point in the history
  • Loading branch information
Chara White committed Jul 14, 2024
1 parent 03ce405 commit 88e3f5e
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 12 deletions.
13 changes: 11 additions & 2 deletions .github/workflows/buildPushDockerImage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,19 @@ jobs:
username: ${{ secrets.DOCKER_USR }}
password: ${{ secrets.DOCKER_TOKEN }}

- name: Build and push
- name: Build and push lite
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile.lite
platforms: linux/amd64,linux/arm64
push: true
tags: cwithw/grass-chrome-novnc:latest
tags: cwithw/grass-chrome-novnc:lite,cwithw/grass-chrome-novnc:latest
- name: Build and push community
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile.community
platforms: linux/amd64,linux/arm64
push: true
tags: cwithw/grass-chrome-novnc:community
51 changes: 51 additions & 0 deletions Dockerfile.community
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
FROM alpine:3.19.1

LABEL AboutImage "grass-chrome-novnc"

LABEL Maintainer "Chara White"

#VNC Server Password
ENV VNC_PASS="CHANGE_IT" \
#VNC Server Title(w/o spaces)
VNC_TITLE="GrassChromium" \
#VNC Resolution(720p is preferable)
VNC_RESOLUTION="800x600" \
#VNC Shared Mode
VNC_SHARED=false \
#Local Display Server Port
DISPLAY=:0 \
#NoVNC Port
NOVNC_PORT=$PORT \
PORT=8080 \
#Locale
LANG=en_US.UTF-8 \
LANGUAGE=en_US.UTF-8 \
LC_ALL=C.UTF-8 \
TZ="Asia/Shanghai" \
# Extra
HOMEPAGE="https://app.getgrass.io/" \
EXTRA_CHROME_OPTS="" \
EXTRA_COMMAND="exit 0" \
GRASS_FLAVOR="community"

COPY assets/ /

RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories && \
apk update && \
apk add --no-cache tzdata ca-certificates supervisor curl wget openssl bash sed unzip xvfb x11vnc websockify openbox chromium nss alsa-lib font-noto font-noto-cjk openssh sshpass jq && \
# noVNC SSL certificate
openssl req -new -newkey rsa:4096 -days 36500 -nodes -x509 -subj "/C=IN/O=Dis/CN=www.google.com" -keyout /etc/ssl/novnc.key -out /etc/ssl/novnc.cert > /dev/null 2>&1 && \
# TimeZone
cp /usr/share/zoneinfo/$TZ /etc/localtime && \
echo $TZ > /etc/timezone && \
# get grass extension
sh /scripts/getgrass.sh && \
# Wipe Temp Files
# Don't delete curl,wget,jq,unzip as they are used in scripts
# keep ssh, sshpass for ssh tunneling(user custom usage)
apk del openssl build-base && \
rm -rf /var/cache/apk/* /tmp/* /extension

ENTRYPOINT ["supervisord", "-l", "/var/log/supervisord.log", "-c"]

CMD ["/config/supervisord.conf"]
3 changes: 2 additions & 1 deletion Dockerfile → Dockerfile.lite
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ ENV VNC_PASS="CHANGE_IT" \
# Extra
HOMEPAGE="https://app.getgrass.io/" \
EXTRA_CHROME_OPTS="" \
EXTRA_COMMAND="exit 0"
EXTRA_COMMAND="exit 0" \
GRASS_FLAVOR="lite"

COPY assets/ /

Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ Add other environment variables if needed.


## Pre built image
amd64: `cwithw/grass-chrome-novnc:latest`
`cwithw/grass-chrome-novnc:lite` for lite node, `cwithw/grass-chrome-novnc:community` for community node.

arm64: `cwithw/grass-chrome-novnc:latest`
`cwithw/grass-chrome-novnc:latest` is an alias for `cwithw/grass-chrome-novnc:lite`.

## Building
if you are having trouble building it because you cannot access google server to download Grass plugin, you can use `docker build . -t cwithw/grass-chrome-novnc:latest --build-arg https_proxy=http://192.168.32.2:7890` to build it with proxy.
Expand All @@ -44,6 +44,7 @@ if you are having trouble building it because you cannot access google server to
|HOMEPAGE |Homepage to open |[grass homepage](https://app.getgrass.io/)|
|EXTRA_CHROME_OPTS|Extra chrome options. can be used to set proxy(--proxy-server=). | |
|HOST_PORT |Host port for VNC |8080 |
|GRASS_FLAVOR |Grass flavor to use. `lite` for lite node, `community` for community node. You don't have to change this; use the different docker images. |lite |

## directories
/data: data. mount this folder to keep your grass cookies.
Expand Down
31 changes: 24 additions & 7 deletions assets/scripts/getgrass.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,30 @@

set -e

extensionId='ilehaonighjijnmpnagapkhpcdbhclfg'
CRX_URL="https://clients2.google.com/service/update2/crx?response=redirect&prodversion=98.0.4758.102&acceptformat=crx2,crx3&x=id%3D~~~~%26uc&nacl_arch=x86-64"
USER_AGENT="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36"

# Download the CRX file
if [ "$GRASS_FLAVOR" != "community" ] && [ "$GRASS_FLAVOR" != "lite" ]; then
echo "Invalid GRASS_FLAVOR: $GRASS_FLAVOR, must be one of 'community' or 'lite'"
exit 1
fi

REAL_CRX_URL=$(echo "$CRX_URL" | sed "s/~~~~/$extensionId/g")
echo "Downloading Grass extension..."
wget -O /tmp/grass.crx --user-agent="$USER_AGENT" "$REAL_CRX_URL"
if [ "$GRASS_FLAVOR" = "community" ]; then
echo "Downloading Grass extension (community)..."
CRX_URL="https://files.getgrass.io/file/grass-extension-upgrades/extension-latest/grass-community-node-linux-4.20.2.zip"
USER_AGENT="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36"
# download the zip file, need to extract the CRX file from it.
wget -O /tmp/grass.zip --user-agent="$USER_AGENT" "$CRX_URL"
unzip /tmp/grass.zip -d /tmp
mv /tmp/grass*.crx /tmp/grass.crx
rm /tmp/grass.zip
else
echo "Downloading Grass extension (lite)..."
extensionId='ilehaonighjijnmpnagapkhpcdbhclfg'
CRX_URL="https://clients2.google.com/service/update2/crx?response=redirect&prodversion=98.0.4758.102&acceptformat=crx2,crx3&x=id%3D~~~~%26uc&nacl_arch=x86-64"
USER_AGENT="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36"
REAL_CRX_URL=$(echo "$CRX_URL" | sed "s/~~~~/$extensionId/g")
# Download the CRX file
wget -O /tmp/grass.crx --user-agent="$USER_AGENT" "$REAL_CRX_URL"
fi


# extract the CRX file
Expand All @@ -20,6 +35,8 @@ fi
mkdir -p /root/grass-extension
(unzip /tmp/grass.crx -d /root/grass-extension || true)

rm /tmp/grass.crx

# Assert that the extension is valid
ls /root/grass-extension/manifest.json >/dev/null
GRASS_EXTENSION_VERSION=$(cat /root/grass-extension/manifest.json | jq -r '.version')
Expand Down

0 comments on commit 88e3f5e

Please sign in to comment.