Skip to content

Commit

Permalink
its on github yaaay
Browse files Browse the repository at this point in the history
  • Loading branch information
Sabramz committed Nov 14, 2023
0 parents commit cbdfb6b
Show file tree
Hide file tree
Showing 9 changed files with 164 additions and 0 deletions.
73 changes: 73 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Docker

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

on:
schedule:
- cron: '26 3 * * 0'
push:
branches: [ main ]
# Publish semver tags as releases.
tags: [ 'v*.*.*' ]
pull_request:
branches: [ main ]

env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}


jobs:
build:

runs-on: ubuntu-latest
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

# Workaround: https://github.com/docker/build-push-action/issues/461
- name: Setup Docker buildx
uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf

# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM ros:noetic-robot
RUN apt-get update -y && \
apt-get install -y tigervnc-standalone-server openbox wget && \
rm -rf /var/lib/apt/lists
ENV VNC_DESKTOP_NAME "Xtigervnc"
ENV VNC_GEOMETRY 1280x800
ENV DISPLAY ":0"
RUN mkdir -p /exo && wget https://github.com/deref/exo/releases/download/2021.11.16/exo_standalone_2021.11.16_linux_amd64.tar.gz -O- | tar xvz && mv exo /usr/local/bin && chmod +x /usr/local/bin/exo && rm -rf /exo
COPY app/ /app/
COPY root/.config/openbox/ /root/.config/openbox/
CMD /app/main.sh
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# xtigervnc-docker

A standalone X11+VNC container for development in Docker based on [TigerVNC](https://tigervnc.org/).

TigerVNC’s [Xvnc](https://tigervnc.org/doc/Xvnc.html) provides both X11 and VNC servers in one, which [offers a better performance][whytiger] compared to running Xvfb and a VNC server separately. This lets you run GUI applications inside Docker without having to include an X server in the application image. For an example usage, see my note [Running an X11 display server and noVNC on Codespaces](https://notes.dt.in.th/CodespacesDisplayServer).

[Pre-built images are available on GitHub Packages](https://github.com/dtinth/xtigervnc-docker/pkgs/container/xtigervnc-docker), [built by GitHub Actions](https://github.com/dtinth/xtigervnc-docker/blob/main/.github/workflows/docker-publish.yml).

[whytiger]: https://www.digitalocean.com/community/tutorials/how-to-remotely-access-gui-applications-using-docker-and-caddy-on-debian-9#:~:text=For%20this%20container%2C%20you%20are%20using%20TigerVNC%20and%20its%20built%2Din%20VNC%20server.%20This%20has%20a%20number%20of%20advantages%20over%20using%20a%20separate%20X11%20and%20VNC%20server

## Ports

- `:6000` - X11 server
- `:5900` - VNC server

## Environment Variables

- `VNC_GEOMETRY` - Set to `<width>x<height>` of the desktop. Default 1280x800.
- `OPENBOX_ENABLED` - Default is `1`. Set to `0` to disable [Openbox](http://openbox.org/wiki/Main_Page) window manager. If disabled, windows will not have a title bar and will not be resizable. Do this if you plan to bring your own window manager.

## Reference

<https://www.digitalocean.com/community/tutorials/how-to-remotely-access-gui-applications-using-docker-and-caddy-on-debian-9>
2 changes: 2 additions & 0 deletions app/Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
xtigervnc: ./xtigervnc.sh
openbox: ./openbox.sh
8 changes: 8 additions & 0 deletions app/main.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash -e
OPENBOX_ENABLED=${OPENBOX_ENABLED:-1}
cd /app
if [ "$OPENBOX_ENABLED" = "1" ]; then
exo run
else
exec ./xtigervnc.sh
fi
6 changes: 6 additions & 0 deletions app/openbox.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
export DISPLAY=:0
while true; do
openbox
sleep 1
done
2 changes: 2 additions & 0 deletions app/xtigervnc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash -e
exec Xtigervnc -desktop "$VNC_DESKTOP_NAME" -geometry "$VNC_GEOMETRY" -listen tcp -ac -SecurityTypes None -AlwaysShared -AcceptKeyEvents -AcceptPointerEvents -SendCutText -AcceptCutText :0
19 changes: 19 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
services:
display:
build: .
volumes:
- ./app:/app:ro
novnc:
image: geek1011/easy-novnc
command: -a :5800 -h display --no-url-password
ports:
- 5800:5800
xeyes:
image: fr3nd/xeyes
environment:
DISPLAY: display:0
shell:
image: debian
command: sleep inf
environment:
DISPLAY: display:0
20 changes: 20 additions & 0 deletions root/.config/openbox/menu.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>

<openbox_menu xmlns="http://openbox.org/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://openbox.org/
file:///usr/share/openbox/menu.xsd">

<menu id="root-menu" label="Openbox 3">
<item label="ObConf">
<action name="Execute"><execute>obconf</execute></action>
</item>
<item label="Reconfigure">
<action name="Reconfigure" />
</item>
<item label="Restart">
<action name="Restart" />
</item>
</menu>

</openbox_menu>

0 comments on commit cbdfb6b

Please sign in to comment.