diff --git a/.github/demo-img.png b/.github/demo-img.png new file mode 100644 index 0000000..112b453 Binary files /dev/null and b/.github/demo-img.png differ diff --git a/.github/workflows/github-build.yml b/.github/workflows/github-build.yml new file mode 100644 index 0000000..e905bb0 --- /dev/null +++ b/.github/workflows/github-build.yml @@ -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 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c6ef218 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.idea + diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..69bc2d9 --- /dev/null +++ b/Dockerfile @@ -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/easy-novnc@v1.1.0 && \ + 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"] diff --git a/LICENSE b/LICENSE index 9b657c6..798beee 100644 --- a/LICENSE +++ b/LICENSE @@ -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. diff --git a/README.md b/README.md index 980cb6d..89f5375 100644 --- a/README.md +++ b/README.md @@ -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 ``` diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..67a7b7a --- /dev/null +++ b/build.sh @@ -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 diff --git a/menu.xml b/menu.xml new file mode 100644 index 0000000..118c06c --- /dev/null +++ b/menu.xml @@ -0,0 +1,20 @@ + + + + + + /usr/bin/OSCAR + + + + + /usr/bin/x-terminal-emulator + + + + + /usr/bin/x-terminal-emulator -e htop + + + + diff --git a/supervisord.conf b/supervisord.conf new file mode 100644 index 0000000..16269cc --- /dev/null +++ b/supervisord.conf @@ -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