From 0e9fbf7ba22606eb803945163e5e79990264be15 Mon Sep 17 00:00:00 2001 From: Craig Date: Mon, 27 Jan 2020 01:28:39 +0000 Subject: [PATCH] alpine --- .devcontainer/Dockerfile | 256 ++++++++++++---------- .devcontainer/devcontainer.json | 4 +- .devcontainer/docker-compose.yaml | 7 +- .docker/entrypoint.sh | 6 - .docker/files/dbus | 4 + .docker/{ => files}/default.pa | 0 .docker/{ => files}/firefox/autoconfig.js | 0 .docker/{ => files}/firefox/neko.js | 0 .docker/{ => files}/firefox/policies.json | 2 +- .docker/{ => files}/openbox.xml | 2 +- .docker/files/supervisord.conf | 49 +++++ .docker/supervisord.conf | 33 ++- .docker/supervisord.dev.conf | 27 --- .docker/test | 36 +-- Dockerfile | 141 +++++++----- server/.env.development | 4 +- server/internal/gst/gst.go | 1 + 17 files changed, 335 insertions(+), 237 deletions(-) delete mode 100755 .docker/entrypoint.sh create mode 100755 .docker/files/dbus rename .docker/{ => files}/default.pa (100%) rename .docker/{ => files}/firefox/autoconfig.js (100%) rename .docker/{ => files}/firefox/neko.js (100%) rename .docker/{ => files}/firefox/policies.json (99%) rename .docker/{ => files}/openbox.xml (99%) create mode 100644 .docker/files/supervisord.conf delete mode 100644 .docker/supervisord.dev.conf diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 463bdd14..c29c0d61 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,129 +1,157 @@ -FROM golang:stretch +FROM nurdism/neko -# This Dockerfile adds 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=vscode +ARG USERNAME=neko ARG USER_UID=1000 ARG USER_GID=$USER_UID -# Avoid warnings by switching to noninteractive -ENV DEBIAN_FRONTEND=noninteractive +# Set to false to skip installing zsh and Oh My ZSH! +ARG INSTALL_ZSH="true" -# Runtime for testing and compileing -RUN apt-get update \ - && apt-get -y install supervisor openbox dbus-x11 ttf-freefont xvfb pulseaudio consolekit firefox-esr x11vnc \ - && apt-get -y install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev gstreamer1.0-plugins-good gstreamer1.0-pulseaudio \ - && apt-get -y install gcc libc6-dev \ - && apt-get -y install libx11-dev xorg-dev libxtst-dev libpng++-dev \ - && apt-get -y install xcb libxcb-xkb-dev x11-xkb-utils libx11-xcb-dev libxkbcommon-x11-dev \ - && apt-get -y install libxkbcommon-dev \ - && apt-get -y install xsel xclip +# 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" -# Configure apt, install packages and tools -RUN apt-get update \ - && apt-get -y install --no-install-recommends apt-utils apt-transport-https dialog 2>&1 \ - # - # Verify git, process tools, lsb-release (common in install instructions for CLIs) installed - && apt-get -y install git iproute2 procps lsb-release xz-utils \ - # - # Install Docker CE CLI - && apt-get install -y apt-transport-https ca-certificates curl 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 \ - # - # Create a non-root user to use if preferred - see https://aka.ms/vscode-remote/containers/non-root-user. - && 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 \ - # Add sudo support for the non-root user - && apt-get install -y sudo \ - && echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \ - && chmod 0440 /etc/sudoers.d/$USERNAME +# 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 12.14.1 +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" -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 -ex \ - && 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 -USER $USERNAME +ENV GOPATH /go +ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH -# Install packages and tools -RUN go get -x -d github.com/stamblerre/gocode 2>&1 \ +# +# 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 \ + && GO111MODULE=on go get -v \ + honnef.co/go/tools/...@latest \ + golang.org/x/tools/cmd/gorename@latest \ + golang.org/x/tools/cmd/goimports@latest \ + golang.org/x/tools/cmd/guru@latest \ + golang.org/x/lint/golint@latest \ + github.com/mdempsky/gocode@latest \ + github.com/cweill/gotests/...@latest \ + github.com/haya14busa/goplay/cmd/goplay@latest \ + github.com/sqs/goreturns@latest \ + github.com/josharian/impl@latest \ + github.com/davidrjenni/reftools/cmd/fillstruct@latest \ + github.com/uudashr/gopkgs/cmd/gopkgs@latest \ + github.com/ramya-rao-a/go-outline@latest \ + github.com/acroca/go-symbols@latest \ + github.com/godoctor/godoctor@latest \ + github.com/rogpeppe/godef@latest \ + github.com/zmb3/gogetdoc@latest \ + github.com/fatih/gomodifytags@latest \ + github.com/mgechev/revive@latest \ + github.com/go-delve/delve/cmd/dlv@latest 2>&1 \ + # + # Install Go tools w/o module support + && go get -v github.com/alecthomas/gometalinter 2>&1 \ + # + # 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 Go tools - && go get -u -v \ - github.com/mdempsky/gocode \ - github.com/uudashr/gopkgs/cmd/gopkgs \ - github.com/ramya-rao-a/go-outline \ - github.com/acroca/go-symbols \ - github.com/godoctor/godoctor \ - golang.org/x/tools/cmd/guru \ - golang.org/x/tools/cmd/gorename \ - github.com/rogpeppe/godef \ - github.com/zmb3/gogetdoc \ - github.com/haya14busa/goplay/cmd/goplay \ - github.com/sqs/goreturns \ - github.com/josharian/impl \ - github.com/davidrjenni/reftools/cmd/fillstruct \ - github.com/fatih/gomodifytags \ - github.com/cweill/gotests/... \ - golang.org/x/tools/cmd/goimports \ - golang.org/x/lint/golint \ - golang.org/x/tools/gopls \ - github.com/alecthomas/gometalinter \ - honnef.co/go/tools/... \ - github.com/golangci/golangci-lint/cmd/golangci-lint \ - github.com/mgechev/revive \ - github.com/derekparker/delve/cmd/dlv 2>&1 + # Install golangci-lint + && curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin 2>&1 -ENV GO111MODULE=on - -# Switch back to dialog for any ad-hoc use of apt-get -ENV DEBIAN_FRONTEND=dialog +RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" "$GOPATH/pkg/mod" && chmod -R 777 "$GOPATH" +ENV GO111MODULE=on \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 0076d052..7e3e50e7 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -3,9 +3,9 @@ "service": "neko", "dockerComposeFile": "docker-compose.yaml", "workspaceFolder": "/workspace", - "remoteUser": "vscode", + "remoteUser": "neko", "settings": { - "terminal.integrated.shell.linux": "/bin/bash", + "terminal.integrated.shell.linux": "/bin/ash", "go.gopath": "/go" }, "extensions": [ diff --git a/.devcontainer/docker-compose.yaml b/.devcontainer/docker-compose.yaml index 7b3062e4..31207e92 100644 --- a/.devcontainer/docker-compose.yaml +++ b/.devcontainer/docker-compose.yaml @@ -1,4 +1,4 @@ -version: '3.6' +version: '2.0' services: neko: network_mode: host @@ -11,6 +11,7 @@ services: security_opt: - seccomp:unconfined volumes: - - /home/neko/src:/workspace + - /home/nurd/neko:/workspace - /var/run/docker.sock:/var/run/docker.sock - command: "/bin/sh -c \"while sleep 1000; do :; done\"" + + command: "/bin/sh -c \"while sleep 1000; do :; done\"" \ No newline at end of file diff --git a/.docker/entrypoint.sh b/.docker/entrypoint.sh deleted file mode 100755 index 92d13615..00000000 --- a/.docker/entrypoint.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -sudo /etc/init.d/dbus start - -echo "Starting supervisord" -/usr/bin/supervisord -c /etc/neko/supervisord.conf \ No newline at end of file diff --git a/.docker/files/dbus b/.docker/files/dbus new file mode 100755 index 00000000..38c8474f --- /dev/null +++ b/.docker/files/dbus @@ -0,0 +1,4 @@ +#!/bin/sh + +rm -rf /var/run/dbus.pid +/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/default.pa b/.docker/files/default.pa similarity index 100% rename from .docker/default.pa rename to .docker/files/default.pa diff --git a/.docker/firefox/autoconfig.js b/.docker/files/firefox/autoconfig.js similarity index 100% rename from .docker/firefox/autoconfig.js rename to .docker/files/firefox/autoconfig.js diff --git a/.docker/firefox/neko.js b/.docker/files/firefox/neko.js similarity index 100% rename from .docker/firefox/neko.js rename to .docker/files/firefox/neko.js diff --git a/.docker/firefox/policies.json b/.docker/files/firefox/policies.json similarity index 99% rename from .docker/firefox/policies.json rename to .docker/files/firefox/policies.json index d062762c..dd42fa69 100644 --- a/.docker/firefox/policies.json +++ b/.docker/files/firefox/policies.json @@ -28,7 +28,7 @@ }, { "Title": "9Anime", - "URL": "https://9anime.to/", + "URL": "https://9anime.xyz/", "Favicon": "https://staticf.akacdn.ru/assets/favicons/favicon.png", "Folder": "Media", "Placement": "toolbar" diff --git a/.docker/openbox.xml b/.docker/files/openbox.xml similarity index 99% rename from .docker/openbox.xml rename to .docker/files/openbox.xml index 9410a010..af6f12df 100644 --- a/.docker/openbox.xml +++ b/.docker/files/openbox.xml @@ -640,7 +640,7 @@ - /var/lib/openbox/debian-menu.xml + menu.xml 200