diff --git a/test/docker-compose.yaml b/test/docker-compose.yaml new file mode 100644 index 00000000..69f3067b --- /dev/null +++ b/test/docker-compose.yaml @@ -0,0 +1,64 @@ +version: "3.4" + +volumes: + X11-unix: + +services: + xserver: + build: "./xserver" + restart: "unless-stopped" + user: "1000:1000" + command: ":0.0" + volumes: + - "X11-unix:/tmp/.X11-unix:rw" + + pulseaudio: + build: "./pulseaudio" + restart: "unless-stopped" + + neko: + build: + context: "../" + dockerfile: "test/neko/Dockerfile" + restart: "unless-stopped" + shm_size: "2gb" + ports: + - "8081:8080" + - "52000-52100:52000-52100/udp" + environment: + DISPLAY: ":0.0" + NEKO_DISPLAY: ":0.0 remote=true" + PULSE_SERVER: tcp:pulseaudio:4713 + NEKO_SCREEN: 1920x1080@30 + NEKO_PASSWORD: neko + NEKO_PASSWORD_ADMIN: admin + NEKO_EPR: 52000-52100 + NEKO_NAT1TO1: 192.168.1.38 + NEKO_ICELITE: 1 + volumes: + - "X11-unix:/tmp/.X11-unix:ro" + depends_on: + - xserver + - pulseaudio + + openbox: + build: "./openbox" + restart: "unless-stopped" + environment: + DISPLAY: ":0.0" + volumes: + - "X11-unix:/tmp/.X11-unix:ro" + depends_on: + - xserver + + firefox: + build: "./firefox" + restart: "unless-stopped" + environment: + DISPLAY: ":0.0" + PULSE_SERVER: tcp:pulseaudio:4713 + volumes: + - "X11-unix:/tmp/.X11-unix:ro" + depends_on: + - neko + - openbox diff --git a/test/firefox/Dockerfile b/test/firefox/Dockerfile new file mode 100644 index 00000000..ef83a990 --- /dev/null +++ b/test/firefox/Dockerfile @@ -0,0 +1,32 @@ +FROM m1k1o/neko:base + +# +# install firefox +RUN set -eux; apt-get update; \ + apt-get install -y --no-install-recommends firefox-esr; \ + # + # create a non-root user + #groupadd --gid 1000 neko; \ + #useradd --uid 1000 --gid neko --shell /bin/bash --create-home neko; \ + # + # install fonts + apt-get install -y --no-install-recommends \ + # Google emojis + fonts-noto-color-emoji \ + # Japanese fonts + fonts-takao-mincho \ + # Chinese fonts + fonts-wqy-zenhei xfonts-intl-chinese xfonts-wqy \ + # Korean fonts + fonts-wqy-microhei; \ + # + # clean up + apt-get --purge autoremove -y xz-utils bzip2; \ + apt-get clean -y; \ + rm -rf /var/lib/apt/lists/* /var/cache/apt/* + +USER neko + +ENTRYPOINT [ "/usr/bin/firefox" ] + +CMD [ "--display", $DISPLAY, "-setDefaultBrowser", "-width", "1280", "-height", "720" ] diff --git a/test/neko/Dockerfile b/test/neko/Dockerfile new file mode 100644 index 00000000..b4b09ff5 --- /dev/null +++ b/test/neko/Dockerfile @@ -0,0 +1,102 @@ +# +# STAGE 1: SERVER +# +FROM golang:1.20-bullseye as server +WORKDIR /src + +# +# install dependencies +RUN set -eux; apt-get update; \ + apt-get install -y --no-install-recommends git cmake make libx11-dev libxrandr-dev libxtst-dev \ + libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly; \ + # + # install libclipboard + set -eux; \ + cd /tmp; \ + git clone --depth=1 https://github.com/jtanx/libclipboard; \ + cd libclipboard; \ + cmake .; \ + make -j4; \ + make install; \ + rm -rf /tmp/libclipboard; \ + # + # clean up + apt-get clean -y; \ + rm -rf /var/lib/apt/lists/* /var/cache/apt/* + +# +# build server +COPY server/ . +RUN ./build + +# +# STAGE 2: CLIENT +# +FROM node:18-bullseye-slim as client +WORKDIR /src + +# +# install dependencies +COPY client/package*.json ./ +RUN npm install + +# +# build client +COPY client/ . +RUN npm run build + +# +# STAGE 3: RUNTIME +# +FROM debian:bullseye-slim + +# +# set custom user +ARG USERNAME=neko +ARG USER_UID=1000 +ARG USER_GID=$USER_UID + +RUN set -eux; \ + apt-get update; \ + # + # install dependencies + apt-get install -y --no-install-recommends pulseaudio dbus-x11 xserver-xorg-video-dummy; \ + apt-get install -y --no-install-recommends libcairo2 libxcb1 libxrandr2 libxv1 libopus0 libvpx6; \ + # + # gst + apt-get install -y --no-install-recommends \ + libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev \ + gstreamer1.0-plugins-base gstreamer1.0-plugins-good \ + gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly \ + gstreamer1.0-pulseaudio; \ + # + # create a non-root user + groupadd --gid $USER_GID $USERNAME; \ + useradd --uid $USER_UID --gid $USERNAME --shell /bin/bash --create-home $USERNAME; \ + # + # make directories for neko + mkdir -p /etc/neko /var/www /var/log/neko; \ + chmod 1777 /var/log/neko; \ + chown -R $USERNAME:$USERNAME /home/$USERNAME; \ + # + # clean up + apt-get clean -y; \ + rm -rf /var/lib/apt/lists/* /var/cache/apt/* + +# +# set default envs +ENV USER=$USERNAME +ENV NEKO_PASSWORD=neko +ENV NEKO_PASSWORD_ADMIN=admin +ENV NEKO_BIND=:8080 + +# +# copy static files from previous stages +COPY --from=server /src/bin/neko /usr/bin/neko +COPY --from=client /src/dist/ /var/www + +USER $USERNAME + +ENTRYPOINT [ "/usr/bin/neko" ] + +CMD [ "serve", "--static", "/var/www" ] diff --git a/test/openbox/Dockerfile b/test/openbox/Dockerfile new file mode 100644 index 00000000..0552d1f6 --- /dev/null +++ b/test/openbox/Dockerfile @@ -0,0 +1,34 @@ +FROM debian:bullseye-slim + +# +# set custom user +ARG USERNAME=neko +ARG USER_UID=1000 +ARG USER_GID=$USER_UID + +# +# install dependencies +RUN set -eux; apt-get update; \ + apt-get install -y --no-install-recommends openbox; \ + # + # create a non-root user + groupadd --gid $USER_GID $USERNAME; \ + useradd --uid $USER_UID --gid $USERNAME --shell /bin/bash --create-home $USERNAME; \ + # + # clean up + apt-get clean -y; \ + rm -rf /var/lib/apt/lists/* /var/cache/apt/* + +# +# set default envs +ENV USER=$USERNAME + +# +# copy configuation files +COPY openbox.xml /etc/neko/openbox.xml + +USER $USERNAME + +ENTRYPOINT [ "/usr/bin/openbox" ] + +CMD [ "--config-file", "/etc/neko/openbox.xml" ] diff --git a/test/openbox/openbox.xml b/test/openbox/openbox.xml new file mode 100644 index 00000000..d2d7d7be --- /dev/null +++ b/test/openbox/openbox.xml @@ -0,0 +1,763 @@ + + + + + + + + 10 + 20 + + + + + + no + true + yes + normal + + + + + yes + + no + + yes + + no + + 200 + + no + + + + + Smart + +
yes
+ + Primary + + 1 + +
+ + + Clearlooks + NLIMC + + yes + yes + + sans + 8 + + bold + + normal + + + + sans + 8 + + bold + + normal + + + + sans + 9 + + normal + + normal + + + + sans + 9 + + normal + + normal + + + + sans + 9 + + bold + + normal + + + + sans + 9 + + bold + + normal + + + + + + + 1 + 1 + + + + 875 + + + + + yes + Nonpixel + + Center + + + + + 10 + + 10 + + + + + + + 0 + 0 + 0 + 0 + + + + TopLeft + + 0 + 0 + no + Above + + Vertical + + no + 300 + + 300 + + Middle + + + + + C-g + + + + leftno + + + rightno + + + upno + + + downno + + + leftno + + + rightno + + + upno + + + downno + + + 1 + + + 2 + + + 3 + + + 4 + + + + + + + + + + + + + + + + + + + + scrot -s + + + + + + + + + + + + + + + + + + + + + + + + yesyes + + + + + + + + + + + + right + + + + + left + + + + + up + + + + + down + + + + + + + + true + Konqueror + + kfmclient openProfile filemanagement + + + + + scrot + + + + + 1 + + 500 + + 400 + + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + previous + + + next + + + previous + + + next + + + previous + + + next + + + + + + + + + + + + + + no + + + + + + + + + + + yes + + + + + + + + + + + + + + + + + + + + + + + + + + + top + + + + + + left + + + + + + right + + + + + + bottom + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + vertical + + + horizontal + + + + + + + + + + + + + + + + + previous + + + next + + + + previous + + + next + + + previous + + + next + + + + + + + + + + + + + + + + + + + + previous + + + next + + + previous + + + next + + + + + + + + + + + menu.xml + 200 + + no + + 100 + + 400 + + yes + + yes + + + + + + + +
diff --git a/test/pulseaudio/Dockerfile b/test/pulseaudio/Dockerfile new file mode 100644 index 00000000..4edcabf2 --- /dev/null +++ b/test/pulseaudio/Dockerfile @@ -0,0 +1,38 @@ +FROM debian:bullseye-slim + +# +# set custom user +ARG USERNAME=neko +ARG USER_UID=1000 +ARG USER_GID=$USER_UID + +# +# install dependencies +RUN set -eux; apt-get update; \ + apt-get install -y --no-install-recommends pulseaudio; \ + # + # create a non-root user + groupadd --gid $USER_GID $USERNAME; \ + useradd --uid $USER_UID --gid $USERNAME --shell /bin/bash --create-home $USERNAME; \ + # + # make directories + mkdir -p /home/$USERNAME/.config/pulse; \ + chown -R $USERNAME:$USERNAME /home/$USERNAME; \ + # + # clean up + apt-get clean -y; \ + rm -rf /var/lib/apt/lists/* /var/cache/apt/* + +# +# set default envs +ENV USER=$USERNAME + +# +# copy configuation files +COPY default.pa /etc/pulse/default.pa + +USER $USERNAME + +ENTRYPOINT [ "/usr/bin/pulseaudio" ] + +CMD [ "--log-level=info", "--disallow-module-loading", "--disallow-exit", "--exit-idle-time=-1" ] diff --git a/test/pulseaudio/default.pa b/test/pulseaudio/default.pa new file mode 100644 index 00000000..fae6b76a --- /dev/null +++ b/test/pulseaudio/default.pa @@ -0,0 +1,10 @@ +#!/usr/bin/pulseaudio -nF + +### Create virtual output device sink +load-module module-null-sink sink_name=audio_output sink_properties=device.description="Virtual\ Audio\ Output" + +# Allow pulse audio to be accessed via TCP (from localhost only), to allow other users to access the virtual devices +load-module module-native-protocol-tcp port=4713 auth-anonymous=1 + +### Make sure we always have a sink around, even if it is a null sink. +load-module module-always-sink diff --git a/test/xserver/Dockerfile b/test/xserver/Dockerfile new file mode 100644 index 00000000..6526cf61 --- /dev/null +++ b/test/xserver/Dockerfile @@ -0,0 +1,17 @@ +FROM debian:bullseye-slim + +# +# install dependencies +RUN set -eux; \ + apt-get update; \ + apt-get install -y --no-install-recommends x11-xserver-utils xserver-xorg-video-dummy; \ + # + # clean up + apt-get clean -y; \ + rm -rf /var/lib/apt/lists/* /var/cache/apt/* + +# +# copy configuation files +COPY xorg.conf /etc/neko/xorg.conf + +ENTRYPOINT [ "/usr/bin/X", "-config", "/etc/neko/xorg.conf", "-nolisten", "local", "-logfile", "/dev/stderr" ] diff --git a/test/xserver/xorg.conf b/test/xserver/xorg.conf new file mode 100644 index 00000000..57016ad1 --- /dev/null +++ b/test/xserver/xorg.conf @@ -0,0 +1,88 @@ +# This xorg configuration file is meant to be used by xpra +# to start a dummy X11 server. +# For details, please see: +# https://xpra.org/trac/wiki/Xdummy + +Section "ServerFlags" + Option "DontVTSwitch" "true" + Option "AllowMouseOpenFail" "true" + Option "PciForceNone" "true" + Option "AutoEnableDevices" "false" + Option "AutoAddDevices" "false" +EndSection + +Section "InputDevice" + Identifier "dummy_mouse" + Option "CorePointer" "true" + Driver "void" +EndSection + +Section "InputDevice" + Identifier "dummy_keyboard" + Option "CoreKeyboard" "true" + Driver "void" +EndSection + +Section "Device" + Identifier "dummy_videocard" + Driver "dummy" + Option "ConstantDPI" "true" + #VideoRam 4096000 + #VideoRam 256000 + VideoRam 192000 +EndSection + +Section "Monitor" + Identifier "dummy_monitor" + HorizSync 5.0 - 1000.0 + VertRefresh 5.0 - 200.0 + #This can be used to get a specific DPI, but only for the default resolution: + #DisplaySize 508 317 + #NOTE: the highest modes will not work without increasing the VideoRam + # for the dummy video card. + # https://arachnoid.com/modelines/ + + # 1280x720 @ 30.00 Hz (GTF) hsync: 21.99 kHz; pclk: 33.78 MHz + Modeline "1280x720_30.00" 33.78 1280 1288 1408 1536 720 721 724 733 -HSync +Vsync + + # 1280x720 @ 60.00 Hz (GTF) hsync: 44.76 kHz; pclk: 74.48 MHz + Modeline "1280x720_60.00" 74.48 1280 1336 1472 1664 720 721 724 746 -HSync +Vsync + # 1152x648 @ 60.00 Hz (GTF) hsync: 40.26 kHz; pclk: 59.91 MHz + Modeline "1152x648_60.00" 59.91 1152 1200 1320 1488 648 649 652 671 -HSync +Vsync + # 1024x576 @ 60.00 Hz (GTF) hsync: 35.82 kHz; pclk: 47.00 MHz + Modeline "1024x576_60.00" 47.00 1024 1064 1168 1312 576 577 580 597 -HSync +Vsync + # 960x720 @ 60.00 Hz (GTF) hsync: 44.76 kHz; pclk: 55.86 MHz + Modeline "960x720_60.00" 55.86 960 1008 1104 1248 720 721 724 746 -HSync +Vsync + # 800x600 @ 60.00 Hz (GTF) hsync: 37.32 kHz; pclk: 38.22 MHz + Modeline "800x600_60.00" 38.22 800 832 912 1024 600 601 604 622 -HSync +Vsync + + # 1920x1080 @ 30.00 Hz (GTF) hsync: 32.97 kHz; pclk: 80.18 MHz + Modeline "1920x1080_30.00" 80.18 1920 1984 2176 2432 1080 1081 1084 1099 -HSync +Vsync + # 1152x648 @ 30.00 Hz (GTF) hsync: 19.80 kHz; pclk: 26.93 MHz + Modeline "1152x648_30.00" 26.93 1152 1144 1256 1360 648 649 652 660 -HSync +Vsync + # 1024x576 @ 30.00 Hz (GTF) hsync: 17.61 kHz; pclk: 20.85 MHz + Modeline "1024x576_30.00" 20.85 1024 1008 1104 1184 576 577 580 587 -HSync +Vsync + # 960x720 @ 30.00 Hz (GTF) hsync: 21.99 kHz; pclk: 25.33 MHz + Modeline "960x720_30.00" 25.33 960 960 1056 1152 720 721 724 733 -HSync +Vsync + # 800x600 @ 30.00 Hz (GTF) hsync: 18.33 kHz; pclk: 17.01 MHz + Modeline "800x600_30.00" 17.01 800 792 864 928 600 601 604 611 -HSync +Vsync +EndSection + +Section "Screen" + Identifier "dummy_screen" + Device "dummy_videocard" + Monitor "dummy_monitor" + DefaultDepth 24 + SubSection "Display" + Viewport 0 0 + Depth 24 + Modes "1280x720_30.00" "1920x1080_60.00" "1280x720_60.00" "1152x648_60.00" "1024x576_60.00" "960x720_60.00" "800x600_60.00" "1920x1080_30.00" "1152x648_30.00" "1024x576_30.00" "960x720_30.00" "800x600_30.00" + EndSubSection +EndSection + +Section "ServerLayout" + Identifier "dummy_layout" + Screen "dummy_screen" + InputDevice "dummy_mouse" + InputDevice "dummy_keyboard" +EndSection