Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Chara White committed Jun 6, 2024
0 parents commit 6d4e893
Show file tree
Hide file tree
Showing 57 changed files with 11,797 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.git
.gitattributes
.gitignore
.github/
app.json
heroku.yml
Makefile
Dockerfile.heroku
CHANGELOG.md
data/
log/
25 changes: 25 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.vscode/
.vagrant*
bin
docker/docker
.*.swp
a.out
*.orig
build_src
.flymake*
.idea
.DS_Store
docs/_build
docs/_static
docs/_templates
.gopath/
.dotcloud
*.test
bundles/
.hg/
vendor/pkg/
pyenv
Vagrantfile
data/
log/
.env
52 changes: 52 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
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="sleep infinity"

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

COPY assets/ /

# get grass extension
RUN 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)
RUN apk del openssl build-base && \
rm -rf /var/cache/apk/* /tmp/* /extension

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

CMD ["/config/supervisord.conf"]
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 Apoorv Vyavahare

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
24 changes: 24 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
USR=cwithw
NAME=grass-chrome-novnc
TAG=latest
IMG=${USR}/${NAME}:${TAG}
PUSH_TAG=$(shell date +%Y%m%d%H%M%S)
PUSH_IMG=${USR}/${NAME}:${PUSH_TAG}

build: clean
docker build --tag ${IMG} --no-cache . --build-arg https_proxy=http://192.168.32.2:7890

up:
docker-compose up

down:
docker-compose down

clean:
docker stop ${IMG} 2>/dev/null || :
docker rm ${IMG} 2>/dev/null || :
docker rmi ${IMG} 2>/dev/null || :

push:
docker tag ${IMG} ${PUSH_IMG}
docker push ${PUSH_IMG}
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Grass-Chromium-Novnc
Based on https://github.com/vital987/chrome-novnc .

Removed the Heroku keep-alive part because you can't run Grass on Heroku anyways.

## Usage

### with docker compose
`docker compose up` and access `http://localhost:8080` to access the VNC.

### with docker run
```
docker run -d -p 8080:8080 -e VNC_PASS=CHANGE_IT cwithw/grass-chrome-novnc:latest
```


## Pre built image
amd64: `cwithw/grass-chrome-novnc:latest`

## 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.

## Environment variables:
|VARIABLE |DESCRIPTION |DEFAULT VALUE |
|-------------:|:------------------------|:-------------:|
|VNC_PASS |VNC Password |CHANGE_IT |
|VNC_TITLE |VNC Session Title |GrassChromium |
|VNC_SHARED |VNC Shared Mode |false |
|VNC_RESOLUTION|VNC Resolution |800x600 |
|EXTRA_COMMAND |Extra command to run. can be used to update grass extension(`sh /scripts/getgrass.sh && sleep infinity`) or start ssh proxy(`sshpass -p password ssh -o StrictHostKeyChecking=no -N -C -D 1337 root@bounceServer`). make sure this command runs forever and does not exit on success. |sleep infinity |
|HOMEPAGE |Homepage to open |grass homepage|
|EXTRA_CHROME_OPTS|Extra chrome options. can be used to set proxy(--proxy-server=). | |
|HOST_PORT |Host port for VNC |8080 |

## directories
/data: data. mount this folder to keep your grass cookies.
/var/log: log
6 changes: 6 additions & 0 deletions assets/config/supervisor/1-init.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[program:init]
command=sh /scripts/init.sh
stderr_logfile=/var/log/init.err.log
exitcodes=0
startsecs=0
priority=1
6 changes: 6 additions & 0 deletions assets/config/supervisor/1-xvfb.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[program:Xvfb]
command=bash -c 'Xvfb $DISPLAY -screen 0 $VNC_RESOLUTION"x24" -nolisten unix'

stderr_logfile=/var/log/Xvfb.stderr.log
priority=1

6 changes: 6 additions & 0 deletions assets/config/supervisor/2-openbox.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[program:Openbox]
command=openbox

priority=2
stderr_logfile=/var/log/openbox.err.log

6 changes: 6 additions & 0 deletions assets/config/supervisor/3-vnc.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[program:VNC]
command=bash -c 'sed -i "s/\$DESKTOP/$VNC_TITLE/g" /opt/novnc/index.html && if ((VNC_SHARED==false)); then x11vnc -storepasswd $VNC_PASS /config/.xpass && x11vnc -usepw -rfbport 5900 -rfbauth /config/.xpass -geometry $VNC_RESOLUTION -forever -alwaysshared -permitfiletransfer -noxrecord -noxfixes -noxdamage -dpms -bg -desktop $VNC_TITLE; else x11vnc -storepasswd $VNC_PASS /config/.xpass && x11vnc -usepw -rfbport 5900 -rfbauth /config/.xpass -geometry $VNC_RESOLUTION -forever -shared -alwaysshared -permitfiletransfer -bg -desktop $VNC_TITLE; fi'
startsecs=0
autorestart=unexpected
stderr_logfile=/var/log/x11vnc.stderr.log
priority=3
5 changes: 5 additions & 0 deletions assets/config/supervisor/4-extra-command.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[program:ExtraCommand]
command=bash -c "$EXTRA_COMMAND"
priority=4
autorestart=true
stderr_logfile=/var/log/extra_command.err.log
6 changes: 6 additions & 0 deletions assets/config/supervisor/4-websockify.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[program:Websockify]
command=bash -c 'websockify --cert /etc/ssl/novnc.cert --key /etc/ssl/novnc.key -D --web=/opt/novnc/ $PORT localhost:5900'
startsecs=0
autorestart=unexpected
stderr_logfile=/var/log/websockify.stderr.log
priority=4
5 changes: 5 additions & 0 deletions assets/config/supervisor/5-chromium.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[program:Chromium]
command=bash -c 'chromium --ignore-certificate-errors --no-sandbox --test-type --disable-dev-shm-usage --disable-gpu --start-maximized --load-extension=/root/grass-extension $EXTRA_CHROME_OPTS $HOMEPAGE'
priority=5
autorestart=true
stderr_logfile=/var/log/chromium.err.log
6 changes: 6 additions & 0 deletions assets/config/supervisord.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[supervisord]
nodaemon=true

[include]
files = /config/supervisor/*.conf

22 changes: 22 additions & 0 deletions assets/opt/novnc/css/bootstrap.custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* Allow navbar slide effect. */
.navbar {
min-height: 0px;
}

@media (min-width: 768px) {
.navbar-right > li {
padding-right:10px;
}
}

@media (max-width: 767px) {
.navbar-nav > li {
padding-left:10px;
padding-right:10px;
}

/* Make full-width buttons in collapsed navbar. */
.navbar-btn,.navbar-btn .btn {
width:100%;
}
}
6 changes: 6 additions & 0 deletions assets/opt/novnc/css/bootstrap.min.css

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions assets/opt/novnc/css/font-awesome.min.css

Large diffs are not rendered by default.

Binary file added assets/opt/novnc/fonts/FontAwesome.otf
Binary file not shown.
Binary file added assets/opt/novnc/fonts/fontawesome-webfont.eot
Binary file not shown.
Loading

0 comments on commit 6d4e893

Please sign in to comment.