This commit is contained in:
Craig
2020-01-27 01:28:39 +00:00
parent 06feef7559
commit 0e9fbf7ba2
17 changed files with 335 additions and 237 deletions

View File

@ -1,83 +1,120 @@
FROM debian:stretch-slim
FROM frolvlad/alpine-glibc
ENV GST_VERSION=1.16.2
# 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" \
#
# build openh264
&& git clone https://github.com/cisco/openh264.git \
&& cd openh264 \
&& make && make install \
&& cd /tmp && 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" \
#
# remove build deps
&& apk del .gst-build-deps
ARG USERNAME=neko
ARG USER_UID=1000
ARG USER_GID=$USER_UID
# Avoid warnings by switching to noninteractive
ENV DEBIAN_FRONTEND=noninteractive
# 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 dependencies ttf-freefont
RUN apt-get update \
&& apt-get -y install curl apt-utils supervisor openbox dbus-x11 xvfb pulseaudio firefox-esr \
&& apt-get -y install gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-pulseaudio \
&& apt-get -y install libxcb-xkb-dev libxkbcommon-x11-dev xclip \
# 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" \
#
# Create a non-root user
&& groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USERNAME --shell /bin/bash --create-home $USERNAME \
# create a non-root user
&& addgroup -g $USER_GID $USERNAME \
&& adduser -D -u $USER_UID -G $USERNAME -s /bin/ash -h /home/$USERNAME $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 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 uBlock
&& mkdir -p /usr/lib/firefox-esr/distribution/extensions \
&& curl -o /usr/lib/firefox-esr/distribution/extensions/uBlock0@raymondhill.net.xpi https://addons.mozilla.org/firefox/downloads/latest/ublock-origin/addon-607454-latest.xpi \
#
# Setup Pulse Audio
# setup pulseaudio
&& mkdir -p /home/$USERNAME/.config/pulse/ \
&& echo "default-server=unix:/tmp/pulseaudio.socket" > /home/$USERNAME/.config/pulse/client.conf \
&& chown -R $USERNAME:$USERNAME /home/$USERNAME \
#
# Workaround for an X11 problem. See: http://blog.tigerteufel.de/?p=476
# workaround for an X11 problem: http://blog.tigerteufel.de/?p=476
&& mkdir /tmp/.X11-unix && chmod 1777 /tmp/.X11-unix && chown $USERNAME /tmp/.X11-unix/ \
#
# Make directories for neko
&& 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/*
# make directories for neko
&& mkdir -p /etc/neko /var/www
#
# Copy configuation files
COPY .docker/openbox.xml /etc/neko/openbox.xml
COPY .docker/supervisord.conf /etc/neko/supervisord.conf
COPY .docker/default.pa /etc/pulse/default.pa
COPY .docker/firefox/neko.js /usr/lib/firefox-esr/mozilla.cfg
COPY .docker/firefox/autoconfig.js /usr/lib/firefox-esr/defaults/pref/autoconfig.js
COPY .docker/firefox/policies.json /usr/lib/firefox-esr/distribution/policies.json
# env
ENV USER=$USERNAME
ENV SCREEN_WIDTH=1280
ENV SCREEN_HEIGHT=720
ENV SCREEN_DEPTH=24
ENV DISPLAY=:99.0
#
# Neko files
# copy configuation files
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
#
# neko files
COPY client/dist/ /var/www
COPY server/bin/neko /usr/bin/neko
USER $USERNAME
#
# Neko Env
ENV NEKO_USER=$USERNAME
ENV NEKO_DISPLAY=0
ENV NEKO_WIDTH=1280
ENV NEKO_HEIGHT=720
# neko env
ENV NEKO_PASSWORD=neko
ENV NEKO_ADMIN=admin
ENV NEKO_BIND=:8080
# Neko Nyan (=^-ω-^=)
ENV NEKO_URL=https://www.youtube.com/embed/QH2-TGUlwu4
#
# Copy entrypoint
COPY .docker/entrypoint.sh /entrypoint.sh
#
# Run Service
CMD ["/bin/bash", "/entrypoint.sh"]
# run neko
CMD ["/usr/bin/supervisord", "-c", "/etc/neko/supervisord.conf"]