diff --git a/.dockerignore b/.dockerignore index 941fc694..af3034f0 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,5 +1,33 @@ +.idea/ +.github/ +.git/ +.gitattributes +.gitignore +LICENSE +README.md .yarn/cache/ .yarn/install-state.gz -libs/xtsb/node_modules -libs/xtsb/dist -.idea \ No newline at end of file +libs/compositor-proxy-generator/node_modules/ +libs/compositor-proxy-generator/.gitignore +libs/compositor-proxy-generator/LICENSE +libs/xtsb/node_modules/ +libs/xtsb/dist/ +libs/xtsb/xcbgen/ +libs/xtsb/test/ +libs/xtsb/protocol/ +libs/xtsb/.prettierrc.js +libs/xtsb/LICENSE +libs/xtsb/README.md +packages/compositor-proxy/build/ +packages/compositor-proxy/dist/ +packages/compositor-proxy/node_modules/ +packages/compositor-proxy/types/ +packages/compositor-proxy/.eslintrc.js +packages/compositor-proxy/.prettierrc.js +packages/compositor-proxy/jest.config.js +packages/compositor-proxy-cli/dist/ +packages/compositor-proxy-cli/node_modules/ +packages/compositor-proxy-cli/.eslintrc.js +packages/compositor-proxy-cli/.prettierrc.js +packages/compositor-proxy-cli/.gitignore +packages/compositor-proxy-cli/example-applications.json diff --git a/docker-build.sh b/docker-build.sh deleted file mode 100755 index 38788d64..00000000 --- a/docker-build.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash -set -e -set -x - -tag_postfix=$(date +%Y%m%d) -tag="docker.io/udevbe/compositor-proxy:${tag_postfix}" - -docker build --pull . -t "${tag}" -docker push "${tag}" - -printf "Build and pushed %s" "${tag}" diff --git a/10_nvidia.json b/docker/10_nvidia.json similarity index 100% rename from 10_nvidia.json rename to docker/10_nvidia.json diff --git a/Dockerfile b/docker/Dockerfile similarity index 67% rename from Dockerfile rename to docker/Dockerfile index af97e7df..aed4ce64 100644 --- a/Dockerfile +++ b/docker/Dockerfile @@ -1,5 +1,27 @@ # syntax=docker/dockerfile:1 -FROM debian:bookworm-20231009-slim as BUILD +FROM debian:bookworm-20231030-slim as BUILD + +ENV NODE_VERSION="v20.9.0" +ENV NODE_DISTRO="linux-x64" + +WORKDIR /app + +COPY ["package.json", "yarn.lock", ".yarnrc.yml", "./"] +COPY [".yarn/", "./.yarn/"] +COPY ["libs/xtsb/package.json", "./libs/xtsb/package.json"] +COPY ["libs/compositor-proxy-generator/package.json", "./libs/compositor-proxy-generator/package.json"] +COPY ["packages/compositor-proxy/package.json", "./packages/compositor-proxy/package.json"] +COPY ["packages/compositor-proxy-cli/package.json", "./packages/compositor-proxy-cli/package.json"] + +COPY ["libs/xtsb/tsconfig.json", "libs/xtsb/tsconfig.node.json", "./libs/xtsb/"] +COPY ["libs/xtsb/src/", "./libs/xtsb/src/"] + +COPY ["packages/compositor-proxy/tsconfig.json", "packages/compositor-proxy/CMakeLists.txt", "./packages/compositor-proxy/"] +COPY ["packages/compositor-proxy/native/", "./packages/compositor-proxy/native/"] +COPY ["packages/compositor-proxy/src/", "./packages/compositor-proxy/src/"] + +COPY ["packages/compositor-proxy-cli/tsconfig.json", "./packages/compositor-proxy-cli/"] +COPY ["packages/compositor-proxy-cli/src/", "./packages/compositor-proxy-cli/src/"] RUN apt-get update && apt-get install -y --no-install-recommends \ cmake \ @@ -28,65 +50,44 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ pipx \ && apt-get autoremove -y \ && apt-get clean \ - && rm -rf /var/lib/apt/lists/* -RUN git clone --depth 1 --branch 1.20 https://gitlab.freedesktop.org/gstreamer/gstreamer.git -RUN cd /gstreamer \ - && pipx run meson build \ - --buildtype=release \ - --strip \ - -Dgpl=enabled \ - -Dorc=enabled \ - -Dbase=enabled \ - -Dgood=enabled \ - -Dbad=enabled \ - -Dugly=enabled \ - -Dauto_features=disabled \ - -Dgst-plugins-base:app=enabled \ - -Dgst-plugins-base:gl=enabled \ - -Dgst-plugins-base:gl-graphene=enabled \ - -Dgst-plugins-base:gl_winsys=egl \ - -Dgst-plugins-base:gl_api=opengl \ - -Dgst-plugins-bad:gl=enabled \ - -Dgst-plugins-bad:nvcodec=enabled \ + && rm -rf /var/lib/apt/lists/* \ + && git clone --depth 1 --branch 1.20 https://gitlab.freedesktop.org/gstreamer/gstreamer.git \ + && cd gstreamer \ + && pipx run meson build \ + --buildtype=release \ + --strip \ + -Dgpl=enabled \ + -Dorc=enabled \ + -Dbase=enabled \ + -Dgood=enabled \ + -Dbad=enabled \ + -Dugly=enabled \ + -Dauto_features=disabled \ + -Dgst-plugins-base:app=enabled \ + -Dgst-plugins-base:gl=enabled \ + -Dgst-plugins-base:gl-graphene=enabled \ + -Dgst-plugins-base:gl_winsys=egl \ + -Dgst-plugins-base:gl_api=opengl \ + -Dgst-plugins-bad:gl=enabled \ + -Dgst-plugins-bad:nvcodec=enabled \ && ninja -C build - -ENV NODE_VERSION="v20.9.0" -ENV NODE_DISTRO="linux-x64" -RUN curl https://nodejs.org/dist/$NODE_VERSION/node-$NODE_VERSION-$NODE_DISTRO.tar.xz --output node-$NODE_VERSION-$NODE_DISTRO.tar.xz -RUN tar xvf node-$NODE_VERSION-$NODE_DISTRO.tar.xz -ENV PATH="/node-$NODE_VERSION-$NODE_DISTRO/bin:$PATH" -RUN corepack enable - -WORKDIR /app -COPY ["package.json", "yarn.lock", ".yarnrc.yml", "./"] -COPY [".yarn/", "./.yarn/"] -COPY ["libs/xtsb/package.json", "./libs/xtsb/package.json"] -COPY ["libs/compositor-proxy-generator/package.json", "./libs/compositor-proxy-generator/package.json"] -COPY ["packages/compositor-proxy/package.json", "./packages/compositor-proxy/package.json"] -COPY ["packages/compositor-proxy-cli/package.json", "./packages/compositor-proxy-cli/package.json"] -RUN yarn install - -COPY ["libs/xtsb/protocol", "libs/xtsb/tsconfig.json", "libs/xtsb/tsconfig.node.json", "./libs/xtsb/"] -COPY ["libs/xtsb/src/", "./libs/xtsb/src/"] -RUN yarn workspace @gfld/xtsb build - -COPY ["packages/compositor-proxy/tsconfig.json", "packages/compositor-proxy/CMakeLists.txt", "./packages/compositor-proxy/"] -COPY ["packages/compositor-proxy/native/", "./packages/compositor-proxy/native/"] -COPY ["packages/compositor-proxy/src/", "./packages/compositor-proxy/src/"] -RUN yarn workspace @gfld/compositor-proxy build - -COPY ["packages/compositor-proxy-cli/tsconfig.json", "./packages/compositor-proxy-cli/"] -COPY ["packages/compositor-proxy-cli/src/", "./packages/compositor-proxy-cli/src/"] -RUN yarn workspace @gfld/compositor-proxy-cli build -RUN yarn workspace @gfld/compositor-proxy-cli package +RUN curl https://nodejs.org/dist/$NODE_VERSION/node-$NODE_VERSION-$NODE_DISTRO.tar.xz --output node-$NODE_VERSION-$NODE_DISTRO.tar.xz \ + && tar xvf node-$NODE_VERSION-$NODE_DISTRO.tar.xz +ENV PATH="/app/node-$NODE_VERSION-$NODE_DISTRO/bin:$PATH" +RUN corepack enable \ + && yarn install \ + && yarn workspace @gfld/xtsb build \ + && yarn workspace @gfld/compositor-proxy build \ + && yarn workspace @gfld/compositor-proxy-cli build \ + && yarn workspace @gfld/compositor-proxy-cli package FROM debian:bookworm-20231030-slim -COPY --from=BUILD /gstreamer/build/subprojects/gst-plugins-bad/sys/nvcodec/libgstnvcodec.so /usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgstnvcodec.so -COPY 10_nvidia.json /usr/share/glvnd/egl_vendor.d/10_nvidia.json +COPY --from=BUILD /app/gstreamer/build/subprojects/gst-plugins-bad/sys/nvcodec/libgstnvcodec.so /usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgstnvcodec.so +COPY docker/10_nvidia.json /usr/share/glvnd/egl_vendor.d/10_nvidia.json WORKDIR /app COPY --from=BUILD /app/packages/compositor-proxy-cli/package/* . -COPY docker-entrypoint.sh . +COPY docker/docker-entrypoint.sh . COPY packages/compositor-proxy-cli/wait-until-ready.sh . RUN sed -i'' -e 's/main$/main contrib non-free/g' /etc/apt/sources.list.d/debian.sources \ diff --git a/docker/docker-build.sh b/docker/docker-build.sh new file mode 100755 index 00000000..c1996cf9 --- /dev/null +++ b/docker/docker-build.sh @@ -0,0 +1,9 @@ +#!/bin/bash +set -e +set -x + +tag_postfix=$(date +%Y%m%d) +tag="docker.io/udevbe/compositor-proxy-cli:${tag_postfix}" + +docker build --pull .. -t "${tag}" -f Dockerfile +printf "Build complete %s\n" "${tag}" diff --git a/docker-compose.yml b/docker/docker-compose.yml similarity index 93% rename from docker-compose.yml rename to docker/docker-compose.yml index 887c5e5a..f443c8c3 100644 --- a/docker-compose.yml +++ b/docker/docker-compose.yml @@ -6,7 +6,7 @@ services: compositor-proxy: # runtime: nvidia build: - context: packages/compositor-proxy-cli + context: ../packages/compositor-proxy-cli dockerfile: Dockerfile command: - --session-id=test123 @@ -35,7 +35,7 @@ services: # runtime: nvidia pid: 'service:compositor-proxy' build: - context: examples/docker-apps/gtk3-demo + context: ../examples/docker-apps/gtk3-demo dockerfile: packages/compositor-proxy-cli/example-apps/gtk3-demo/Dockerfile privileged: false user: "1000:1000" @@ -53,7 +53,7 @@ services: # runtime: nvidia pid: 'service:compositor-proxy' build: - context: examples/docker-apps/gtk4-demo + context: ../examples/docker-apps/gtk4-demo dockerfile: packages/compositor-proxy-cli/example-apps/gtk4-demo/Dockerfile privileged: false user: "1000:1000" @@ -71,7 +71,7 @@ services: # runtime: nvidia pid: 'service:compositor-proxy' build: - context: examples/docker-apps/alacritty + context: ../examples/docker-apps/alacritty dockerfile: packages/compositor-proxy-cli/example-apps/alacritty/Dockerfile privileged: false user: "1000:1000" @@ -90,7 +90,7 @@ services: # runtime: nvidia pid: 'service:compositor-proxy' build: - context: examples/docker-apps/xterm + context: ../examples/docker-apps/xterm dockerfile: packages/compositor-proxy-cli/example-apps/xterm/Dockerfile privileged: false user: "1000:1000" @@ -111,7 +111,7 @@ services: # runtime: nvidia pid: 'service:compositor-proxy' build: - context: examples/docker-apps/glxgears + context: ../examples/docker-apps/glxgears dockerfile: packages/compositor-proxy-cli/example-apps/glxgears/Dockerfile ipc: host privileged: false diff --git a/docker-entrypoint.sh b/docker/docker-entrypoint.sh similarity index 100% rename from docker-entrypoint.sh rename to docker/docker-entrypoint.sh diff --git a/packages/compositor-proxy/README.md b/packages/compositor-proxy/README.md deleted file mode 100644 index 21121131..00000000 --- a/packages/compositor-proxy/README.md +++ /dev/null @@ -1,59 +0,0 @@ -# Usage - -## Development - -- `yarn install` -- `yarn generate` -- `yarn build:native` -- `cp dist/encoding/proxy-encoding-addon.node src/encoding/proxy-encoding-addon.node` -- `cp dist/proxy-poll-addon.node src/proxy-poll-addon.node` - -and finally -- `yarn start` - -You should now see something that says `Compositor proxy started. Listening on port 8081`. - -## Production build - -- `yarn install` -- `yarn generate` -- `yarn build` -- `yarn package` - -This creates a set of files in the `package` directory, to start simply run the `run.sh` script inside. - -There is also a docker image available `docker.io/udevbe/compositor-proxy` that you can use as well as an example docker compose file with some applications. -This docker compose file only runs the compositor-proxy as well as some extra containerized applications. You still need to run a compositor-module separately to connect to -this compositor-proxy. - -## Options -The `run.sh` script accepts several arguments: - -``` -Usage - $ compositor-proxy - -Options - --basic-auth=USER:PASSWORD Basic auth credentials to use when securing this proxy. - Optional. - --bind-ip=IP The ip or hostname to listen on. - Optional. Default: "0.0.0.0". - --bind-port=PORT The port to listen on. - Optional. Default "8081". - --allow-origin=ORIGIN CORS allowed client origins, used when doing cross-origin requests. Value can be comma seperated domains. - Optional. Default "localhost:8080". - --base-url=URL The public base url to use when other services connect to this endpoint. - Optional. Default "ws://localhost:8081". - --render-device=PATH Path of the render device that should be used for hardware acceleration. - Optional. Default "/dev/dri/renderD128". - --encoder=ENCODER The h264 encoder to use. "x264", "nvh264" and "vaapih264" are supported. - "x264" is a pure software encoder. "nvh264" is a hw accelerated encoder for Nvidia based GPUs. - "vaapih264" is an experimental encoder for intel GPUs. - Optional. Default "x264". - --application=NAME:EXECUTABLE_PATH:HTTP_PATH Maps an application with NAME and EXECUTABLE_PATH to an HTTP_PATH. This option can be repeated - with different values to map multiple applications. - Optional. Default: "gtk4-demo:/gtk4-demo:/usr/bin/gtk4-demo". - --help, -h Print this help text. - - The environment variable "LOG_LEVEL" is used to set the logging level. Accepted values are: "fatal", "error", "warn", "info", "debug", "trace" -```