diff --git a/.github/workflows/buildPushDockerImage.yml b/.github/workflows/buildPushDockerImage.yml index 4723f81..73b7dbe 100644 --- a/.github/workflows/buildPushDockerImage.yml +++ b/.github/workflows/buildPushDockerImage.yml @@ -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 \ No newline at end of file + 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 \ No newline at end of file diff --git a/Dockerfile.community b/Dockerfile.community new file mode 100644 index 0000000..35789d5 --- /dev/null +++ b/Dockerfile.community @@ -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"] diff --git a/Dockerfile b/Dockerfile.lite similarity index 97% rename from Dockerfile rename to Dockerfile.lite index e079cd0..4329916 100644 --- a/Dockerfile +++ b/Dockerfile.lite @@ -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/ / diff --git a/README.md b/README.md index 9929ea3..7554380 100644 --- a/README.md +++ b/README.md @@ -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. @@ -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. diff --git a/assets/scripts/getgrass.sh b/assets/scripts/getgrass.sh index 43ed569..dbcbc0d 100644 --- a/assets/scripts/getgrass.sh +++ b/assets/scripts/getgrass.sh @@ -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 @@ -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')