split base build to multiple dockerfiles.

This commit is contained in:
Miroslav Šedivý 2024-09-08 17:21:09 +02:00
parent bbefb393f8
commit 38e8ac3e21
79 changed files with 455 additions and 968 deletions

View file

@ -1,148 +0,0 @@
#
# Stage 0: Build xorg dependencies.
#
FROM debian:bullseye-slim as xorg-deps
ENV DEBIAN_FRONTEND=noninteractive
RUN set -eux; \
apt-get update; \
apt-get install -y \
git gcc pkgconf autoconf automake libtool make xorg-dev xutils-dev \
&& rm -rf /var/lib/apt/lists/*;
WORKDIR /xorg
COPY xorg/ /xorg/
# build xserver-xorg-video-dummy 0.3.8-2 with RandR support.
RUN set -eux; \
cd xf86-video-dummy; \
git clone --depth 1 --branch xserver-xorg-video-dummy-1_0.3.8-2 https://salsa.debian.org/xorg-team/driver/xserver-xorg-video-dummy; \
cd xserver-xorg-video-dummy; \
patch -p1 < ../xdummy-randr.patch; \
./autogen.sh; \
make -j$(nproc); \
make install;
# build custom input driver
RUN set -eux; \
cd xf86-input-neko; \
./autogen.sh --prefix=/usr; \
./configure; \
make -j$(nproc); \
make install;
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.166.0/containers/go/.devcontainer/base.Dockerfile
# [Choice] Go version: 1, 1.16, 1.15
ARG VARIANT="1"
FROM mcr.microsoft.com/vscode/devcontainers/go:0-${VARIANT}
# [Option] Install Node.js
ARG INSTALL_NODE="true"
ARG NODE_VERSION="lts/*"
RUN if [ "${INSTALL_NODE}" = "true" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi
# build dependencies
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends \
libx11-dev libxrandr-dev libxtst-dev libgtk-3-dev \
libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev; \
# install libxcvt-dev (not available in base image)
wget http://ftp.de.debian.org/debian/pool/main/libx/libxcvt/libxcvt-dev_0.1.2-1_amd64.deb; \
wget http://ftp.de.debian.org/debian/pool/main/libx/libxcvt/libxcvt0_0.1.2-1_amd64.deb; \
apt-get install --no-install-recommends ./libxcvt0_0.1.2-1_amd64.deb ./libxcvt-dev_0.1.2-1_amd64.deb;
# runtime dependencies
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends \
wget ca-certificates supervisor \
pulseaudio dbus-x11 xserver-xorg-video-dummy \
libcairo2 libxcb1 libxrandr2 libxv1 libopus0 libvpx6 \
#
# needed for profile upload preStop hook
zip curl \
#
# file chooser handler, clipboard, drop
xdotool xclip libgtk-3-0 \
#
# gst
gstreamer1.0-plugins-base gstreamer1.0-plugins-good \
gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly \
gstreamer1.0-pulseaudio;
# libxcvt already installed
# dev runtime dependencies
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends \
xfce4 xfce4-terminal firefox-esr sudo;
# configure runtime
ARG USERNAME=neko
ARG USER_UID=1001
ARG USER_GID=$USER_UID
RUN set -eux; \
#
# create a 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
echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME; \
chmod 0440 /etc/sudoers.d/$USERNAME; \
#
# 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; \
chown -R $USERNAME:$USERNAME /home/$USERNAME; \
#
# install fonts
apt-get install -y --no-install-recommends \
# Emojis
fonts-noto-color-emoji \
# Chinese fonts
fonts-arphic-ukai fonts-arphic-uming \
# Japanese fonts
fonts-ipafont-mincho fonts-ipafont-gothic \
# Korean fonts
fonts-unfonts-core \
# Indian fonts
fonts-indic;
# copy dependencies from previous stage
COPY --from=xorg-deps /usr/local/lib/xorg/modules/drivers/dummy_drv.so /usr/lib/xorg/modules/drivers/dummy_drv.so
COPY --from=xorg-deps /usr/local/lib/xorg/modules/input/neko_drv.so /usr/lib/xorg/modules/input/neko_drv.so
# copy runtime files
COPY runtime/dbus /usr/bin/dbus
COPY runtime/default.pa /etc/pulse/default.pa
COPY runtime/supervisord.conf /etc/neko/supervisord.conf
COPY runtime/xorg.conf /etc/neko/xorg.conf
COPY runtime/icon-theme /home/$USERNAME/.icons/default
# copy dev runtime files
COPY dev/runtime/config.yml /etc/neko/neko.yml
COPY dev/runtime/supervisord.conf /etc/neko/supervisord/dev.conf
# customized scripts
RUN chmod +x /usr/bin/dbus;\
echo '#!/bin/sh\nsleep infinity' > /usr/bin/neko; \
chmod +x /usr/bin/neko; \
echo '#!/bin/sh\nsudo sh -c "export USER='$USERNAME'\nexport HOME=/home/'$USERNAME'\n/usr/bin/supervisord -c /etc/neko/supervisord.conf"' > /usr/bin/deps; \
chmod +x /usr/bin/deps; \
touch .env.development;
# set default envs
ENV USER=$USERNAME
ENV DISPLAY=:99.0
ENV PULSE_SERVER=unix:/tmp/pulseaudio.socket
ENV NEKO_SERVER_BIND=:3000
ENV NEKO_WEBRTC_EPR=3001-3004

View file

@ -1,20 +0,0 @@
# dev container
You need to run all dependencies with `deps` command before you start debugging.
Create `.env.development` in repository root. Make sure your local IP is correct.
```sh
NEKO_WEBRTC_NAT1TO1=10.0.0.8
```
# without container
- Make sure `pulseaudio` contains correct configuration.
- Specify `DISPLAY` that is being used by xorg.
```sh
DISPLAY=:0
NEKO_WEBRTC_NAT1TO1=10.0.0.8
NEKO_SERVER_BIND=:3000
```

View file

@ -1,44 +0,0 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.166.0/containers/go
{
"name": "Go",
"build": {
"dockerfile": "Dockerfile",
"context": "../server/",
"args": {
// Update the VARIANT arg to pick a version of Go: 1, 1.16, 1.15
"VARIANT": "1.20",
// Options
"INSTALL_NODE": "false",
"NODE_VERSION": "lts/*"
}
},
"runArgs": [ "--cap-add=SYS_PTRACE", "--cap-add=SYS_ADMIN", "--shm-size=2G", "--security-opt", "seccomp=unconfined" ],
"customizations": {
"vscode": {
// Set *default* container specific settings.json values on container create.
"settings": {
"terminal.integrated.shell.linux": "/bin/bash",
"go.toolsManagement.checkForUpdates": "local",
"go.useLanguageServer": true,
"go.gopath": "/go",
"go.goroot": "/usr/local/go"
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"golang.Go"
]
}
},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
"appPort": ["3000:3000", "3001:3001/udp", "3002:3002/udp", "3003:3003/udp", "3004:3004/udp"],
// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "go version",
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "neko"
}

View file

@ -2,11 +2,26 @@
If you want to contribute, but do not want to install anything on your host system, we got you covered. You only need docker. Technically, it could be done using vs code development in container, but this is more fun:).
## Running server (while developing)
Go to `../server/dev` and run:
- `./build` - Build server binary.
- `./start` - Start server.
- `./rebuild` - Rebuild server binary and restart server while it is running.
## Running client (while developing)
Go to `../client/dev` and run:
- `./npm install` - Install dependencies first.
- `./serve` - Start client with live reload.
## Building a new image after changes
You need to copy `.env.default` to `.env` and customize values.
## Step 1: Building server
- `./build` - You can use this command to build your specified `SERVER_TAG` along with base image.
- `./build` - You can use this command to build base image. It will be used for building other images.
If you want, you can build other tags. `base` tag needs to be build first:
@ -15,26 +30,3 @@ If you want, you can build other tags. `base` tag needs to be build first:
- `./build chromium`
- `./build google-chrome`
- etc...
## Step 2: Starting server
- `./start-server` - Starting server image you specified in `.env`.
- `./start-server -r` - Shortcut for rebuilding server binary and then starting.
If you are changing something in the server code, you do not want to rebuild container each time. You can just rebuild your binary:
- `./rebuild-server` - Rebuild only server binary.
- `./rebuild-server -f` - Force to rebuild whole Golang environment (you should do this only of you change some dependencies).
## Step 3: Serving client
- `./serve-client` - Serving vue.js client.
- `./serve-client -i` - Install all dependencies.
## Debug
You can navigate to `CLIENT_PORT` and see live client there. It will be connected to your local server on `SERVER_PORT`.
If you are leaving client as is and not changing it, you don't need to start `./serve-client` and you can access server's GUI directly on `SERVER_PORT`.
Feel free to open new PR.

View file

@ -2,8 +2,6 @@
set -ex
cd "$(dirname "$0")"
BASE="${PWD}/../"
# BUILD_IMAGE from environment vairables has precedence
if [ ! -z "${BUILD_IMAGE}" ]
then
@ -35,18 +33,18 @@ fi
build_client() {
docker build -t neko-dev-client -f base/Dockerfile --target client "${BASE}"
docker build -t neko-dev-client ../client
docker run --rm \
--user "$(id -u):$(id -g)" \
-v "${BASE}client/dist:/tmp/dist" \
-v "${PWD}/../client/dist:/tmp/dist" \
neko-dev-client sh -c "rm -rf /tmp/dist/*; cp -r /src/dist/* /tmp/dist"
}
build_server() {
docker build -t neko-dev-server -f base/Dockerfile --target server "${BASE}"
docker build -t neko-dev-server ../server
docker run --rm \
--user "$(id -u):$(id -g)" \
-v "${BASE}server/bin:/tmp/bin" \
-v "${PWD}/../server/bin:/tmp/bin" \
neko-dev-server sh -c "rm -rf /tmp/bin/neko; cp /src/bin/neko /tmp/bin"
}
@ -54,7 +52,7 @@ build() {
if [ "$1" = "base" ]
then
# build base
docker build -t "${BUILD_IMAGE}:base" -f base/Dockerfile "${BASE}"
BUILD_IMAGE=$BUILD_IMAGE ../build
else
# build image
docker build -t "${BUILD_IMAGE}:$1" --build-arg="BASE_IMAGE=${BUILD_IMAGE}:base" -f "$1/Dockerfile" "$1/"
@ -65,7 +63,7 @@ build_arm() {
if [ "$1" = "base" ]
then
# build ARM base
docker build -t "${BUILD_IMAGE}:arm-base" -f base/Dockerfile.arm "${BASE}"
BUILD_IMAGE=$BUILD_IMAGE FLAVOUR=arm ../build
elif [ -f "$1/Dockerfile.arm" ]
then
# build dedicated ARM image
@ -80,7 +78,7 @@ build_intel() {
if [ "$1" = "base" ]
then
# build intel base
docker build -t "${BUILD_IMAGE}:intel-base" -f base/Dockerfile.intel "${BASE}"
BUILD_IMAGE=$BUILD_IMAGE FLAVOUR=intel ../build
elif [ -f "$1/Dockerfile.intel" ]
then
# build dedicated intel image
@ -95,7 +93,7 @@ build_nvidia() {
if [ "$1" = "base" ]
then
# build nvidia base
docker build -t "${BUILD_IMAGE}:nvidia-base" -f base/Dockerfile.nvidia "${BASE}"
BUILD_IMAGE=$BUILD_IMAGE FLAVOUR=nvidia ../build
elif [ -f "$1/Dockerfile.nvidia" ]
then
# build dedicated nvidia image

10
.gitignore vendored
View file

@ -33,3 +33,13 @@ bin
# Environment files
*.env
bin/
.idea
.env.development
runtime/fonts/*
!runtime/fonts/.gitkeep
runtime/icon-theme/*
!runtime/icon-theme/.gitkeep

72
build Executable file
View file

@ -0,0 +1,72 @@
#!/bin/bash
cd "$(dirname "$0")"
# if build image is not specified, use default
if [ -z "$BUILD_IMAGE" ]; then
BUILD_IMAGE="m1k1o/neko"
fi
echo "Using build image: $BUILD_IMAGE"
echo "Using flavour: $FLAVOUR"
RUNTIME_IMAGE="neko-runtime"
# if flavour is specified, append it to the image name and Dockerfile
if [ "$FLAVOUR" != "" ]; then
RUNTIME_IMAGE="$RUNTIME_IMAGE-$FLAVOUR"
BASE_IMAGE="$BUILD_IMAGE:$FLAVOUR-base"
else
BASE_IMAGE="$BUILD_IMAGE:base"
fi
# if -f is passed, force rebuild
if [ "$1" == "-f" ]; then
echo "Forcing rebuild, removing existing images"
docker rmi neko-xorg-deps neko-server neko-client neko-runtime $BASE_IMAGE
fi
function docker_image_exists() {
[ "$(docker images -q $1 2> /dev/null)" != "" ]
}
if ! docker_image_exists neko-xorg-deps; then
echo "Building neko-xorg-deps image"
docker build -t neko-xorg-deps runtime/xorg-deps/
else
echo "neko-xorg-deps image already exists"
fi
if ! docker_image_exists neko-server; then
echo "Building neko-server image"
docker build -t neko-server server/
else
echo "neko-server image already exists"
fi
if ! docker_image_exists neko-client; then
echo "Building neko-client image"
docker build -t neko-client client/
else
echo "neko-client image already exists"
fi
if ! docker_image_exists $RUNTIME_IMAGE; then
echo "Building $RUNTIME_IMAGE image"
docker build -t $RUNTIME_IMAGE -f runtime/Dockerfile.$FLAVOUR runtime/
else
echo "$RUNTIME_IMAGE image already exists"
fi
docker build -t $BASE_IMAGE -f - . <<EOF
FROM neko-xorg-deps AS xorg-deps
FROM neko-server AS server
FROM neko-client AS client
FROM $RUNTIME_IMAGE AS runtime
COPY --from=xorg-deps /usr/local/lib/xorg/modules/drivers/dummy_drv.so /usr/lib/xorg/modules/drivers/dummy_drv.so
COPY --from=xorg-deps /usr/local/lib/xorg/modules/input/neko_drv.so /usr/lib/xorg/modules/input/neko_drv.so
COPY --from=server /src/bin/plugins/ /etc/neko/plugins/
COPY --from=server /src/bin/neko /usr/bin/neko
COPY --from=client /src/dist/ /var/www
COPY config.yml /etc/neko/neko.yaml
EOF

View file

@ -1 +0,0 @@
VUE_APP_SERVER_PORT=3000

View file

@ -1,4 +1,6 @@
FROM node:18-bullseye-slim as client
ARG BASE_IMAGE=node:18-bullseye-slim
FROM $BASE_IMAGE AS client
WORKDIR /src
#
@ -10,3 +12,7 @@ RUN npm install
# build client
COPY . .
RUN npm run build
#
# artifacts from this stage
# COPY --from=client /src/dist/ /var/www

20
config.yml Normal file
View file

@ -0,0 +1,20 @@
desktop:
screen: "1920x1080@60"
member:
# needed for legacy API ad there is no user management
provider: "multiuser"
multiuser:
admin_password: "admin"
user_password: "neko"
session:
merciful_reconnect: true
# default setting for legacy API
implicit_hosting: false
cookie:
# needed for legacy API
enabled: false
webrtc:
icelite: true

108
runtime/Dockerfile Normal file
View file

@ -0,0 +1,108 @@
ARG BASE_IMAGE=debian:bullseye-slim
FROM $BASE_IMAGE AS runtime
#
# set custom user
ARG USERNAME=neko
ARG USER_UID=1000
ARG USER_GID=$USER_UID
#
# install dependencies
ENV DEBIAN_FRONTEND=noninteractive
RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends \
wget ca-certificates supervisor \
pulseaudio dbus-x11 xserver-xorg-video-dummy \
libcairo2 libxcb1 libxrandr2 libxv1 libopus0 libvpx6 \
#
# needed for profile upload preStop hook
zip curl \
#
# file chooser handler, clipboard, drop
xdotool xclip libgtk-3-0 \
#
# gst
gstreamer1.0-plugins-base gstreamer1.0-plugins-good \
gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly \
gstreamer1.0-pulseaudio; \
# install libxcvt0 (not available in debian:bullseye)
wget http://ftp.de.debian.org/debian/pool/main/libx/libxcvt/libxcvt0_0.1.2-1_amd64.deb; \
apt-get install --no-install-recommends ./libxcvt0_0.1.2-1_amd64.deb; \
rm ./libxcvt0_0.1.2-1_amd64.deb; \
#
# create a 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; \
#
# 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 /var/log/neko \
/tmp/runtime-$USERNAME \
/home/$USERNAME/.config/pulse \
/home/$USERNAME/.local/share/xorg; \
chmod 1777 /var/log/neko; \
chown $USERNAME /var/log/neko/ /tmp/runtime-$USERNAME; \
chown -R $USERNAME:$USERNAME /home/$USERNAME; \
#
# install fonts
apt-get install -y --no-install-recommends \
# Emojis
fonts-noto-color-emoji \
# Chinese fonts
fonts-arphic-ukai fonts-arphic-uming \
fonts-wqy-zenhei xfonts-intl-chinese xfonts-wqy \
# Japanese fonts
fonts-ipafont-mincho fonts-ipafont-gothic \
fonts-takao-mincho \
# Korean fonts
fonts-unfonts-core \
fonts-wqy-microhei \
# Indian fonts
fonts-indic; \
#
# clean up
apt-get clean -y; \
rm -rf /var/lib/apt/lists/* /var/cache/apt/*
#
# copy runtime configs
COPY --chown=neko:neko .Xresources /home/$USERNAME/.Xresources
COPY dbus /usr/bin/dbus
COPY default.pa /etc/pulse/default.pa
COPY supervisord.conf /etc/neko/supervisord.conf
COPY supervisord.dbus.conf /etc/neko/supervisord.dbus.conf
COPY xorg.conf /etc/neko/xorg.conf
#
# copy runtime folders
COPY --chown=neko:neko icon-theme /home/$USERNAME/.icons/default
COPY fontconfig/* /etc/fonts/conf.d/
COPY fonts /usr/local/share/fonts
#
# set default envs
ENV USER=$USERNAME
ENV DISPLAY=:99.0
ENV PULSE_SERVER=unix:/tmp/pulseaudio.socket
ENV XDG_RUNTIME_DIR=/tmp/runtime-$USERNAME
ENV NEKO_SERVER_BIND=:8080
ENV NEKO_PLUGINS_ENABLED=true
ENV NEKO_PLUGINS_DIR=/etc/neko/plugins/
#
# add healthcheck
HEALTHCHECK --interval=10s --timeout=5s --retries=8 \
CMD wget -O - http://localhost:${NEKO_SERVER_BIND#*:}/health || exit 1
#
# run neko
CMD ["/usr/bin/supervisord", "-c", "/etc/neko/supervisord.conf"]

View file

@ -1,76 +1,5 @@
ARG BASE_IMAGE=debian:bullseye-slim
ARG BUILD_IMAGE=golang:1.21-bullseye
#
# Stage 0: Build xorg dependencies.
#
FROM $BASE_IMAGE as xorg-deps
ENV DEBIAN_FRONTEND=noninteractive
RUN set -eux; \
apt-get update; \
apt-get install -y \
git gcc pkgconf autoconf automake libtool make xorg-dev xutils-dev \
&& rm -rf /var/lib/apt/lists/*;
WORKDIR /xorg
COPY xorg/ /xorg/
# build xf86-video-dummy v0.3.8 with RandR support
RUN set -eux; \
cd xf86-video-dummy/v0.3.8; \
patch -p1 < ../01_v0.3.8_xdummy-randr.patch; \
autoreconf -v --install; \
./configure; \
make -j$(nproc); \
make install;
# build custom input driver
RUN set -eux; \
cd xf86-input-neko; \
./autogen.sh --prefix=/usr; \
./configure; \
make -j$(nproc); \
make install;
#
# Stage 1: Build.
#
FROM $BUILD_IMAGE as build
WORKDIR /src
#
# install dependencies
ENV DEBIAN_FRONTEND=noninteractive
RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends \
libx11-dev libxrandr-dev libxtst-dev libgtk-3-dev \
libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev; \
# install libxcvt-dev (not available in debian:bullseye)
wget http://ftp.de.debian.org/debian/pool/main/libx/libxcvt/libxcvt-dev_0.1.2-1_armhf.deb; \
wget http://ftp.de.debian.org/debian/pool/main/libx/libxcvt/libxcvt0_0.1.2-1_armhf.deb; \
apt-get install --no-install-recommends ./libxcvt0_0.1.2-1_armhf.deb ./libxcvt-dev_0.1.2-1_armhf.deb; \
#
# clean up
apt-get clean -y; \
rm -rf /var/lib/apt/lists/* /var/cache/apt/*
ARG GIT_COMMIT
ARG GIT_BRANCH
ARG GIT_TAG
#
# build server
COPY . .
RUN ./build
#
# Stage 2: Runtime.
#
FROM $BASE_IMAGE as runtime
FROM $BASE_IMAGE AS runtime
#
# set custom user
@ -144,24 +73,20 @@ RUN set -eux; \
apt-get clean -y; \
rm -rf /var/lib/apt/lists/* /var/cache/apt/*
# copy dependencies from previous stage
COPY --from=xorg-deps /usr/local/lib/xorg/modules/drivers/dummy_drv.so /usr/lib/xorg/modules/drivers/dummy_drv.so
COPY --from=xorg-deps /usr/local/lib/xorg/modules/input/neko_drv.so /usr/lib/xorg/modules/input/neko_drv.so
#
# copy runtime configs
COPY --chown=neko:neko runtime/.Xresources /home/$USERNAME/.Xresources
COPY runtime/dbus /usr/bin/dbus
COPY runtime/default.pa /etc/pulse/default.pa
COPY runtime/supervisord.conf /etc/neko/supervisord.conf
COPY runtime/supervisord.dbus.conf /etc/neko/supervisord.dbus.conf
COPY runtime/xorg.conf /etc/neko/xorg.conf
COPY --chown=neko:neko .Xresources /home/$USERNAME/.Xresources
COPY dbus /usr/bin/dbus
COPY default.pa /etc/pulse/default.pa
COPY supervisord.conf /etc/neko/supervisord.conf
COPY supervisord.dbus.conf /etc/neko/supervisord.dbus.conf
COPY xorg.conf /etc/neko/xorg.conf
#
# copy runtime folders
COPY --chown=neko:neko runtime/icon-theme /home/$USERNAME/.icons/default
COPY runtime/fontconfig/* /etc/fonts/conf.d/
COPY runtime/fonts /usr/local/share/fonts
COPY --chown=neko:neko icon-theme /home/$USERNAME/.icons/default
COPY fontconfig/* /etc/fonts/conf.d/
COPY fonts /usr/local/share/fonts
#
# set default envs
@ -173,14 +98,6 @@ ENV NEKO_SERVER_BIND=:8080
ENV NEKO_PLUGINS_ENABLED=true
ENV NEKO_PLUGINS_DIR=/etc/neko/plugins/
#
# copy plugins from previous stage
COPY --from=build /src/bin/plugins/ $NEKO_PLUGINS_DIR
#
# copy executable from previous stage
COPY --from=build /src/bin/neko /usr/bin/neko
#
# add healthcheck
HEALTHCHECK --interval=10s --timeout=5s --retries=8 \

102
runtime/Dockerfile.bookworm Normal file
View file

@ -0,0 +1,102 @@
ARG BASE_IMAGE=debian:bookworm-slim
FROM $BASE_IMAGE AS runtime
#
# set custom user
ARG USERNAME=neko
ARG USER_UID=1000
ARG USER_GID=$USER_UID
#
# install dependencies
ENV DEBIAN_FRONTEND=noninteractive
RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends \
wget ca-certificates supervisor \
pulseaudio xserver-xorg-video-dummy \
libcairo2 libxcb1 libxrandr2 libxv1 libopus0 libvpx7 libxcvt0 \
#
# needed for profile upload preStop hook
zip curl \
#
# file chooser handler, clipboard, drop
xdotool xclip libgtk-3-0 \
#
# gst
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; \
adduser $USERNAME audio; \
adduser $USERNAME video; \
adduser $USERNAME pulse; \
#
# 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 /var/log/neko \
/tmp/runtime-$USERNAME \
/home/$USERNAME/.config/pulse \
/home/$USERNAME/.local/share/xorg; \
chmod 1777 /var/log/neko; \
chown $USERNAME /var/log/neko/ /tmp/runtime-$USERNAME; \
chown -R $USERNAME:$USERNAME /home/$USERNAME; \
#
# install fonts
apt-get install -y --no-install-recommends \
# Emojis
fonts-noto-color-emoji \
# Chinese fonts
fonts-arphic-ukai fonts-arphic-uming \
fonts-wqy-zenhei xfonts-intl-chinese xfonts-wqy \
# Japanese fonts
fonts-ipafont-mincho fonts-ipafont-gothic \
fonts-takao-mincho \
# Korean fonts
fonts-unfonts-core \
fonts-wqy-microhei \
# Indian fonts
fonts-indic; \
#
# clean up
apt-get clean -y; \
rm -rf /var/lib/apt/lists/* /var/cache/apt/*
#
# copy runtime configs
COPY --chown=neko:neko .Xresources /home/$USERNAME/.Xresources
COPY default.pa /etc/pulse/default.pa
COPY supervisord.conf /etc/neko/supervisord.conf
COPY xorg.conf /etc/neko/xorg.conf
#
# copy runtime folders
COPY --chown=neko:neko icon-theme /home/$USERNAME/.icons/default
COPY fontconfig/* /etc/fonts/conf.d/
COPY fonts /usr/local/share/fonts
#
# set default envs
ENV USER=$USERNAME
ENV DISPLAY=:99.0
ENV PULSE_SERVER=unix:/tmp/pulseaudio.socket
ENV XDG_RUNTIME_DIR=/tmp/runtime-$USERNAME
ENV NEKO_SERVER_BIND=:8080
ENV NEKO_PLUGINS_ENABLED=true
ENV NEKO_PLUGINS_DIR=/etc/neko/plugins/
#
# add healthcheck
HEALTHCHECK --interval=10s --timeout=5s --retries=8 \
CMD wget -O - http://localhost:${NEKO_SERVER_BIND#*:}/health || exit 1
#
# run neko
CMD ["/usr/bin/supervisord", "-c", "/etc/neko/supervisord.conf"]

View file

@ -1,76 +1,5 @@
ARG BASE_IMAGE=debian:bullseye-slim
ARG BUILD_IMAGE=golang:1.21-bullseye
#
# Stage 0: Build xorg dependencies.
#
FROM $BASE_IMAGE as xorg-deps
ENV DEBIAN_FRONTEND=noninteractive
RUN set -eux; \
apt-get update; \
apt-get install -y \
git gcc pkgconf autoconf automake libtool make xorg-dev xutils-dev \
&& rm -rf /var/lib/apt/lists/*;
WORKDIR /xorg
COPY xorg/ /xorg/
# build xf86-video-dummy v0.3.8 with RandR support
RUN set -eux; \
cd xf86-video-dummy/v0.3.8; \
patch -p1 < ../01_v0.3.8_xdummy-randr.patch; \
autoreconf -v --install; \
./configure; \
make -j$(nproc); \
make install;
# build custom input driver
RUN set -eux; \
cd xf86-input-neko; \
./autogen.sh --prefix=/usr; \
./configure; \
make -j$(nproc); \
make install;
#
# Stage 1: Build.
#
FROM $BUILD_IMAGE as build
WORKDIR /src
#
# install dependencies
ENV DEBIAN_FRONTEND=noninteractive
RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends \
libx11-dev libxrandr-dev libxtst-dev libgtk-3-dev \
libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev; \
# install libxcvt-dev (not available in debian:bullseye)
wget http://ftp.de.debian.org/debian/pool/main/libx/libxcvt/libxcvt-dev_0.1.2-1_amd64.deb; \
wget http://ftp.de.debian.org/debian/pool/main/libx/libxcvt/libxcvt0_0.1.2-1_amd64.deb; \
apt-get install --no-install-recommends ./libxcvt0_0.1.2-1_amd64.deb ./libxcvt-dev_0.1.2-1_amd64.deb; \
#
# clean up
apt-get clean -y; \
rm -rf /var/lib/apt/lists/* /var/cache/apt/*
ARG GIT_COMMIT
ARG GIT_BRANCH
ARG GIT_TAG
#
# build server
COPY . .
RUN ./build
#
# Stage 2: Runtime.
#
FROM $BASE_IMAGE as runtime
FROM $BASE_IMAGE AS runtime
#
# set custom user
@ -152,26 +81,22 @@ RUN set -eux; \
apt-get clean -y; \
rm -rf /var/lib/apt/lists/* /var/cache/apt/*
# copy dependencies from previous stage
COPY --from=xorg-deps /usr/local/lib/xorg/modules/drivers/dummy_drv.so /usr/lib/xorg/modules/drivers/dummy_drv.so
COPY --from=xorg-deps /usr/local/lib/xorg/modules/input/neko_drv.so /usr/lib/xorg/modules/input/neko_drv.so
#
# copy runtime configs
COPY --chown=neko:neko runtime/.Xresources /home/$USERNAME/.Xresources
COPY runtime/dbus /usr/bin/dbus
COPY runtime/default.pa /etc/pulse/default.pa
COPY runtime/supervisord.conf /etc/neko/supervisord.conf
COPY runtime/supervisord.dbus.conf /etc/neko/supervisord.dbus.conf
COPY runtime/xorg.conf /etc/neko/xorg.conf
COPY runtime/intel/add-render-group.sh /usr/bin/add-render-group.sh
COPY runtime/intel/supervisord.rendergroup.conf /etc/neko/supervisord/supervisord.rendergroup.conf
COPY --chown=neko:neko .Xresources /home/$USERNAME/.Xresources
COPY dbus /usr/bin/dbus
COPY default.pa /etc/pulse/default.pa
COPY supervisord.conf /etc/neko/supervisord.conf
COPY supervisord.dbus.conf /etc/neko/supervisord.dbus.conf
COPY xorg.conf /etc/neko/xorg.conf
COPY intel/add-render-group.sh /usr/bin/add-render-group.sh
COPY intel/supervisord.rendergroup.conf /etc/neko/supervisord/supervisord.rendergroup.conf
#
# copy runtime folders
COPY --chown=neko:neko runtime/icon-theme /home/$USERNAME/.icons/default
COPY runtime/fontconfig/* /etc/fonts/conf.d/
COPY runtime/fonts /usr/local/share/fonts
COPY --chown=neko:neko icon-theme /home/$USERNAME/.icons/default
COPY fontconfig/* /etc/fonts/conf.d/
COPY fonts /usr/local/share/fonts
#
# set default envs
@ -185,14 +110,6 @@ ENV NEKO_PLUGINS_DIR=/etc/neko/plugins/
ENV NEKO_HWENC=VAAPI
ENV RENDER_GID=
#
# copy plugins from previous stage
COPY --from=build /src/bin/plugins/ $NEKO_PLUGINS_DIR
#
# copy executable from previous stage
COPY --from=build /src/bin/neko /usr/bin/neko
#
# add healthcheck
HEALTHCHECK --interval=10s --timeout=5s --retries=8 \

View file

@ -4,7 +4,7 @@ ARG VIRTUALGL_VERSION=3.1
ARG GSTREAMER_VERSION=1.20
#
# Stage 0: Build gstreamer with nvidia plugins.
# Stage 1: Build gstreamer with nvidia plugins.
#
FROM ubuntu:${UBUNTU_RELEASE} AS gstreamer
ARG GSTREAMER_VERSION
@ -53,76 +53,10 @@ RUN set -eux; \
ninja -C build; \
meson install -C build;
#
# Stage 0: Build xorg dependencies.
#
FROM debian:bullseye-slim as xorg-deps
ENV DEBIAN_FRONTEND=noninteractive
RUN set -eux; \
apt-get update; \
apt-get install -y \
git gcc pkgconf autoconf automake libtool make xorg-dev xutils-dev \
&& rm -rf /var/lib/apt/lists/*;
WORKDIR /xorg
COPY xorg/ /xorg/
# build xf86-video-dummy v0.3.8 with RandR support
RUN set -eux; \
cd xf86-video-dummy/v0.3.8; \
patch -p1 < ../01_v0.3.8_xdummy-randr.patch; \
autoreconf -v --install; \
./configure; \
make -j$(nproc); \
make install;
# build custom input driver
RUN set -eux; \
cd xf86-input-neko; \
./autogen.sh --prefix=/usr; \
./configure; \
make -j$(nproc); \
make install;
#
# Stage 1: Build.
#
FROM golang:1.21-bullseye as build
WORKDIR /src
#
# install dependencies
ENV DEBIAN_FRONTEND=noninteractive
RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends \
libx11-dev libxrandr-dev libxtst-dev libgtk-3-dev \
libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev; \
# install libxcvt-dev (not available in debian:bullseye)
wget http://ftp.de.debian.org/debian/pool/main/libx/libxcvt/libxcvt-dev_0.1.2-1_amd64.deb; \
wget http://ftp.de.debian.org/debian/pool/main/libx/libxcvt/libxcvt0_0.1.2-1_amd64.deb; \
apt-get install --no-install-recommends ./libxcvt0_0.1.2-1_amd64.deb ./libxcvt-dev_0.1.2-1_amd64.deb; \
#
# clean up
apt-get clean -y; \
rm -rf /var/lib/apt/lists/* /var/cache/apt/*
ARG GIT_COMMIT
ARG GIT_BRANCH
ARG GIT_TAG
#
# build server
COPY . .
RUN ./build
#
# Stage 2: Runtime.
#
FROM nvidia/cuda:${CUDA_VERSION}-runtime-ubuntu${UBUNTU_RELEASE} as runtime
FROM nvidia/cuda:${CUDA_VERSION}-runtime-ubuntu${UBUNTU_RELEASE} AS runtime
ARG UBUNTU_RELEASE
ARG VIRTUALGL_VERSION
@ -247,10 +181,6 @@ RUN set -eux; \
apt-get clean -y; \
rm -rf /var/lib/apt/lists/* /var/cache/apt/*
# copy dependencies from previous stage
COPY --from=xorg-deps /usr/local/lib/xorg/modules/drivers/dummy_drv.so /usr/lib/xorg/modules/drivers/dummy_drv.so
COPY --from=xorg-deps /usr/local/lib/xorg/modules/input/neko_drv.so /usr/lib/xorg/modules/input/neko_drv.so
#
# configure EGL and Vulkan manually
RUN VULKAN_API_VERSION=$(dpkg -s libvulkan1 | grep -oP 'Version: [0-9|\.]+' | grep -oP '[0-9]+(\.[0-9]+)(\.[0-9]+)') && \
@ -293,18 +223,18 @@ RUN set -eux; \
#
# copy runtime configs
COPY --chown=neko:neko runtime/.Xresources /home/$USERNAME/.Xresources
COPY runtime/dbus /usr/bin/dbus
COPY runtime/default.pa /etc/pulse/default.pa
COPY runtime/supervisord.conf /etc/neko/supervisord.conf
COPY runtime/supervisord.dbus.conf /etc/neko/supervisord.dbus.conf
COPY runtime/xorg.conf /etc/neko/xorg.conf
COPY --chown=neko:neko .Xresources /home/$USERNAME/.Xresources
COPY dbus /usr/bin/dbus
COPY default.pa /etc/pulse/default.pa
COPY supervisord.conf /etc/neko/supervisord.conf
COPY supervisord.dbus.conf /etc/neko/supervisord.dbus.conf
COPY xorg.conf /etc/neko/xorg.conf
#
# copy runtime folders
COPY --chown=neko:neko runtime/icon-theme /home/$USERNAME/.icons/default
COPY runtime/fontconfig/* /etc/fonts/conf.d/
COPY runtime/fonts /usr/local/share/fonts
COPY --chown=neko:neko icon-theme /home/$USERNAME/.icons/default
COPY fontconfig/* /etc/fonts/conf.d/
COPY fonts /usr/local/share/fonts
#
# set default envs
@ -323,17 +253,9 @@ ENV LD_LIBRARY_PATH="/usr/share/gstreamer/lib/x86_64-linux-gnu${LD_LIBRARY_PATH:
ENV PKG_CONFIG_PATH="/usr/share/gstreamer/lib/x86_64-linux-gnu/pkgconfig${PKG_CONFIG_PATH:+:${PKG_CONFIG_PATH}}"
#
# copy gstreamer from previous stage
# copy artifacts from previous stages
COPY --from=gstreamer /usr/share/gstreamer /usr/share/gstreamer
#
# copy plugins from previous stage
COPY --from=build /src/bin/plugins/ $NEKO_PLUGINS_DIR
#
# copy executable from previous stage
COPY --from=build /src/bin/neko /usr/bin/neko
#
# add healthcheck
HEALTHCHECK --interval=10s --timeout=5s --retries=8 \

View file

@ -4,7 +4,7 @@ ARG VIRTUALGL_VERSION=3.1
ARG GSTREAMER_VERSION=1.22
#
# Stage 0: Build gstreamer with nvidia plugins.
# Stage 1: Build gstreamer with nvidia plugins.
#
FROM ubuntu:${UBUNTU_RELEASE} AS gstreamer
ARG GSTREAMER_VERSION
@ -53,72 +53,10 @@ RUN set -eux; \
ninja -C build; \
meson install -C build;
#
# Stage 0: Build xorg dependencies.
#
FROM debian:bookworm-slim as xorg-deps
ENV DEBIAN_FRONTEND=noninteractive
RUN set -eux; \
apt-get update; \
apt-get install -y \
git gcc pkgconf autoconf automake libtool make xorg-dev xutils-dev \
&& rm -rf /var/lib/apt/lists/*;
WORKDIR /xorg
COPY xorg/ /xorg/
# build xf86-video-dummy v0.3.8 with RandR support
RUN set -eux; \
cd xf86-video-dummy/v0.3.8; \
patch -p1 < ../01_v0.3.8_xdummy-randr.patch; \
autoreconf -v --install; \
./configure; \
make -j$(nproc); \
make install;
# build custom input driver
RUN set -eux; \
cd xf86-input-neko; \
./autogen.sh --prefix=/usr; \
./configure; \
make -j$(nproc); \
make install;
#
# Stage 1: Build.
#
FROM golang:1.21-bookworm as build
WORKDIR /src
#
# install dependencies
ENV DEBIAN_FRONTEND=noninteractive
RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends \
libx11-dev libxrandr-dev libxtst-dev libgtk-3-dev libxcvt-dev \
libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev; \
#
# clean up
apt-get clean -y; \
rm -rf /var/lib/apt/lists/* /var/cache/apt/*
ARG GIT_COMMIT
ARG GIT_BRANCH
ARG GIT_TAG
#
# build server
COPY . .
RUN ./build
#
# Stage 2: Runtime.
#
FROM nvidia/cuda:${CUDA_VERSION}-runtime-ubuntu${UBUNTU_RELEASE} as runtime
FROM nvidia/cuda:${CUDA_VERSION}-runtime-ubuntu${UBUNTU_RELEASE} AS runtime
ARG UBUNTU_RELEASE
ARG VIRTUALGL_VERSION
@ -239,10 +177,6 @@ RUN set -eux; \
apt-get clean -y; \
rm -rf /var/lib/apt/lists/* /var/cache/apt/*
# copy dependencies from previous stage
COPY --from=xorg-deps /usr/local/lib/xorg/modules/drivers/dummy_drv.so /usr/lib/xorg/modules/drivers/dummy_drv.so
COPY --from=xorg-deps /usr/local/lib/xorg/modules/input/neko_drv.so /usr/lib/xorg/modules/input/neko_drv.so
#
# configure EGL and Vulkan manually
RUN VULKAN_API_VERSION=$(dpkg -s libvulkan1 | grep -oP 'Version: [0-9|\.]+' | grep -oP '[0-9]+(\.[0-9]+)(\.[0-9]+)') && \
@ -285,16 +219,16 @@ RUN set -eux; \
#
# copy runtime configs
COPY --chown=neko:neko runtime/.Xresources /home/$USERNAME/.Xresources
COPY runtime/default.pa /etc/pulse/default.pa
COPY runtime/supervisord.conf /etc/neko/supervisord.conf
COPY runtime/xorg.conf /etc/neko/xorg.conf
COPY --chown=neko:neko .Xresources /home/$USERNAME/.Xresources
COPY default.pa /etc/pulse/default.pa
COPY supervisord.conf /etc/neko/supervisord.conf
COPY xorg.conf /etc/neko/xorg.conf
#
# copy runtime folders
COPY --chown=neko:neko runtime/icon-theme /home/$USERNAME/.icons/default
COPY runtime/fontconfig/* /etc/fonts/conf.d/
COPY runtime/fonts /usr/local/share/fonts
COPY --chown=neko:neko icon-theme /home/$USERNAME/.icons/default
COPY fontconfig/* /etc/fonts/conf.d/
COPY fonts /usr/local/share/fonts
#
# set default envs
@ -312,18 +246,11 @@ ENV PATH="/usr/share/gstreamer/bin:${PATH}"
ENV LD_LIBRARY_PATH="/usr/share/gstreamer/lib/x86_64-linux-gnu${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}"
ENV PKG_CONFIG_PATH="/usr/share/gstreamer/lib/x86_64-linux-gnu/pkgconfig${PKG_CONFIG_PATH:+:${PKG_CONFIG_PATH}}"
#
# copy gstreamer from previous stage
# copy artifacts from previous stages
COPY --from=gstreamer /usr/share/gstreamer /usr/share/gstreamer
#
# copy plugins from previous stage
COPY --from=build /src/bin/plugins/ $NEKO_PLUGINS_DIR
#
# copy executable from previous stage
COPY --from=build /src/bin/neko /usr/bin/neko
#
# add healthcheck
HEALTHCHECK --interval=10s --timeout=5s --retries=8 \

View file

@ -0,0 +1,34 @@
ARG BASE_IMAGE=debian:bullseye-slim
FROM $BASE_IMAGE AS xorg-deps
WORKDIR /xorg
ENV DEBIAN_FRONTEND=noninteractive
RUN set -eux; \
apt-get update; \
apt-get install -y \
git gcc pkgconf autoconf automake libtool make xorg-dev xutils-dev \
&& rm -rf /var/lib/apt/lists/*;
COPY . /xorg/
# build xf86-video-dummy v0.3.8 with RandR support
RUN set -eux; \
cd xf86-video-dummy/v0.3.8; \
patch -p1 < ../01_v0.3.8_xdummy-randr.patch; \
autoreconf -v --install; \
./configure; \
make -j$(nproc); \
make install;
# build custom input driver
RUN set -eux; \
cd xf86-input-neko; \
./autogen.sh --prefix=/usr; \
./configure; \
make -j$(nproc); \
make install;
# artifacts from this stage
# COPY --from=xorg-deps /usr/local/lib/xorg/modules/drivers/dummy_drv.so /usr/lib/xorg/modules/drivers/dummy_drv.so
# COPY --from=xorg-deps /usr/local/lib/xorg/modules/input/neko_drv.so /usr/lib/xorg/modules/input/neko_drv.so

10
server/.gitignore vendored
View file

@ -1,12 +1,2 @@
bin/
.idea
.env.development
runtime/fonts/*
!runtime/fonts/.gitkeep
runtime/icon-theme/*
!runtime/icon-theme/.gitkeep
plugins/*
!plugins/.gitkeep

View file

@ -1,44 +1,6 @@
ARG BASE_IMAGE=debian:bullseye-slim
ARG BUILD_IMAGE=golang:1.21-bullseye
ARG BASE_IMAGE=golang:1.21-bullseye
FROM $BASE_IMAGE AS server
#
# Stage 0: Build xorg dependencies.
#
FROM $BASE_IMAGE as xorg-deps
ENV DEBIAN_FRONTEND=noninteractive
RUN set -eux; \
apt-get update; \
apt-get install -y \
git gcc pkgconf autoconf automake libtool make xorg-dev xutils-dev \
&& rm -rf /var/lib/apt/lists/*;
WORKDIR /xorg
COPY xorg/ /xorg/
# build xf86-video-dummy v0.3.8 with RandR support
RUN set -eux; \
cd xf86-video-dummy/v0.3.8; \
patch -p1 < ../01_v0.3.8_xdummy-randr.patch; \
autoreconf -v --install; \
./configure; \
make -j$(nproc); \
make install;
# build custom input driver
RUN set -eux; \
cd xf86-input-neko; \
./autogen.sh --prefix=/usr; \
./configure; \
make -j$(nproc); \
make install;
#
# Stage 1: Build.
#
FROM $BUILD_IMAGE as build
WORKDIR /src
#
@ -68,124 +30,6 @@ COPY . .
RUN ./build
#
# Stage 2: Runtime.
#
FROM $BASE_IMAGE as runtime
#
# set custom user
ARG USERNAME=neko
ARG USER_UID=1000
ARG USER_GID=$USER_UID
#
# install dependencies
ENV DEBIAN_FRONTEND=noninteractive
RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends \
wget ca-certificates supervisor \
pulseaudio dbus-x11 xserver-xorg-video-dummy \
libcairo2 libxcb1 libxrandr2 libxv1 libopus0 libvpx6 \
#
# needed for profile upload preStop hook
zip curl \
#
# file chooser handler, clipboard, drop
xdotool xclip libgtk-3-0 \
#
# gst
gstreamer1.0-plugins-base gstreamer1.0-plugins-good \
gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly \
gstreamer1.0-pulseaudio; \
# install libxcvt0 (not available in debian:bullseye)
wget http://ftp.de.debian.org/debian/pool/main/libx/libxcvt/libxcvt0_0.1.2-1_amd64.deb; \
apt-get install --no-install-recommends ./libxcvt0_0.1.2-1_amd64.deb; \
rm ./libxcvt0_0.1.2-1_amd64.deb; \
#
# create a 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; \
#
# 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 /var/log/neko \
/tmp/runtime-$USERNAME \
/home/$USERNAME/.config/pulse \
/home/$USERNAME/.local/share/xorg; \
chmod 1777 /var/log/neko; \
chown $USERNAME /var/log/neko/ /tmp/runtime-$USERNAME; \
chown -R $USERNAME:$USERNAME /home/$USERNAME; \
#
# install fonts
apt-get install -y --no-install-recommends \
# Emojis
fonts-noto-color-emoji \
# Chinese fonts
fonts-arphic-ukai fonts-arphic-uming \
fonts-wqy-zenhei xfonts-intl-chinese xfonts-wqy \
# Japanese fonts
fonts-ipafont-mincho fonts-ipafont-gothic \
fonts-takao-mincho \
# Korean fonts
fonts-unfonts-core \
fonts-wqy-microhei \
# Indian fonts
fonts-indic; \
#
# clean up
apt-get clean -y; \
rm -rf /var/lib/apt/lists/* /var/cache/apt/*
# copy dependencies from previous stage
COPY --from=xorg-deps /usr/local/lib/xorg/modules/drivers/dummy_drv.so /usr/lib/xorg/modules/drivers/dummy_drv.so
COPY --from=xorg-deps /usr/local/lib/xorg/modules/input/neko_drv.so /usr/lib/xorg/modules/input/neko_drv.so
#
# copy runtime configs
COPY --chown=neko:neko runtime/.Xresources /home/$USERNAME/.Xresources
COPY runtime/dbus /usr/bin/dbus
COPY runtime/default.pa /etc/pulse/default.pa
COPY runtime/supervisord.conf /etc/neko/supervisord.conf
COPY runtime/supervisord.dbus.conf /etc/neko/supervisord.dbus.conf
COPY runtime/xorg.conf /etc/neko/xorg.conf
#
# copy runtime folders
COPY --chown=neko:neko runtime/icon-theme /home/$USERNAME/.icons/default
COPY runtime/fontconfig/* /etc/fonts/conf.d/
COPY runtime/fonts /usr/local/share/fonts
#
# set default envs
ENV USER=$USERNAME
ENV DISPLAY=:99.0
ENV PULSE_SERVER=unix:/tmp/pulseaudio.socket
ENV XDG_RUNTIME_DIR=/tmp/runtime-$USERNAME
ENV NEKO_SERVER_BIND=:8080
ENV NEKO_PLUGINS_ENABLED=true
ENV NEKO_PLUGINS_DIR=/etc/neko/plugins/
#
# copy plugins from previous stage
COPY --from=build /src/bin/plugins/ $NEKO_PLUGINS_DIR
#
# copy executable from previous stage
COPY --from=build /src/bin/neko /usr/bin/neko
#
# add healthcheck
HEALTHCHECK --interval=10s --timeout=5s --retries=8 \
CMD wget -O - http://localhost:${NEKO_SERVER_BIND#*:}/health || exit 1
#
# run neko
CMD ["/usr/bin/supervisord", "-c", "/etc/neko/supervisord.conf"]
# artifacts from this stage
# COPY --from=server /src/bin/plugins/ $NEKO_PLUGINS_DIR
# COPY --from=server /src/bin/neko /usr/bin/neko

View file

@ -1,44 +1,6 @@
ARG BASE_IMAGE=debian:bookworm-slim
ARG BUILD_IMAGE=golang:1.21-bookworm
ARG BASE_IMAGE=golang:1.21-bookworm
FROM $BASE_IMAGE AS server
#
# Stage 0: Build xorg dependencies.
#
FROM $BASE_IMAGE as xorg-deps
ENV DEBIAN_FRONTEND=noninteractive
RUN set -eux; \
apt-get update; \
apt-get install -y \
git gcc pkgconf autoconf automake libtool make xorg-dev xutils-dev \
&& rm -rf /var/lib/apt/lists/*;
WORKDIR /xorg
COPY xorg/ /xorg/
# build xf86-video-dummy v0.3.8 with RandR support
RUN set -eux; \
cd xf86-video-dummy/v0.3.8; \
patch -p1 < ../01_v0.3.8_xdummy-randr.patch; \
autoreconf -v --install; \
./configure; \
make -j$(nproc); \
make install;
# build custom input driver
RUN set -eux; \
cd xf86-input-neko; \
./autogen.sh --prefix=/usr; \
./configure; \
make -j$(nproc); \
make install;
#
# Stage 1: Build.
#
FROM $BUILD_IMAGE as build
WORKDIR /src
#
@ -64,118 +26,6 @@ COPY . .
RUN ./build
#
# Stage 2: Runtime.
#
FROM $BASE_IMAGE as runtime
#
# set custom user
ARG USERNAME=neko
ARG USER_UID=1000
ARG USER_GID=$USER_UID
#
# install dependencies
ENV DEBIAN_FRONTEND=noninteractive
RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends \
wget ca-certificates supervisor \
pulseaudio xserver-xorg-video-dummy \
libcairo2 libxcb1 libxrandr2 libxv1 libopus0 libvpx7 libxcvt0 \
#
# needed for profile upload preStop hook
zip curl \
#
# file chooser handler, clipboard, drop
xdotool xclip libgtk-3-0 \
#
# gst
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; \
adduser $USERNAME audio; \
adduser $USERNAME video; \
adduser $USERNAME pulse; \
#
# 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 /var/log/neko \
/tmp/runtime-$USERNAME \
/home/$USERNAME/.config/pulse \
/home/$USERNAME/.local/share/xorg; \
chmod 1777 /var/log/neko; \
chown $USERNAME /var/log/neko/ /tmp/runtime-$USERNAME; \
chown -R $USERNAME:$USERNAME /home/$USERNAME; \
#
# install fonts
apt-get install -y --no-install-recommends \
# Emojis
fonts-noto-color-emoji \
# Chinese fonts
fonts-arphic-ukai fonts-arphic-uming \
fonts-wqy-zenhei xfonts-intl-chinese xfonts-wqy \
# Japanese fonts
fonts-ipafont-mincho fonts-ipafont-gothic \
fonts-takao-mincho \
# Korean fonts
fonts-unfonts-core \
fonts-wqy-microhei \
# Indian fonts
fonts-indic; \
#
# clean up
apt-get clean -y; \
rm -rf /var/lib/apt/lists/* /var/cache/apt/*
# copy dependencies from previous stage
COPY --from=xorg-deps /usr/local/lib/xorg/modules/drivers/dummy_drv.so /usr/lib/xorg/modules/drivers/dummy_drv.so
COPY --from=xorg-deps /usr/local/lib/xorg/modules/input/neko_drv.so /usr/lib/xorg/modules/input/neko_drv.so
#
# copy runtime configs
COPY --chown=neko:neko runtime/.Xresources /home/$USERNAME/.Xresources
COPY runtime/default.pa /etc/pulse/default.pa
COPY runtime/supervisord.conf /etc/neko/supervisord.conf
COPY runtime/xorg.conf /etc/neko/xorg.conf
#
# copy runtime folders
COPY --chown=neko:neko runtime/icon-theme /home/$USERNAME/.icons/default
COPY runtime/fontconfig/* /etc/fonts/conf.d/
COPY runtime/fonts /usr/local/share/fonts
#
# set default envs
ENV USER=$USERNAME
ENV DISPLAY=:99.0
ENV PULSE_SERVER=unix:/tmp/pulseaudio.socket
ENV XDG_RUNTIME_DIR=/tmp/runtime-$USERNAME
ENV NEKO_SERVER_BIND=:8080
ENV NEKO_PLUGINS_ENABLED=true
ENV NEKO_PLUGINS_DIR=/etc/neko/plugins/
#
# copy plugins from previous stage
COPY --from=build /src/bin/plugins/ $NEKO_PLUGINS_DIR
#
# copy executable from previous stage
COPY --from=build /src/bin/neko /usr/bin/neko
#
# add healthcheck
HEALTHCHECK --interval=10s --timeout=5s --retries=8 \
CMD wget -O - http://localhost:${NEKO_SERVER_BIND#*:}/health || exit 1
#
# run neko
CMD ["/usr/bin/supervisord", "-c", "/etc/neko/supervisord.conf"]
# artifacts from this stage
# COPY --from=server /src/bin/plugins/ $NEKO_PLUGINS_DIR
# COPY --from=server /src/bin/neko /usr/bin/neko

View file

@ -8,19 +8,10 @@ set -e
GIT_COMMIT=`git rev-parse --short HEAD`
GIT_BRANCH=`git rev-parse --symbolic-full-name --abbrev-ref HEAD`
# if first argument is nvidia, use nvidia dockerfile
if [ "$1" = "nvidia" ]; then
echo "Building nvidia docker image"
DOCKERFILE="Dockerfile.nvidia"
elif [ "$1" = "intel" ]; then
echo "Building intel docker image"
DOCKERFILE="Dockerfile.intel"
else
echo "Building default docker image"
DOCKERFILE="Dockerfile"
fi
echo "Building server image"
docker build -t neko_server --build-arg "GIT_COMMIT=$GIT_COMMIT" --build-arg "GIT_BRANCH=$GIT_BRANCH" -f ../Dockerfile ..
docker build -t neko_server_build --target build --build-arg "GIT_COMMIT=$GIT_COMMIT" --build-arg "GIT_BRANCH=$GIT_BRANCH" -f ../$DOCKERFILE ..
docker build -t neko_server_runtime --target runtime --build-arg "GIT_COMMIT=$GIT_COMMIT" --build-arg "GIT_BRANCH=$GIT_BRANCH" -f ../$DOCKERFILE ..
BUILD_IMAGE=neko_server FLAVOUR=$1 ../../build
docker build -t neko_server_app --build-arg "BASE_IMAGE=neko_server_runtime" -f ./runtime/Dockerfile ./runtime
echo "Building app image"
docker build -t neko_server:app --build-arg "BASE_IMAGE=neko_server:base" -f ./runtime/Dockerfile ./runtime

View file

@ -1,12 +1,12 @@
#!/bin/bash
cd "$(dirname "$0")"
if [ "$(docker images -q neko_server_build 2> /dev/null)" == "" ]; then
echo "Image 'neko_server_build' not found. Run ./build first."
if [ "$(docker images -q neko_server 2> /dev/null)" == "" ]; then
echo "Image 'neko_server' not found. Run ./build first."
exit 1
fi
docker run -it --rm \
--entrypoint="go" \
-v "${PWD}/../:/src" \
neko_server_build fmt ./...
neko_server fmt ./...

View file

@ -1,8 +1,8 @@
#!/bin/bash
cd "$(dirname "$0")"
if [ "$(docker images -q neko_server_build 2> /dev/null)" == "" ]; then
echo "Image 'neko_server_build' not found. Run ./build first."
if [ "$(docker images -q neko_server 2> /dev/null)" == "" ]; then
echo "Image 'neko_server' not found. Run ./build first."
exit 1
fi
@ -10,7 +10,7 @@ docker run -it \
--name "neko_server_go" \
--entrypoint="go" \
-v "${PWD}/../:/src" \
neko_server_build "$@";
neko_server "$@";
#
# copy package files
docker cp neko_server_go:/src/go.mod "../go.mod"
@ -18,7 +18,7 @@ docker cp neko_server_go:/src/go.sum "../go.sum"
#
# commit changes to image
docker commit "neko_server_go" "neko_server_build"
docker commit "neko_server_go" "neko_server"
#
# remove contianer

View file

@ -1,8 +1,8 @@
#!/bin/bash
cd "$(dirname "$0")"
if [ "$(docker images -q neko_server_build 2> /dev/null)" == "" ]; then
echo "Image 'neko_server_build' not found. Run ./build first."
if [ "$(docker images -q neko_server 2> /dev/null)" == "" ]; then
echo "Image 'neko_server' not found. Run ./build first."
exit 1
fi
@ -11,4 +11,4 @@ fi
docker run --rm -it \
-v "${PWD}/../:/src" \
--entrypoint="/bin/bash" \
neko_server_build -c '[ -f ./bin/golangci-lint ] || curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.31.0;./bin/golangci-lint run';
neko_server -c '[ -f ./bin/golangci-lint ] || curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.31.0;./bin/golangci-lint run';

View file

@ -10,7 +10,7 @@ set -e
docker run --rm -it \
-v "${PWD}/../:/src" \
--entrypoint="/bin/bash" \
neko_server_build "./build" "$@";
neko_server "./build" "$@";
#
# remove old plugins

View file

@ -1,6 +1,6 @@
#!/bin/bash
cd "$(dirname "$0")"
cd ../xorg/xf86-input-neko
cd ../../runtime/xorg-deps/xf86-input-neko
#
# aborting if any command returns a non-zero value

View file

@ -1,4 +1,4 @@
ARG BASE_IMAGE=neko_server_runtime:latest
ARG BASE_IMAGE=neko_server:base
FROM $BASE_IMAGE
ARG SRC_URL="https://download.mozilla.org/?product=firefox-latest&os=linux64&lang=en-US"

View file

@ -1,8 +1,8 @@
#!/bin/bash
cd "$(dirname "$0")"
if [ -z "$(docker images -q neko_server_app 2> /dev/null)" ]; then
echo "Image 'neko_server_app' not found. Running ./build first."
if [ -z "$(docker images -q neko_server:app 2> /dev/null)" ]; then
echo "Image 'neko_server:app' not found. Running ./build first."
./build
fi
@ -66,4 +66,4 @@ docker run --rm -it \
--shm-size=2G \
--security-opt seccomp=unconfined \
$EXTRAOPTS \
neko_server_app:latest;
neko_server:app;