Skip to content

Commit

Permalink
Docker OSCAR initial code
Browse files Browse the repository at this point in the history
  • Loading branch information
rogerrum committed Nov 3, 2022
1 parent 75684f8 commit cb26c73
Show file tree
Hide file tree
Showing 9 changed files with 225 additions and 2 deletions.
Binary file added .github/demo-img.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 37 additions & 0 deletions .github/workflows/github-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Release

on:
release:
types: [created]

jobs:
buildx:
# strategy:
# fail-fast: false
# 1 job at a time since cron depends on latest
# max-parallel: 1
# matrix:
# tag:
# - latest
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@main
with:
ref: ${{ github.ref }}

- name: Set Docker Tag
run: echo "TAG=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV

- name: Docker login
uses: azure/docker-login@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build docker container
env:
DOCKER_CLI_EXPERIMENTAL: enabled
run: |
curl -fsSL https://raw.githubusercontent.com/pschmitt/ci-setup-docker-buildx/master/setup.sh | bash
./build.sh ${{ matrix.tag }} -p
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.idea

37 changes: 37 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
FROM golang:1.14-buster AS easy-novnc-build
WORKDIR /src
RUN go mod init build && \
go get github.com/geek1011/[email protected] && \
go build -o /bin/easy-novnc github.com/geek1011/easy-novnc

FROM debian:buster

RUN apt-get update -y && \
apt-get install -y --no-install-recommends openbox tigervnc-standalone-server supervisor gosu && \
rm -rf /var/lib/apt/lists && \
mkdir -p /usr/share/desktop-directories

RUN apt-get update -y && \
apt-get install -y --no-install-recommends lxterminal nano wget openssh-client rsync ca-certificates xdg-utils htop tar xzip gzip bzip2 zip unzip && \
rm -rf /var/lib/apt/lists



RUN apt-get update -y && \
wget -q -O /tmp/oscar.deb https://www.apneaboard.com/OSCAR/oscar_1.4.0-Debian10_amd64.deb && \
apt install -y /tmp/oscar.deb && \
rm /tmp/oscar.deb && \
rm -rf /var/lib/apt/lists

COPY --from=easy-novnc-build /bin/easy-novnc /usr/local/bin/
COPY menu.xml /etc/xdg/openbox/
COPY supervisord.conf /etc/
EXPOSE 8080

RUN groupadd --gid 1000 app && \
useradd --home-dir /data --shell /bin/bash --uid 1000 --gid 1000 app && \
mkdir -p /data

#VOLUME /data

CMD ["sh", "-c", "chown app:app /data /dev/stdout && exec gosu app supervisord"]
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:

oscar-docker Copyright (C) 2022 Roger Rumao
docker-oscar Copyright (C) 2022 Roger Rumao
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ To stop the container simply run:
```
$ docker stop oscar
```
To remove the conainer simply run:
To remove the container simply run:
```
$ docker rm oscar
```
Expand Down
88 changes: 88 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#!/usr/bin/env bash

usage() {
echo "Usage: $0 [cron]"
}

array_join() {
local IFS="$1"
shift
echo "$*"
}

get_available_architectures() {
local image="$1"
local tag="${2:-latest}"

docker buildx imagetools inspect --raw "${image}:${tag}" | \
jq -r '.manifests[].platform | .os + "/" + .architecture + "/" + .variant' | \
sed 's#/$##' | sort
}

if [[ "${BASH_SOURCE[0]}" == "${0}" ]]
then
set -ex

cd "$(readlink -f "$(dirname "$0")")" || exit 9

# Defaults
DOCKERFILE="${DOCKERFILE:-Dockerfile}"
IMAGE_NAME="${IMAGE_NAME:-rogerrum/docker-oscar}"
TAG="${TAG:-latest}"

case "$1" in
latest)
DOCKERFILE=Dockerfile
TAG=latest
shift
;;
help|h|--help|-h)
usage
exit 0
;;
esac

EXTRA_BUILD_ARGS=()

case "$1" in
push|p|--push|-p)
EXTRA_BUILD_ARGS+=("--push")
;;
*)
EXTRA_BUILD_ARGS+=("--load")
;;
esac

# read -r base_image base_tag <<< \
# "$(sed -nr 's/^FROM\s+([^:]+):?((\w+).*)\s*$/\1 \3/p' "$DOCKERFILE" | head -1)"
# shellcheck disable=2207
# platforms=($(get_available_architectures "$base_image" "$base_tag"))
platforms=(
linux/amd64
# linux/arm/v6
# linux/arm/v7
# linux/arm64/v8
)

BUILD_TYPE=manual

if [[ "$TRAVIS" == "true" ]]
then
BUILD_TYPE=travis
EXTRA_BUILD_ARGS+=("--no-cache")
elif [[ "$GITHUB_ACTIONS" == "true" ]]
then
BUILD_TYPE=github
EXTRA_BUILD_ARGS+=("--no-cache")
fi

docker buildx build \
--file "$DOCKERFILE" \
--platform "$(array_join "," "${platforms[@]}")" \
--label=built-by=rogerrum \
--label=build-type="$BUILD_TYPE" \
--label=built-on="$HOSTNAME" \
--tag "${IMAGE_NAME}:${TAG}" \
"${EXTRA_BUILD_ARGS[@]}" \
.
fi
20 changes: 20 additions & 0 deletions 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="OSCAR">
<action name="Execute">
<execute>/usr/bin/OSCAR</execute>
</action>
</item>
<item label="Terminal">
<action name="Execute">
<execute>/usr/bin/x-terminal-emulator</execute>
</action>
</item>
<item label="Htop">
<action name="Execute">
<execute>/usr/bin/x-terminal-emulator -e htop</execute>
</action>
</item>
</menu>
</openbox_menu>
39 changes: 39 additions & 0 deletions supervisord.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[supervisord]
nodaemon=true
pidfile=/tmp/supervisord.pid
logfile=/dev/fd/1
logfile_maxbytes=0

[program:x11]
priority=0
command=/usr/bin/Xtigervnc -desktop "OSCAR" -localhost -rfbport 5900 -SecurityTypes None -AlwaysShared -AcceptKeyEvents -AcceptPointerEvents -AcceptSetDesktopSize -SendCutText -AcceptCutText :0
autorestart=true
stdout_logfile=/dev/fd/1
stdout_logfile_maxbytes=0
redirect_stderr=true

[program:easy-novnc]
priority=0
command=/usr/local/bin/easy-novnc --addr :8080 --host localhost --port 5900 --no-url-password --novnc-params "resize=remote"
autorestart=true
stdout_logfile=/dev/fd/1
stdout_logfile_maxbytes=0
redirect_stderr=true

[program:openbox]
priority=1
command=/usr/bin/openbox
environment=DISPLAY=:0
autorestart=true
stdout_logfile=/dev/fd/1
stdout_logfile_maxbytes=0
redirect_stderr=true

[program:app]
priority=1
environment=DISPLAY=:0
command=/usr/bin/OSCAR
autorestart=true
stdout_logfile=/dev/fd/1
stdout_logfile_maxbytes=0
redirect_stderr=true

0 comments on commit cb26c73

Please sign in to comment.