From 56464778f2568b8f96e82ce258b7fc63ccf2a80f Mon Sep 17 00:00:00 2001 From: Craig Date: Tue, 28 Jan 2020 07:07:35 +0000 Subject: [PATCH] back to debian, better firefox support --- .devcontainer/Dockerfile | 233 +++++++++++++++------------- .devcontainer/devcontainer.json | 2 +- .docker/build | 22 ++- .docker/files/dbus | 9 +- .docker/files/firefox/policies.json | 10 +- .docker/files/supervisord.conf | 2 +- .docker/supervisord.conf | 2 +- .docker/test | 34 +++- Dockerfile | 110 +++++++------ README.md | 13 +- docker-compose.yaml | 12 +- neko.code-workspace | 5 - server/internal/gst/gst.go | 7 +- 13 files changed, 251 insertions(+), 210 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index c29c0d6..4237617 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,121 +1,87 @@ FROM nurdism/neko -ARG USERNAME=neko -ARG USER_UID=1000 -ARG USER_GID=$USER_UID +RUN apt-get update && apt-get install -y --no-install-recommends autoconf ca-certificates curl netbase wget \ + bzr git mercurial openssh-client subversion procps automake bzip2 dpkg-dev file g++ gcc \ + libbz2-dev libc6-dev libcurl4-openssl-dev libdb-dev libevent-dev libffi-dev libgdbm-dev libglib2.0-dev libgmp-dev \ + libjpeg-dev libkrb5-dev liblzma-dev libmagickcore-dev libmagickwand-dev libmaxminddb-dev libncurses5-dev libncursesw5-dev \ + libpng-dev libpq-dev libreadline-dev libsqlite3-dev libssl-dev libtool libwebp-dev libxml2-dev libxslt-dev libyaml-dev \ + make patch unzip xz-utils zlib1g-dev pkg-config \ + && if ! command -v gpg > /dev/null; then \ + apt-get update; \ + apt-get install -y --no-install-recommends gnupg dirmngr; \ + fi -# Set to false to skip installing zsh and Oh My ZSH! -ARG INSTALL_ZSH="true" - -# Location and expected SHA for common setup script - SHA generated on release -ARG COMMON_SCRIPT_SOURCE="https://raw.githubusercontent.com/microsoft/vscode-dev-containers/master/script-library/common-alpine.sh" -ARG COMMON_SCRIPT_SHA="dev-mode" - -# Install git, bash, dependencies, and add a non-root user -RUN apk update \ - && apk add --no-cache wget coreutils ca-certificates \ - && apk add --no-cache wget openssl docker libxtst-dev xclip x11vnc glib-dev gobject-introspection \ - # - # Verify git, common tools / libs installed, add/modify non-root user, optionally install zsh - && wget -q -O /tmp/common-setup.sh $COMMON_SCRIPT_SOURCE \ - && if [ "$COMMON_SCRIPT_SHA" != "dev-mode" ]; then echo "$COMMON_SCRIPT_SHA /tmp/common-setup.sh" | sha256sum -c - ; fi \ - && /bin/ash /tmp/common-setup.sh "$INSTALL_ZSH" "$USERNAME" "$USER_UID" "$USER_GID" \ - && rm /tmp/common-setup.sh - -ENV NODE_VERSION 13.7.0 -RUN apk add --no-cache curl libstdc++ \ - && ARCH= && alpineArch="$(apk --print-arch)" \ - && case "${alpineArch##*-}" in \ - x86_64) \ - ARCH='x64' \ - CHECKSUM="4c153345a08d2eeb40dfbb62f1ef6ade7ec369630f9cf9f061bf9d52b10acafc" \ - ;; \ - *) ;; \ - esac \ - && if [ -n "${CHECKSUM}" ]; then \ - set -eu; \ - curl -fsSLO --compressed "https://unofficial-builds.nodejs.org/download/release/v$NODE_VERSION/node-v$NODE_VERSION-linux-$ARCH-musl.tar.xz"; \ - echo "$CHECKSUM node-v$NODE_VERSION-linux-$ARCH-musl.tar.xz" | sha256sum -c - \ - && tar -xJf "node-v$NODE_VERSION-linux-$ARCH-musl.tar.xz" -C /usr/local --strip-components=1 --no-same-owner \ - && ln -s /usr/local/bin/node /usr/local/bin/nodejs; \ - else \ - echo "Building from source" \ - # backup build - && apk add --no-cache binutils-gold g++ gcc gnupg libgcc linux-headers make python \ - # gpg keys listed at https://github.com/nodejs/node#release-keys - && for key in \ - 94AE36675C464D64BAFA68DD7434390BDBE9B9C5 \ - FD3A5288F042B6850C66B31F09FE44734EB7990E \ - 71DCFD284A79C3B38668286BC97EC7A07EDE3FC1 \ - DD8F2338BAE7501E3DD5AC78C273792F7D83545D \ - C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 \ - B9AE9905FFD7803F25714661B63B535A4C206CA9 \ - 77984A986EBC2AA786BC0F66B01FBB92821C587A \ - 8FCCA13FEF1D0C2E91008E09770F7A9A5AE15600 \ - 4ED778F539E3634C779C87C6D7062848A1AB005C \ - A48C2BEE680E841632CD4E44F07496B3EB3C1762 \ - B9E2F5981AA6E0CD28160D9FF13993A75599653C \ - ; do \ - gpg --batch --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys "$key" || \ - gpg --batch --keyserver hkp://ipv4.pool.sks-keyservers.net --recv-keys "$key" || \ - gpg --batch --keyserver hkp://pgp.mit.edu:80 --recv-keys "$key" ; \ - done \ - && curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION.tar.xz" \ - && curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/SHASUMS256.txt.asc" \ - && gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc \ - && grep " node-v$NODE_VERSION.tar.xz\$" SHASUMS256.txt | sha256sum -c - \ - && tar -xf "node-v$NODE_VERSION.tar.xz" \ - && cd "node-v$NODE_VERSION" \ - && ./configure \ - && make -j$(getconf _NPROCESSORS_ONLN) V= \ - && make install \ - && cd .. \ - && rm -Rf "node-v$NODE_VERSION" \ - && rm "node-v$NODE_VERSION.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt; \ - fi \ - && rm -f "node-v$NODE_VERSION-linux-$ARCH-musl.tar.xz" +ENV NODE_VERSION 12.14.1 +RUN ARCH= && dpkgArch="$(dpkg --print-architecture)" \ + && case "${dpkgArch##*-}" in \ + amd64) ARCH='x64';; \ + ppc64el) ARCH='ppc64le';; \ + s390x) ARCH='s390x';; \ + arm64) ARCH='arm64';; \ + armhf) ARCH='armv7l';; \ + i386) ARCH='x86';; \ + *) echo "unsupported architecture"; exit 1 ;; \ + esac \ + # gpg keys listed at https://github.com/nodejs/node#release-keys + && set -eux \ + && for key in \ + 94AE36675C464D64BAFA68DD7434390BDBE9B9C5 \ + FD3A5288F042B6850C66B31F09FE44734EB7990E \ + 71DCFD284A79C3B38668286BC97EC7A07EDE3FC1 \ + DD8F2338BAE7501E3DD5AC78C273792F7D83545D \ + C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 \ + B9AE9905FFD7803F25714661B63B535A4C206CA9 \ + 77984A986EBC2AA786BC0F66B01FBB92821C587A \ + 8FCCA13FEF1D0C2E91008E09770F7A9A5AE15600 \ + 4ED778F539E3634C779C87C6D7062848A1AB005C \ + A48C2BEE680E841632CD4E44F07496B3EB3C1762 \ + B9E2F5981AA6E0CD28160D9FF13993A75599653C \ + ; do \ + gpg --batch --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys "$key" || \ + gpg --batch --keyserver hkp://ipv4.pool.sks-keyservers.net --recv-keys "$key" || \ + gpg --batch --keyserver hkp://pgp.mit.edu:80 --recv-keys "$key" ; \ + done \ + && curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-$ARCH.tar.xz" \ + && curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/SHASUMS256.txt.asc" \ + && gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc \ + && grep " node-v$NODE_VERSION-linux-$ARCH.tar.xz\$" SHASUMS256.txt | sha256sum -c - \ + && tar -xJf "node-v$NODE_VERSION-linux-$ARCH.tar.xz" -C /usr/local --strip-components=1 --no-same-owner \ + && rm "node-v$NODE_VERSION-linux-$ARCH.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt \ + && ln -s /usr/local/bin/node /usr/local/bin/nodejs ENV GOLANG_VERSION 1.13.6 RUN set -eux \ - && apk add --no-cache bash gcc musl-dev openssl go \ - && export \ -# set GOROOT_BOOTSTRAP such that we can actually build Go - GOROOT_BOOTSTRAP="$(go env GOROOT)" \ -# ... and set "cross-building" related vars to the installed system's values so that we create a build targeting the proper arch -# (for example, if our build host is GOARCH=amd64, but our build env/image is GOARCH=386, our build needs GOARCH=386) - GOOS="$(go env GOOS)" \ - GOARCH="$(go env GOARCH)" \ - GOHOSTOS="$(go env GOHOSTOS)" \ - GOHOSTARCH="$(go env GOHOSTARCH)" \ - ; \ -# also explicitly set GO386 and GOARM if appropriate -# https://github.com/docker-library/golang/issues/184 - apkArch="$(apk --print-arch)"; \ - case "$apkArch" in \ - armhf) export GOARM='6' ;; \ - armv7) export GOARM='7' ;; \ - x86) export GO386='387' ;; \ - esac; \ - wget -O go.tgz "https://golang.org/dl/go$GOLANG_VERSION.src.tar.gz"; \ - echo 'aae5be954bdc40bcf8006eb77e8d8a5dde412722bc8effcdaf9772620d06420c *go.tgz' | sha256sum -c -; \ - tar -C /usr/local -xzf go.tgz; \ - rm go.tgz; \ - cd /usr/local/go/src; \ - ./make.bash; \ - rm -rf \ -# https://github.com/golang/go/blob/0b30cf534a03618162d3015c8705dd2231e34703/src/cmd/dist/buildtool.go#L121-L125 - /usr/local/go/pkg/bootstrap \ -# https://golang.org/cl/82095 -# https://github.com/golang/build/blob/e3fe1605c30f6a3fd136b561569933312ede8782/cmd/release/releaselet.go#L56 - /usr/local/go/pkg/obj \ - && export PATH="/usr/local/go/bin:$PATH" \ - && go version + && dpkgArch="$(dpkg --print-architecture)" \ + && case "${dpkgArch##*-}" in \ + amd64) goRelArch='linux-amd64'; goRelSha256='a1bc06deb070155c4f67c579f896a45eeda5a8fa54f35ba233304074c4abbbbd' ;; \ + armhf) goRelArch='linux-armv6l'; goRelSha256='37a1a83e363dcf146a67fa839d170fd1afb13009585fdd493d0a3370fbe6f785' ;; \ + arm64) goRelArch='linux-arm64'; goRelSha256='0a18125c4ed80f9c3045cf92384670907c4796b43ed63c4307210fe93e5bbca5' ;; \ + i386) goRelArch='linux-386'; goRelSha256='27feb013106da784f09e560720aa41ab395c67f7eed4c4a0fce04bc6e3d01c7d' ;; \ + ppc64el) goRelArch='linux-ppc64le'; goRelSha256='26a977a8af5dc50a562f0a57b58dded5fa3bacfe77722cf8a84ea54ca54728dd' ;; \ + s390x) goRelArch='linux-s390x'; goRelSha256='5cd9900a1fa0f0cac657930b648381cad9b8c5e2bbc77caf86a6fb5cedad0017' ;; \ + *) goRelArch='src'; goRelSha256='aae5be954bdc40bcf8006eb77e8d8a5dde412722bc8effcdaf9772620d06420c'; \ + echo >&2; echo >&2 "warning: current architecture ($dpkgArch) does not have a corresponding Go binary release; will be building from source"; echo >&2 ;; \ + esac \ + && url="https://golang.org/dl/go${GOLANG_VERSION}.${goRelArch}.tar.gz" \ + && wget -O go.tgz "$url" \ + && echo "${goRelSha256} *go.tgz" | sha256sum -c - \ + && tar -C /usr/local -xzf go.tgz \ + && rm go.tgz \ + && if [ "$goRelArch" = 'src' ]; then \ + echo >&2; \ + echo >&2 'error: UNIMPLEMENTED'; \ + echo >&2 'TODO install golang-any from jessie-backports for GOROOT_BOOTSTRAP (and uninstall after build)'; \ + echo >&2; \ + exit 1; \ + fi \ + && export PATH="/usr/local/go/bin:$PATH" \ + && go version ENV GOPATH /go ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH # -# Install Go tools w/module support +# install Go tools w/module support RUN mkdir -p /tmp/gotools \ && cd /tmp/gotools \ && GO111MODULE=on go get -v golang.org/x/tools/gopls@latest 2>&1 \ @@ -141,17 +107,62 @@ RUN mkdir -p /tmp/gotools \ github.com/mgechev/revive@latest \ github.com/go-delve/delve/cmd/dlv@latest 2>&1 \ # - # Install Go tools w/o module support + # install Go tools w/o module support && go get -v github.com/alecthomas/gometalinter 2>&1 \ # - # Install gocode-gomod + # install gocode-gomod && go get -x -d github.com/stamblerre/gocode 2>&1 \ && go build -o gocode-gomod github.com/stamblerre/gocode \ && mv gocode-gomod $GOPATH/bin/ \ # - # Install golangci-lint + # install golangci-lint && curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin 2>&1 RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" "$GOPATH/pkg/mod" && chmod -R 777 "$GOPATH" -ENV GO111MODULE=on \ No newline at end of file +# turn on go modules +ENV GO111MODULE=on + +# the node image includes a non-root user with sudo access. Use the "remoteUser" +# property in devcontainer.json to use it. On Linux, the container user's GID/UIDs +# will be updated to match your local UID/GID (when using the dockerFile property). +# See https://aka.ms/vscode-remote/containers/non-root-user for details. +ARG USERNAME=neko +ARG USER_UID=1000 +ARG USER_GID=$USER_UID + +# set to false to skip installing zsh and Oh My ZSH! +ARG INSTALL_ZSH="true" + +# location and expected SHA for common setup script - SHA generated on release +ARG COMMON_SCRIPT_SOURCE="https://raw.githubusercontent.com/microsoft/vscode-dev-containers/master/script-library/common-debian.sh" +ARG COMMON_SCRIPT_SHA="dev-mode" + +# configure apt and install packages +RUN apt-get update \ + && apt-get -y install --no-install-recommends apt-utils x11vnc libxtst-dev openssl dialog wget ca-certificates 2>&1 \ + # + # verify git, common tools / libs installed, add/modify non-root user, optionally install zsh + && wget -q -O /tmp/common-setup.sh $COMMON_SCRIPT_SOURCE \ + && if [ "$COMMON_SCRIPT_SHA" != "dev-mode" ]; then echo "$COMMON_SCRIPT_SHA /tmp/common-setup.sh" | sha256sum -c - ; fi \ + && /bin/bash /tmp/common-setup.sh "$INSTALL_ZSH" "$USERNAME" "$USER_UID" "$USER_GID" \ + && rm /tmp/common-setup.sh \ + # + # install docker + && apt-get install -y apt-transport-https gnupg-agent software-properties-common lsb-release \ + && curl -fsSL https://download.docker.com/linux/$(lsb_release -is | tr '[:upper:]' '[:lower:]')/gpg | (OUT=$(apt-key add - 2>&1) || echo $OUT) \ + && add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/$(lsb_release -is | tr '[:upper:]' '[:lower:]') $(lsb_release -cs) stable" \ + && apt-get update && apt-get install -y docker-ce-cli \ + # + # install docker compose + && curl -sSL "https://github.com/docker/compose/releases/download/${COMPOSE_VERSION}/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose \ + && chmod +x /usr/local/bin/docker-compose \ + # + # set alternate global install location that both users have rights to access + && mkdir -p /usr/local/share/npm-global \ + && chown ${USERNAME}:root /usr/local/share/npm-global \ + && npm config -g set prefix /usr/local/share/npm-global \ + && sudo -u ${USERNAME} npm config -g set prefix /usr/local/share/npm-global + +# switch back to dialog for any ad-hoc use of apt-get +ENV DEBIAN_FRONTEND=dialog \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 7e3e50e..4662b7b 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -5,7 +5,7 @@ "workspaceFolder": "/workspace", "remoteUser": "neko", "settings": { - "terminal.integrated.shell.linux": "/bin/ash", + "terminal.integrated.shell.linux": "/bin/bash", "go.gopath": "/go" }, "extensions": [ diff --git a/.docker/build b/.docker/build index 24de051..24de556 100755 --- a/.docker/build +++ b/.docker/build @@ -1,17 +1,15 @@ #!/bin/bash -cd ../server -go get && ./build - -cd ../client -npm install && npm run build - -cd ../ -sudo docker build -f Dockerfile -t nurdism/neko . +cd ../server \ + && go get \ + && ./build \ + && cd ../client \ + && npm install && npm run build \ + && cd ../ \ + && sudo docker build -f Dockerfile -t nurdism/neko . \ + && sudo docker images nurdism/neko +# sudo docker images nurdism/neko # sudo docker push nurdism/neko:latest -# sudo docker run -e NEKO_BIND='0.0.0.0:9000' --network host --shm-size=1gb nurdism/neko:latest -# sudo docker run -p 9000:8080 -p 59000-59100:59000-59100/udp --shm-size=2gb nurdism/neko:latest -# sudo docker run -p 8080:8080 --shm-size=1gb nurdism/neko:latest -# sudo docker run --network host --shm-size=1gb nurdism/neko:latest +# sudo docker run -p 80:8080 -p 59000-59100:59000-59100/udp --shm-size=1gb nurdism/neko:latest # sudo docker run --network host --shm-size=1gb -it nurdism/neko:latest /bin/bash \ No newline at end of file diff --git a/.docker/files/dbus b/.docker/files/dbus index 38c8474..a09c1cf 100755 --- a/.docker/files/dbus +++ b/.docker/files/dbus @@ -1,4 +1,11 @@ #!/bin/sh -rm -rf /var/run/dbus.pid +if [ ! -d /var/run/dbus ]; then + mkdir -p /var/run/dbus +fi + +if [ -f /var/run/dbus.pid ]; then + rm -f /var/run/dbus.pid +fi + /usr/bin/dbus-daemon --nofork --print-pid --config-file=/usr/share/dbus-1/system.conf \ No newline at end of file diff --git a/.docker/files/firefox/policies.json b/.docker/files/firefox/policies.json index dd42fa6..d75ba66 100644 --- a/.docker/files/firefox/policies.json +++ b/.docker/files/firefox/policies.json @@ -1,6 +1,6 @@ { "policies": { - "BlockAboutAddons": true, + "BlockAboutAddons": false, "BlockAboutConfig": true, "BlockAboutProfiles": true, "BlockAboutSupport": true, @@ -28,7 +28,7 @@ }, { "Title": "9Anime", - "URL": "https://9anime.xyz/", + "URL": "https://9anime.to/", "Favicon": "https://staticf.akacdn.ru/assets/favicons/favicon.png", "Folder": "Media", "Placement": "toolbar" @@ -93,7 +93,7 @@ "CaptivePortal": false, "DisableAppUpdate": true, "DisableBuiltinPDFViewer": true, - "DisableDeveloperTools": true, + "DisableDeveloperTools": false, "DisableFeedbackCommands": true, "DisableFirefoxAccounts": true, "DisableFirefoxScreenshots": true, @@ -119,6 +119,10 @@ "*": { "installation_mode": "blocked" }, + "nordvpnproxy@nordvpn.com": { + "install_url": "https://addons.mozilla.org/firefox/downloads/latest/nordvpn-proxy-extension/latest.xpi", + "installation_mode": "force_installed" + }, "uBlock0@raymondhill.net": { "install_url": "https://addons.mozilla.org/firefox/downloads/latest/ublock-origin/latest.xpi", "installation_mode": "force_installed" diff --git a/.docker/files/supervisord.conf b/.docker/files/supervisord.conf index 9ad1c84..548afad 100644 --- a/.docker/files/supervisord.conf +++ b/.docker/files/supervisord.conf @@ -36,7 +36,7 @@ user=%(ENV_USER)s [program:firefox-esr] environment=HOME="/home/%(ENV_USER)s",USER="%(ENV_USER)s" -command=/usr/lib/firefox/firefox --display=%(ENV_DISPLAY)s --setDefaultBrowser -width %(ENV_SCREEN_WIDTH)s -height %(ENV_SCREEN_HEIGHT)s +command=/usr/lib/firefox-esr/firefox-esr --display=%(ENV_DISPLAY)s --setDefaultBrowser -width %(ENV_SCREEN_WIDTH)s -height %(ENV_SCREEN_HEIGHT)s autorestart=true priority=400 user=%(ENV_USER)s diff --git a/.docker/supervisord.conf b/.docker/supervisord.conf index d1c4435..1444ced 100644 --- a/.docker/supervisord.conf +++ b/.docker/supervisord.conf @@ -36,7 +36,7 @@ user=%(ENV_USER)s [program:firefox-esr] environment=HOME="/home/%(ENV_USER)s",USER="%(ENV_USER)s" -command=/usr/lib/firefox/firefox --display=%(ENV_DISPLAY)s --setDefaultBrowser -width %(ENV_SCREEN_WIDTH)s -height %(ENV_SCREEN_HEIGHT)s +command=/usr/lib/firefox-esr/firefox-esr --display=%(ENV_DISPLAY)s --setDefaultBrowser -width %(ENV_SCREEN_WIDTH)s -height %(ENV_SCREEN_HEIGHT)s autorestart=true priority=400 user=%(ENV_USER)s \ No newline at end of file diff --git a/.docker/test b/.docker/test index 828965d..eac2f52 100755 --- a/.docker/test +++ b/.docker/test @@ -2,6 +2,11 @@ # usefull debugging tools pavucontrol htop x11vnc +if [[ $EUID -ne 0 ]]; then + echo "This script must be run as root" + exit 1 +fi + # if [ ! -f ../server/bin/neko ]; then # echo "build server before testing" # exit 1 @@ -15,30 +20,39 @@ sudo mkdir -p /var/run/dbus /etc/neko sudo rm -rf /var/run/dbus.pid -sudo cp files/firefox/neko.js /usr/lib/firefox/mozilla.cfg -sudo cp files/firefox/autoconfig.js /usr/lib/firefox/defaults/pref/autoconfig.js -sudo cp files/firefox/policies.json /usr/lib/firefox/distribution/policies.json +sudo cp files/firefox-esr/neko.js /usr/lib/firefox-esr/mozilla.cfg +#sudo rm -f /usr/lib/firefox-esr/mozilla.cfg + +sudo cp files/firefox-esr/autoconfig.js /usr/lib/firefox-esr/defaults/pref/autoconfig.js +#sudo rm -f /usr/lib/firefox-esr/defaults/pref/autoconfig.js + +sudo cp files/firefox-esr/policies.json /usr/lib/firefox-esr/distribution/policies.json +#sudo rm -f /usr/lib/firefox-esr/distribution/policies.json sudo cp files/dbus /usr/bin/dbus sudo cp files/default.pa /etc/pulse/default.pa sudo cp files/supervisord.conf /etc/neko/supervisord.conf sudo cp files/openbox.xml /etc/neko/openbox.xml +sudo mkdir -p /usr/lib/firefox/distribution/extensions + if [ ! -f /usr/lib/firefox/distribution/extensions/uBlock0@raymondhill.net.xpi ]; then - sudo mkdir -p /usr/lib/firefox/distribution/extensions sudo curl -o /usr/lib/firefox/distribution/extensions/uBlock0@raymondhill.net.xpi https://addons.mozilla.org/firefox/downloads/latest/ublock-origin/addon-607454-latest.xpi fi +if [ ! -f /usr/lib/firefox/distribution/extensions/nordvpnproxy@nordvpn.com.xpi ]; then + sudo curl -o /usr/lib/firefox/distribution/extensions/nordvpnproxy@nordvpn.com.xpi https://addons.mozilla.org/firefox/downloads/latest/nordvpn-proxy-extension/latest.xpi +fi + sudo cp ../server/bin/neko /usr/bin/neko sudo cp -R ../client/dist /var/www/ sudo rm -rf $HOME/.mozilla -sudo rm -rf /var/run/supervisord.pid mkdir -p $HOME/.config/pulse echo "default-server=unix:/tmp/pulseaudio.socket" > $HOME/.config/pulse/client.conf -export USER=vscode +export USER=neko export SCREEN_WIDTH=1280 export SCREEN_HEIGHT=720 export SCREEN_DEPTH=24 @@ -49,4 +63,12 @@ export NEKO_BIND=:8080 export NEKO_KEY= export NEKO_CERT= +if [ -f /var/run/supervisord.pid ]; then + sudo rm -f /var/run/supervisord.pid +fi + +if [ -f supervisord.log ]; then + sudo rm -f supervisord.log +fi + supervisord --configuration ./supervisord.conf \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 2ca8d05..f35f4a4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,79 +1,70 @@ -FROM frolvlad/alpine-glibc +FROM debian:stretch-slim -ENV GST_VERSION=1.16.2 +# avoid warnings by switching to noninteractive +ENV DEBIAN_FRONTEND=noninteractive + +ENV GSTPATH /gst +ENV GST_VERSION 1.16 # build gstreamer -RUN apk add --no-cache --virtual .gst-build-deps \ - build-base bison flex perl python glib-dev zlib-dev \ - opus-dev \ - pulseaudio-dev libx11-dev libxv-dev libxt-dev libxfixes-dev libvpx-dev \ - git nasm openssl-dev \ - # - # build gstreamer - && cd /tmp \ - && wget "https://gstreamer.freedesktop.org/src/gstreamer/gstreamer-$GST_VERSION.tar.xz" \ - && tar xvfJ "gstreamer-$GST_VERSION.tar.xz" > /dev/null \ - && cd "gstreamer-$GST_VERSION" \ - && ./configure --prefix=/usr \ - && make && make install \ - && cd /tmp && rm -rf "gstreamer-$GST_VERSION" \ - # - # build gst-plugins-base - && wget "https://gstreamer.freedesktop.org/src/gst-plugins-base/gst-plugins-base-$GST_VERSION.tar.xz" \ - && tar xvfJ "gst-plugins-base-$GST_VERSION.tar.xz" > /dev/null \ - && cd "gst-plugins-base-$GST_VERSION" \ - && ./configure --prefix=/usr \ - && make && make install \ - && cd /tmp && rm -rf "gst-plugins-base-$GST_VERSION" \ - # - # build gst-plugins-good - && wget "https://gstreamer.freedesktop.org/src/gst-plugins-good/gst-plugins-good-$GST_VERSION.tar.xz" \ - && tar xvfJ "gst-plugins-good-$GST_VERSION.tar.xz" > /dev/null \ - && cd "gst-plugins-good-$GST_VERSION" \ - && ./configure --prefix=/usr \ - && make && make install \ - && cd /tmp && rm -rf "gst-plugins-good-$GST_VERSION" \ +RUN set -eux && \ + apt-get update && apt-get install -y --no-install-recommends \ + git ca-certificates build-essential perl python pkg-config autoconf automake autopoint libtool bison flex \ + gettext nasm openssl libglib2.0-dev libopus-dev libvpx-dev libpulse-dev libx11-dev libxv-dev libxt-dev \ + libxtst-dev libxfixes-dev libssl-dev \ + ## set up dir + && mkdir $GSTPATH \ # # build openh264 + && cd $GSTPATH \ && git clone https://github.com/cisco/openh264.git \ && cd openh264 \ && make && make install \ - && cd /tmp && rm -rf openh264 \ + && cd $GSTPATH && rm -rf openh264 \ # - # build gst-plugins-bad - && wget "https://gstreamer.freedesktop.org/src/gst-plugins-bad/gst-plugins-bad-$GST_VERSION.tar.xz" \ - && tar xvfJ "gst-plugins-bad-$GST_VERSION.tar.xz" > /dev/null \ - && cd "gst-plugins-bad-$GST_VERSION" \ - && ./configure --prefix=/usr \ - && make && make install \ - && cd /tmp && rm -rf "gst-plugins-bad-$GST_VERSION" \ + # build gstreamer + && for MODULE in \ + gstreamer \ + gst-plugins-base \ + gst-plugins-good \ + gst-plugins-bad \ + ; do \ + git clone git://anongit.freedesktop.org/gstreamer/$MODULE; \ + cd $MODULE; \ + git checkout $GST_VERSION; \ + PATH=$GSTPATH/local/bin:$PATH PKG_CONFIG_PATH=$GSTPATH/local/lib/pkgconfig ./autogen.sh --prefix $GSTPATH/local --disable-gtk-doc; \ + make && make install; \ + cd $GSTPATH && rm -rf $MODULE; \ + done \ # # remove build deps - && apk del .gst-build-deps + && apt-get --purge autoremove -y build-essential perl python pkg-config autoconf automake autopoint libtool bison flex \ + gettext nasm openssl libglib2.0-dev libopus-dev libvpx-dev libpulse-dev libx11-dev libxv-dev libxt-dev \ + libxtst-dev libxfixes-dev libssl-dev + +ENV PATH=$GSTPATH/local/bin:$PATH +ENV LD_LIBRARY_PATH=$GSTPATH/local/lib:$LD_LIBRARY_PATH +ENV PKG_CONFIG_PATH=$GSTPATH/local/lib/pkgconfig:$PKG_CONFIG_PATH ARG USERNAME=neko ARG USER_UID=1000 ARG USER_GID=$USER_UID -# RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories -# RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories -# RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories - # install neko dependencies -RUN apk add --no-cache supervisor openbox dbus-x11 xvfb pulseaudio alsa-plugins-pulse opus libvpx libxv libxtst libxfixes xclip ttf-freefont \ - && apk add --no-cache libevent --repository "http://dl-cdn.alpinelinux.org/alpine/edge/main" \ - && apk add --no-cache firefox-esr --repository "http://dl-cdn.alpinelinux.org/alpine/edge/community" \ +RUN set -eux \ + && apt-get update && apt-get install -y --no-install-recommends wget ca-certificates pulseaudio openbox dbus-x11 xvfb libxv1 xclip firefox-esr supervisor \ # # create a non-root user - && addgroup -g $USER_GID $USERNAME \ - && adduser -D -u $USER_UID -G $USERNAME -s /bin/ash -h /home/$USERNAME $USERNAME \ + && groupadd --gid $USER_GID $USERNAME \ + && useradd --uid $USER_UID --gid $USERNAME --shell /bin/bash --create-home $USERNAME \ && adduser $USERNAME audio \ && adduser $USERNAME video \ && adduser $USERNAME pulse \ # - # install uBlock - && mkdir -p /usr/lib/firefox/distribution/extensions \ - && wget -O /usr/lib/firefox/distribution/extensions/uBlock0@raymondhill.net.xpi https://addons.mozilla.org/firefox/downloads/latest/ublock-origin/addon-607454-latest.xpi \ + # install extensions + && mkdir -p /usr/lib/firefox-esr/distribution/extensions \ + && wget -O /usr/lib/firefox-esr/distribution/extensions/uBlock0@raymondhill.net.xpi https://addons.mozilla.org/firefox/downloads/latest/ublock-origin/latest.xpi \ + && wget -O /usr/lib/firefox-esr/distribution/extensions/nordvpnproxy@nordvpn.com.xpi https://addons.mozilla.org/firefox/downloads/latest/nordvpn-proxy-extension/latest.xpi \ # # setup pulseaudio && mkdir -p /home/$USERNAME/.config/pulse/ \ @@ -84,7 +75,12 @@ RUN apk add --no-cache supervisor openbox dbus-x11 xvfb pulseaudio alsa-plugins- && mkdir /tmp/.X11-unix && chmod 1777 /tmp/.X11-unix && chown $USERNAME /tmp/.X11-unix/ \ # # make directories for neko - && mkdir -p /etc/neko /var/www + && mkdir -p /etc/neko /var/www \ + # + # clean up + && apt-get autoremove -y \ + && apt-get clean -y \ + && rm -rf /var/lib/apt/lists/* /var/cache/apt/* # # env @@ -100,9 +96,9 @@ COPY .docker/files/dbus /usr/bin/dbus COPY .docker/files/openbox.xml /etc/neko/openbox.xml COPY .docker/files/supervisord.conf /etc/neko/supervisord.conf COPY .docker/files/default.pa /etc/pulse/default.pa -COPY .docker/files/firefox/neko.js /usr/lib/firefox/mozilla.cfg -COPY .docker/files/firefox/autoconfig.js /usr/lib/firefox/defaults/pref/autoconfig.js -COPY .docker/files/firefox/policies.json /usr/lib/firefox/distribution/policies.json +COPY .docker/files/firefox/neko.js /usr/lib/firefox-esr/mozilla.cfg +COPY .docker/files/firefox/autoconfig.js /usr/lib/firefox-esr/defaults/pref/autoconfig.js +COPY .docker/files/firefox/policies.json /usr/lib/firefox-esr/distribution/policies.json # # neko files diff --git a/README.md b/README.md index 7616243..322758a 100644 --- a/README.md +++ b/README.md @@ -49,15 +49,16 @@ sudo docker run -p 8080:8080 -e NEKO_PASSWORD='secret' -e NEKO_ADMIN='secret' -- ### Config ``` -NEKO_USER=$USERNAME // User -NEKO_DISPLAY=0 // Display number -NEKO_WIDTH=1280 // Display width -NEKO_HEIGHT=720 // Display height +SCREEN_WIDTH=1280 // Display width +SCREEN_HEIGHT=720 // Display height +SCREEN_DEPTH=24 // Display bit depth +DISPLAY=:99.0 // Display number + NEKO_PASSWORD=neko // Password NEKO_ADMIN=neko // Admin Password NEKO_BIND=0.0.0.0:8080 // Bind -NEKO_KEY= // (SSL)Key -NEKO_CERT= // (SSL)Cert +NEKO_KEY= // (SSL)Key, needed for clipboard sync +NEKO_CERT= // (SSL)Cert, needed for clipboard sync ``` ### Development diff --git a/docker-compose.yaml b/docker-compose.yaml index a201e67..c0b6b27 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,14 +1,16 @@ -version: '2.0' +version: "2.0" services: neko: image: nurdism/neko restart: always - shm_size: '2gb' + shm_size: "1gb" ports: - "80:8080" environment: - NEKO_DISPLAY: 0 - NEKO_WIDTH: 1280 - NEKO_HEIGHT: 720 + DISPLAY: :99.0 + SCREEN_WIDTH: 1280 + SCREEN_HEIGHT: 720 + SCREEN_DEPTH: 24 NEKO_PASSWORD: neko + NEKO_ADMIN: admin NEKO_BIND: :8080 \ No newline at end of file diff --git a/neko.code-workspace b/neko.code-workspace index 0725dd1..5e0bf37 100644 --- a/neko.code-workspace +++ b/neko.code-workspace @@ -43,10 +43,5 @@ "swyphcosmo.spellchecker", "eamodio.gitlens" ], - "files.associations": { - "iostream": "cpp", - "xtest.h": "c", - "xlib.h": "c" - } } } \ No newline at end of file diff --git a/server/internal/gst/gst.go b/server/internal/gst/gst.go index a0490d1..76cdb0c 100644 --- a/server/internal/gst/gst.go +++ b/server/internal/gst/gst.go @@ -30,7 +30,12 @@ import ( gstreamer1.0-tools \ gstreamer1.0-x \ gstreamer1.0-alsa \ - gstreamer1.0-pulseaudio + gstreamer1.0-pulseaudio + + gst-inspect-1.0 --version + gst-inspect-1.0 plugin + gst-launch-1.0 ximagesrc show-pointer=true use-damage=false ! video/x-raw,framerate=30/1 ! videoconvert ! queue ! vp8enc error-resilient=partitions keyframe-max-dist=10 auto-alt-ref=true cpu-used=5 deadline=1 ! autovideosink + gst-launch-1.0 pulsesrc ! audioconvert ! opusenc ! autoaudiosink */ // Pipeline is a wrapper for a GStreamer Pipeline