VNC: add dashboard app and noVNC config (#99)
* VNC: add dashboard app and auto config * VNC: add dashboard app and noVNC config * format * format again * Update config.yaml Co-authored-by: Dean Sheather <dean@coder.com>
This commit is contained in:
parent
aa06f95f54
commit
91ef8f521b
|
@ -100,7 +100,8 @@ RUN find $VNC_SETUP_SCRIPTS -name '*.sh' -exec chmod a+x {} +
|
|||
RUN $VNC_SETUP_SCRIPTS/set_user_permission.sh $VNC_ROOT_DIR \
|
||||
&& chmod +x $VNC_XSTARTUP
|
||||
|
||||
COPY ["configure", "/coder/configure"]
|
||||
# Add Coder-specific scripts and metadata to the image
|
||||
COPY ["./coder", "/coder"]
|
||||
RUN chmod +x /coder/configure
|
||||
|
||||
USER coder
|
||||
|
|
|
@ -4,13 +4,18 @@ A [sample image](https://github.com/cdr/enterprise-images/tree/main/images/vnc)
|
|||
|
||||
## To connect
|
||||
|
||||
- Option 1 (Web): Create a dev URL on port `6081` and navigate to it
|
||||
- Option 2 (SSH Tunneling): Use SSH tunneling to expose the VNC server to your local machine. You will need the [coder-cli](https://github.com/cdr/coder-cli) and a VNC client installed on your local machine.
|
||||
- Option 1 (Web): Click the "Desktop" application from the Coder dashboard on any workspace that uses this VNC image.
|
||||
|
||||
![VNC application screenshot](./example.png)
|
||||
|
||||
- Option 2 (SSH Tunneling): Connect from your local VNC Client. Expose the VNC server to your local machine. You will need the [coder-cli](https://github.com/cdr/coder-cli) and any VNC client installed on your local machine.
|
||||
|
||||
```sh
|
||||
coder config-ssh
|
||||
# Forward the remote VNC server to your local machine
|
||||
ssh -L -N 5990:localhost:5990 coder.[env-name]
|
||||
coder tunnel vnc-ux 5990 5990
|
||||
# You will not see any output if it succeeds, but you
|
||||
# will be able to connect your VNC client to localhost:5990
|
||||
```
|
||||
|
||||
- Option 3 (Web): Create a dev URL on port `6081` and navigate to it
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
# Adds a "Desktop" app to this workspace in the Coder dashboard
|
||||
apps:
|
||||
- name: Desktop
|
||||
scheme: http
|
||||
port: 6081
|
||||
# Working directory
|
||||
working-directory: /home/coder
|
||||
# File path to icon used in application launcher
|
||||
icon-path: /coder/apps/desktop.png
|
||||
# VNC server will be started by default in this image
|
||||
command: supervisorctl
|
||||
# Array of arguments for command
|
||||
args: ["start", "vncserver"]
|
||||
health-check:
|
||||
exec:
|
||||
command: "supervisorctl"
|
||||
args: ["status", "vncserver"]
|
||||
http:
|
||||
scheme: "http"
|
||||
path: "/"
|
||||
port: 6081
|
Binary file not shown.
After Width: | Height: | Size: 105 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.1 MiB |
|
@ -0,0 +1,50 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>VNC Desktop</title>
|
||||
<style type="text/css">
|
||||
body {
|
||||
margin: 0;
|
||||
/* Reset default margin */
|
||||
}
|
||||
|
||||
iframe {
|
||||
display: block;
|
||||
/* iframes are inline by default */
|
||||
background: #000;
|
||||
border: none;
|
||||
/* Reset default border */
|
||||
height: 100vh;
|
||||
/* Viewport-relative units */
|
||||
width: 100vw;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<iframe src="vnc.html" id="desktop">
|
||||
Your browser does not support iFrames. Navigate to
|
||||
<a id="desktop-link" href="vnc.html">vnc.html</a>.
|
||||
</iframe>
|
||||
|
||||
<script type="text/javascript">
|
||||
let url = "vnc.html?resize=remote&autoconnect=1&path=";
|
||||
let path = "websockify";
|
||||
if (window.location.pathname) {
|
||||
// change the path depending on window.location (necessary for websockets to work on Coder's application path
|
||||
// ex. /api/v0/workspaces/[id]/proxy/apps/desktop/)
|
||||
path = window.location.pathname;
|
||||
path = path.replace(/^\/|\/$/g, "");
|
||||
path = path + "/websockify";
|
||||
console.log(path);
|
||||
} else {
|
||||
console.error("window.location.pathname is undefined");
|
||||
}
|
||||
document.getElementById("desktop").src = url + path;
|
||||
document.getElementById("desktop-link").href = url + path;
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -7,5 +7,5 @@ wget -qO- https://github.com/novnc/noVNC/archive/v1.2.0.tar.gz | tar xz --strip
|
|||
wget -qO- https://github.com/novnc/websockify/archive/v0.9.0.tar.gz | tar xz --strip 1 -C "$NO_VNC_HOME/utils/websockify"
|
||||
chmod +x -v "$NO_VNC_HOME"/utils/*.sh
|
||||
|
||||
## Create index.html to forward automatically to `vnc.html`
|
||||
ln -s "$NO_VNC_HOME/vnc.html" "$NO_VNC_HOME/index.html"
|
||||
# Add our index with settings optimized for Coder
|
||||
ln -s "$VNC_ROOT_DIR/index.html" "$NO_VNC_HOME/index.html"
|
Loading…
Reference in New Issue