From 349b22743a0cdccfea8eedfce445009a2c2e20e5 Mon Sep 17 00:00:00 2001 From: "Victor A." <52110451+cs50victor@users.noreply.github.com> Date: Wed, 7 Feb 2024 15:40:02 -0500 Subject: [PATCH 1/8] move dirs --- .dockerignore | 9 +- Cargo.toml | 2 +- Dockerfile | 94 +++++++++++++++---- crates/new_media/Cargo.toml | 26 ----- new_media/Cargo.toml | 27 ++++++ .../new_media => new_media}/src/controls.rs | 0 {crates/new_media => new_media}/src/main.rs | 0 {crates/new_media => new_media}/src/server.rs | 0 8 files changed, 110 insertions(+), 48 deletions(-) delete mode 100644 crates/new_media/Cargo.toml create mode 100644 new_media/Cargo.toml rename {crates/new_media => new_media}/src/controls.rs (100%) rename {crates/new_media => new_media}/src/main.rs (100%) rename {crates/new_media => new_media}/src/server.rs (100%) diff --git a/.dockerignore b/.dockerignore index 62aa066..f5284ad 100644 --- a/.dockerignore +++ b/.dockerignore @@ -4,12 +4,15 @@ # Allow files and directories !/.cargo/ !/Cargo.toml -!/Cargo.lock -!/crates/new_media -!/recipie.json +!/crates/bevy_ws_server +!/crates/bevy_headless +!/new_media/Cargo.toml +!/new_media/src/** + # Ignore unnecessary files inside allowed directories # This should go after the allowed directories # **/*~ # **/*.log # **/.DS_Store # **/Thumbs.db + diff --git a/Cargo.toml b/Cargo.toml index 7bd7a91..fd10615 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [workspace] resolver = "2" -members = ["crates/*"] +members = ["crates/*", "new_media"] package.rust-version = "1.75.0" diff --git a/Dockerfile b/Dockerfile index 91e0152..2a8f749 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,25 +1,83 @@ -FROM rust as planner +# FROM rust as planner +# WORKDIR /app +# RUN cargo install cargo-chef +# COPY . . +# RUN cargo chef prepare --recipe-path recipe.json + +# FROM rust as cacher +# WORKDIR /app +# RUN cargo install cargo-chef +# COPY --from=planner /app/recipe.json recipe.json +# RUN cargo chef cook --release --recipe-path=recipe.json + +# FROM rust as builder +# COPY . /app +# WORKDIR /app +# COPY --from=cacher /app/target target +# COPY --from=cacher /usr/local/cargo /usr/local/cargo +# RUN cargo build --release + +# FROM bitnami/minideb:bookworm +# COPY --from=builder /app/target/release/new_media /app/new_media +# WORKDIR /app + +# EXPOSE 8080 +# CMD ["./new_media"] + +# -------------- + +# FROM lukemathwalker/cargo-chef:latest-rust-1 AS chef +# WORKDIR /app + +# FROM chef AS planner +# COPY . . +# RUN cargo chef prepare --recipe-path recipe.json + +# FROM chef AS builder +# COPY --from=planner /app/recipe.json recipe.json +# RUN apt-get update -qq && apt-get -y install --no-install-recommends \ +# libasound2-dev \ +# libudev-dev \ +# libwayland-dev \ +# libxkbcommon-dev +# # # Build dependencies - this is the caching Docker layer! +# RUN cargo chef cook --release --features docker --recipe-path recipe.json + +# # Build application +# COPY . . +# RUN cargo build --release --features docker + +# # We do not need the Rust toolchain to run the binary! +# FROM debian:bookworm-slim AS runtime +# WORKDIR /app +# COPY --from=builder /app/target/release/new_media /usr/local/bin + +# EXPOSE 8080 +# ENTRYPOINT ["/usr/local/bin/new_media"] + + +FROM lukemathwalker/cargo-chef:latest-rust-1 AS chef WORKDIR /app -RUN cargo install cargo-chef + +FROM chef AS planner COPY . . RUN cargo chef prepare --recipe-path recipe.json -FROM rust as cacher -WORKDIR /app -RUN cargo install cargo-chef +FROM chef AS builder COPY --from=planner /app/recipe.json recipe.json -RUN cargo chef cook --release --recipe-path=recipe.json - -FROM rust as builder -COPY . /app -WORKDIR /app -COPY --from=cacher /app/target target -COPY --from=cacher /usr/local/cargo /usr/local/cargo -RUN cargo build --release +RUN apt-get update -qq && apt-get -y install --no-install-recommends \ + libasound2-dev \ + libudev-dev \ + libwayland-dev \ + libxkbcommon-dev +# Build dependencies - this is the caching Docker layer! +RUN cargo chef cook --release --features docker --recipe-path recipe.json +# Build application +COPY . . +RUN cargo build --release --features docker -FROM bitnami/minideb:bookworm -COPY --from=builder /app/target/release/new_media /app/new_media +# We do not need the Rust toolchain to run the binary! +FROM debian:bookworm-slim AS runtime WORKDIR /app - -EXPOSE 8080 -CMD ["./new_media"] +COPY --from=builder /app/target/release/new_media /usr/local/bin +ENTRYPOINT ["/usr/local/bin/app"] \ No newline at end of file diff --git a/crates/new_media/Cargo.toml b/crates/new_media/Cargo.toml deleted file mode 100644 index ae04407..0000000 --- a/crates/new_media/Cargo.toml +++ /dev/null @@ -1,26 +0,0 @@ -[package] -name = "new_media" -version = "0.0.1" -edition = "2021" -rust-version.workspace = true -default-run = "new_media" - -[dependencies] -anyhow = {workspace = true} -async-net = {workspace = true} -base64 = {workspace = true} -bevy = { workspace = true } -bevy_ws_server = { path = "../../crates/bevy_ws_server" } -bevy_headless = { path = "../../crates/bevy_headless" } -bevy_gaussian_splatting = { version = "2.0.2", default-features = true } -bevy_panorbit_camera = { workspace = true } -crossbeam-channel = { workspace = true } -dotenvy = "0.15.7" -log = { workspace = true } -pretty_env_logger = {workspace = true} -serde = { version = "1.0.192", features = ["derive"] } -serde_json = "1.0.108" -tungstenite = {workspace = true} - -# [target.i686-unknown-linux-gnu.dependencies] -# winit = { version = "0.29.10", default-features = false, features = ["x11"]} diff --git a/new_media/Cargo.toml b/new_media/Cargo.toml new file mode 100644 index 0000000..7c83926 --- /dev/null +++ b/new_media/Cargo.toml @@ -0,0 +1,27 @@ +[package] +name = "new_media" +version = "0.0.1" +edition = "2021" +rust-version.workspace = true +default-run = "new_media" + +[dependencies] +anyhow = { workspace = true } +async-net = { workspace = true } +base64 = { workspace = true } +bevy = { workspace = true } +bevy_ws_server = { path = "../crates/bevy_ws_server" } +bevy_headless = { path = "../crates/bevy_headless" } +bevy_gaussian_splatting = { version = "2.0.2", default-features = true } +bevy_panorbit_camera = { workspace = true } +crossbeam-channel = { workspace = true } +dotenvy = "0.15.7" +log = { workspace = true } +pretty_env_logger = { workspace = true } +serde = { version = "1.0.192", features = ["derive"] } +serde_json = "1.0.108" +tungstenite = { workspace = true } +winit = { version = "0.29.10", optional = true } + +[features] +docker = ["dep:winit"] diff --git a/crates/new_media/src/controls.rs b/new_media/src/controls.rs similarity index 100% rename from crates/new_media/src/controls.rs rename to new_media/src/controls.rs diff --git a/crates/new_media/src/main.rs b/new_media/src/main.rs similarity index 100% rename from crates/new_media/src/main.rs rename to new_media/src/main.rs diff --git a/crates/new_media/src/server.rs b/new_media/src/server.rs similarity index 100% rename from crates/new_media/src/server.rs rename to new_media/src/server.rs From 25c07ba742365a2ece80d1db7e747dabef62095c Mon Sep 17 00:00:00 2001 From: "Victor A." <52110451+cs50victor@users.noreply.github.com> Date: Wed, 7 Feb 2024 15:52:45 -0500 Subject: [PATCH 2/8] ubuntu fails --- Dockerfile | 98 ++++++++++++++---------------------------------------- 1 file changed, 25 insertions(+), 73 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2a8f749..56564e7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,83 +1,35 @@ -# FROM rust as planner -# WORKDIR /app -# RUN cargo install cargo-chef -# COPY . . -# RUN cargo chef prepare --recipe-path recipe.json +# Use a minimal Ubuntu image as the base image +FROM ubuntu:latest as builder -# FROM rust as cacher -# WORKDIR /app -# RUN cargo install cargo-chef -# COPY --from=planner /app/recipe.json recipe.json -# RUN cargo chef cook --release --recipe-path=recipe.json +# Set the working directory inside the container +WORKDIR /usr/src/app -# FROM rust as builder -# COPY . /app -# WORKDIR /app -# COPY --from=cacher /app/target target -# COPY --from=cacher /usr/local/cargo /usr/local/cargo -# RUN cargo build --release +# Install necessary build dependencies +RUN apt-get update && \ + apt-get install -y \ + build-essential \ + curl g++ pkg-config libx11-dev libasound2-dev libudev-dev libxkbcommon-x11-0 libwayland-dev libxkbcommon-dev -# FROM bitnami/minideb:bookworm -# COPY --from=builder /app/target/release/new_media /app/new_media -# WORKDIR /app +# Install Rust using rustup +RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y -# EXPOSE 8080 -# CMD ["./new_media"] +# Add Rust binaries to the PATH +ENV PATH="/root/.cargo/bin:${PATH}" -# -------------- - -# FROM lukemathwalker/cargo-chef:latest-rust-1 AS chef -# WORKDIR /app - -# FROM chef AS planner -# COPY . . -# RUN cargo chef prepare --recipe-path recipe.json - -# FROM chef AS builder -# COPY --from=planner /app/recipe.json recipe.json -# RUN apt-get update -qq && apt-get -y install --no-install-recommends \ -# libasound2-dev \ -# libudev-dev \ -# libwayland-dev \ -# libxkbcommon-dev -# # # Build dependencies - this is the caching Docker layer! -# RUN cargo chef cook --release --features docker --recipe-path recipe.json - -# # Build application -# COPY . . -# RUN cargo build --release --features docker - -# # We do not need the Rust toolchain to run the binary! -# FROM debian:bookworm-slim AS runtime -# WORKDIR /app -# COPY --from=builder /app/target/release/new_media /usr/local/bin - -# EXPOSE 8080 -# ENTRYPOINT ["/usr/local/bin/new_media"] +# Copy the rest of the application source code into the container +COPY . . +# Build the application +RUN cargo build --release --features docker -FROM lukemathwalker/cargo-chef:latest-rust-1 AS chef -WORKDIR /app +# Use a minimal Ubuntu image as the final base image +FROM ubuntu:latest -FROM chef AS planner -COPY . . -RUN cargo chef prepare --recipe-path recipe.json +# Set the working directory inside the container +WORKDIR /usr/src/app -FROM chef AS builder -COPY --from=planner /app/recipe.json recipe.json -RUN apt-get update -qq && apt-get -y install --no-install-recommends \ - libasound2-dev \ - libudev-dev \ - libwayland-dev \ - libxkbcommon-dev -# Build dependencies - this is the caching Docker layer! -RUN cargo chef cook --release --features docker --recipe-path recipe.json -# Build application -COPY . . -RUN cargo build --release --features docker +# Copy only the necessary files from the builder stage +COPY --from=builder /usr/src/app/target/release/new_media . -# We do not need the Rust toolchain to run the binary! -FROM debian:bookworm-slim AS runtime -WORKDIR /app -COPY --from=builder /app/target/release/new_media /usr/local/bin -ENTRYPOINT ["/usr/local/bin/app"] \ No newline at end of file +# Specify the command to run on container start +CMD ["./new_media"] From 243f1bcae259b562a2587135e2fb2faa1b52fa9f Mon Sep 17 00:00:00 2001 From: "Victor A." <52110451+cs50victor@users.noreply.github.com> Date: Wed, 7 Feb 2024 20:29:01 -0500 Subject: [PATCH 3/8] refactor: curr err - NoCompositorListening --- Dockerfile | 91 +++++++++++++++++++++++++++++++++++-------- new_media/Cargo.toml | 3 +- new_media/src/main.rs | 1 - package.json | 1 + 4 files changed, 78 insertions(+), 18 deletions(-) diff --git a/Dockerfile b/Dockerfile index 56564e7..ece1c03 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,26 +1,47 @@ -# Use a minimal Ubuntu image as the base image -FROM ubuntu:latest as builder +FROM mcr.microsoft.com/devcontainers/rust:1-1-bullseye as builder -# Set the working directory inside the container WORKDIR /usr/src/app # Install necessary build dependencies -RUN apt-get update && \ - apt-get install -y \ - build-essential \ - curl g++ pkg-config libx11-dev libasound2-dev libudev-dev libxkbcommon-x11-0 libwayland-dev libxkbcommon-dev - -# Install Rust using rustup -RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y +RUN apt-get update && apt-get install -y \ + pkg-config \ + libasound2-dev \ + libudev-dev \ + mesa-utils \ + vulkan-tools \ + libwayland-dev \ + libxkbcommon-dev \ + libvulkan1 \ + libvulkan-dev \ + libegl1-mesa-dev \ + libgles2-mesa-dev \ + libx11-dev \ + libxcursor-dev \ + libxrandr-dev \ + libxi-dev \ + libxrandr-dev \ + libxcb1-dev \ + libxcb-icccm4-dev \ + libxcb-image0-dev \ + libxcb-keysyms1-dev \ + libxcb-randr0-dev \ + libxcb-shape0-dev \ + libxcb-xfixes0-dev \ + libxcb-xkb-dev \ + libegl1-mesa \ + libgl1-mesa-glx \ + libgl1-mesa-dri \ + libglu1-mesa-dev \ + libglu1-mesa \ + libgles2-mesa \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* -# Add Rust binaries to the PATH -ENV PATH="/root/.cargo/bin:${PATH}" -# Copy the rest of the application source code into the container COPY . . -# Build the application -RUN cargo build --release --features docker +# Build the application +RUN cargo build --release --features docker # Use a minimal Ubuntu image as the final base image FROM ubuntu:latest @@ -28,8 +49,46 @@ FROM ubuntu:latest # Set the working directory inside the container WORKDIR /usr/src/app +# Install necessary build dependencies +RUN apt-get update && apt-get install -y \ + pkg-config \ + libasound2-dev \ + libudev-dev \ + mesa-utils \ + vulkan-tools \ + libwayland-dev \ + libxkbcommon-dev \ + libvulkan1 \ + libvulkan-dev \ + libegl1-mesa-dev \ + libgles2-mesa-dev \ + libx11-dev \ + libxcursor-dev \ + libxrandr-dev \ + libxi-dev \ + libxrandr-dev \ + libxcb1-dev \ + libxcb-icccm4-dev \ + libxcb-image0-dev \ + libxcb-keysyms1-dev \ + libxcb-randr0-dev \ + libxcb-shape0-dev \ + libxcb-xfixes0-dev \ + libxcb-xkb-dev \ + libegl1-mesa \ + libgl1-mesa-glx \ + libgl1-mesa-dri \ + libglu1-mesa-dev \ + libglu1-mesa \ + libgles2-mesa \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + # Copy only the necessary files from the builder stage COPY --from=builder /usr/src/app/target/release/new_media . -# Specify the command to run on container start + +ENV XDG_RUNTIME_DIR=/tmp +ENV RUST_BACKTRACE=1 +EXPOSE 8080 CMD ["./new_media"] diff --git a/new_media/Cargo.toml b/new_media/Cargo.toml index 7c83926..7d5f4e6 100644 --- a/new_media/Cargo.toml +++ b/new_media/Cargo.toml @@ -22,6 +22,7 @@ serde = { version = "1.0.192", features = ["derive"] } serde_json = "1.0.108" tungstenite = { workspace = true } winit = { version = "0.29.10", optional = true } +openssl = { version = "0.10.63", features = ["vendored"] } [features] -docker = ["dep:winit"] +docker = ["dep:winit","bevy/wayland", "bevy/x11"] diff --git a/new_media/src/main.rs b/new_media/src/main.rs index db0bbf4..6b8c3ab 100644 --- a/new_media/src/main.rs +++ b/new_media/src/main.rs @@ -70,7 +70,6 @@ pub struct AppConfig { fn main() { dotenvy::from_filename_override(".env.local").ok(); - // ************** REQUIRED ENV VARS ************** pretty_env_logger::formatted_builder() .filter_module("new_media", log::LevelFilter::Info) diff --git a/package.json b/package.json index 1290e3e..6bed94e 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "private": true, "scripts": { "build": "pnpm --dir=demo build", + "dev:server": "docker run --rm -it $(docker build -q .)", "dev": "concurrently --names 'WEB,SERVER' -c 'auto' \"pnpm --dir=demo dev\" \"cargo rr --bin new_media\"", "format": "concurrently --names 'fmt:web,fmt:rs,fmt:toml' -c 'auto' \"pnpm format:prettier\" \"pnpm format:rs\" \"pnpm format:toml\"", "format:prettier": "prettier --write \"**/*.{js,ts,tsx}\"", From 1c3ab781e1ac1948764e1e5d1695349f2459d3db Mon Sep 17 00:00:00 2001 From: "Victor A." <52110451+cs50victor@users.noreply.github.com> Date: Thu, 15 Feb 2024 13:37:12 -0500 Subject: [PATCH 4/8] stash --- .dockerignore | 3 + Cargo.toml | 2 +- Dockerfile | 176 +++++++++++++++-------------- crates/bevy_headless/src/plugin.rs | 8 +- labwc/autostart | 10 ++ new_media/Cargo.toml | 5 +- start.sh | 12 ++ sway/autostart | 8 ++ 8 files changed, 131 insertions(+), 93 deletions(-) create mode 100644 labwc/autostart create mode 100644 start.sh create mode 100644 sway/autostart diff --git a/.dockerignore b/.dockerignore index f5284ad..615f1a8 100644 --- a/.dockerignore +++ b/.dockerignore @@ -4,6 +4,9 @@ # Allow files and directories !/.cargo/ !/Cargo.toml +!/start.sh +!/labwc +!/sway !/crates/bevy_ws_server !/crates/bevy_headless !/new_media/Cargo.toml diff --git a/Cargo.toml b/Cargo.toml index fd10615..03ab94d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,7 +28,7 @@ bevy = { version = "0.12.1", default-features = false, features = [ "bevy_asset", "bevy_core_pipeline", "bevy_render", - "multi-threaded" + "multi-threaded", ] } bevy_panorbit_camera = "0.10.0" crossbeam-channel = "0.5.10" diff --git a/Dockerfile b/Dockerfile index ece1c03..eaaed91 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,93 +2,105 @@ FROM mcr.microsoft.com/devcontainers/rust:1-1-bullseye as builder WORKDIR /usr/src/app -# Install necessary build dependencies -RUN apt-get update && apt-get install -y \ - pkg-config \ - libasound2-dev \ - libudev-dev \ - mesa-utils \ - vulkan-tools \ - libwayland-dev \ - libxkbcommon-dev \ - libvulkan1 \ - libvulkan-dev \ - libegl1-mesa-dev \ - libgles2-mesa-dev \ - libx11-dev \ - libxcursor-dev \ - libxrandr-dev \ - libxi-dev \ - libxrandr-dev \ - libxcb1-dev \ - libxcb-icccm4-dev \ - libxcb-image0-dev \ - libxcb-keysyms1-dev \ - libxcb-randr0-dev \ - libxcb-shape0-dev \ - libxcb-xfixes0-dev \ - libxcb-xkb-dev \ - libegl1-mesa \ - libgl1-mesa-glx \ - libgl1-mesa-dri \ - libglu1-mesa-dev \ - libglu1-mesa \ - libgles2-mesa \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* - - COPY . . # Build the application RUN cargo build --release --features docker -# Use a minimal Ubuntu image as the final base image -FROM ubuntu:latest +# -------------------------------------------------- +# FROM fedora:latest -# Set the working directory inside the container -WORKDIR /usr/src/app +# WORKDIR /usr/src/app + +# USER root + +# ENV DEBIAN_FRONTEND=noninteractive + +# # # Install necessary build dependencies +# RUN dnf update -y && dnf install -y gcc-c++ libX11-devel alsa-lib-devel systemd-devel wayland-devel libxkbcommon-devel weston libXcursor libXrandr +# # RUN dnf update -y && dnf install -y \ +# # pkg-config \ +# # weston \ +# # xwayland \ +# # kbd \ +# # dos2unix \ +# # libasound2-dev \ +# # libudev-dev \ +# # mesa-utils \ +# # vulkan-tools \ +# # libwayland-dev \ +# # libxkbcommon-dev \ +# # libvulkan1 \ +# # libvulkan-dev \ +# # libegl1-mesa-dev \ +# # libgles2-mesa-dev \ +# # libx11-dev \ +# # libxcursor-dev \ +# # libxrandr-dev \ +# # libxi-dev \ +# # libxrandr-dev \ +# # libxcb1-dev \ +# # libxcb-icccm4-dev \ +# # libxcb-image0-dev \ +# # libxcb-keysyms1-dev \ +# # libxcb-randr0-dev \ +# # libxcb-shape0-dev \ +# # libxcb-xfixes0-dev \ +# # libxcb-xkb-dev \ +# # libegl1-mesa \ +# # libgl1-mesa-glx \ +# # libgl1-mesa-dri \ +# # libglu1-mesa-dev \ +# # libglu1-mesa \ +# # libgles2-mesa \ +# # && apt-get clean \ +# # && rm -rf /var/lib/apt/lists/* + +# RUN mkdir tmp/ + +# ENV XDG_RUNTIME_DIR=tmp +# ENV WLR_BACKENDS=headless +# ENV WLR_LIBINPUT_NO_DEVICES=1 +# ENV WAYLAND_DISPLAY=wayland-0 +# ENV DISPLAY=:1 + +# COPY --from=builder /usr/src/app/target/release/new_media . +# ENV RUST_BACKTRACE=1 + +# EXPOSE 8080 + +# CMD ["./new_media"] -# Install necessary build dependencies -RUN apt-get update && apt-get install -y \ - pkg-config \ - libasound2-dev \ - libudev-dev \ - mesa-utils \ - vulkan-tools \ - libwayland-dev \ - libxkbcommon-dev \ - libvulkan1 \ - libvulkan-dev \ - libegl1-mesa-dev \ - libgles2-mesa-dev \ - libx11-dev \ - libxcursor-dev \ - libxrandr-dev \ - libxi-dev \ - libxrandr-dev \ - libxcb1-dev \ - libxcb-icccm4-dev \ - libxcb-image0-dev \ - libxcb-keysyms1-dev \ - libxcb-randr0-dev \ - libxcb-shape0-dev \ - libxcb-xfixes0-dev \ - libxcb-xkb-dev \ - libegl1-mesa \ - libgl1-mesa-glx \ - libgl1-mesa-dri \ - libglu1-mesa-dev \ - libglu1-mesa \ - libgles2-mesa \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* - -# Copy only the necessary files from the builder stage -COPY --from=builder /usr/src/app/target/release/new_media . - - -ENV XDG_RUNTIME_DIR=/tmp -ENV RUST_BACKTRACE=1 + +# ----------------- TESTING + +FROM registry.fedoraproject.org/fedora-minimal:37 +RUN microdnf install -y --setopt install_weak_deps=0 busybox spice-html5 python3-websockify novnc weston labwc sway wayvnc dbus-daemon procps-ng foot wofi bemenu google-noto-naskh-arabic-fonts dejavu-fonts-all ; microdnf clean all + +RUN mkdir /opt/busybox; \ + /sbin/busybox --install -s /opt/busybox +ENV PATH=/usr/share/Modules/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/opt/busybox +RUN cp /usr/share/weston/background.png /usr/share/backgrounds/default.png ; \ + busybox adduser -D app ; \ + busybox passwd -l app ; \ + mkdir -p /home/app/tmp ; busybox chown app:app /home/app/tmp +ADD sway /etc/sway/config.d/sway +ADD labwc /etc/xdg/labwc + +USER app +ENV SHELL=/bin/bash +ENV PATH=/home/app/.local/bin:/home/app/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/opt/busybox +ENV XDG_RUNTIME_DIR=/home/app/tmp +ENV WLR_BACKENDS=headless +ENV WLR_LIBINPUT_NO_DEVICES=1 +ENV WAYLAND_DISPLAY=wayland-1 + +ADD start.sh /start.sh + +EXPOSE 5900 EXPOSE 8080 -CMD ["./new_media"] + + +ENTRYPOINT ["/start.sh"] + + diff --git a/crates/bevy_headless/src/plugin.rs b/crates/bevy_headless/src/plugin.rs index 848d310..c14689a 100644 --- a/crates/bevy_headless/src/plugin.rs +++ b/crates/bevy_headless/src/plugin.rs @@ -238,12 +238,6 @@ fn capture_img_bytes( match ImageBuffer::::from_raw(source_size.width, source_size.height, image_bytes) { Some(image_bytes) => { curr_img.0.lock().update_data(frame_id, &image_bytes, extension.to_owned()); - - // if let Some(curr_img) = curr_img.as_mut(){ - // curr_img.update_data(frame_id, &image_bytes, extension.to_owned()); - // }else{ - // log::info!("Curr Image Resource still doesn't exist"); - // } }, None => { log::error!("Failed creating image buffer for frame - '{frame_id}'"); @@ -271,7 +265,7 @@ impl Plugin for HeadlessPlugin { exit_condition: bevy::window::ExitCondition::DontExit, close_when_requested: false, }) - .disable::(), + .disable::() ); // TODO: diff --git a/labwc/autostart b/labwc/autostart new file mode 100644 index 0000000..758f4f0 --- /dev/null +++ b/labwc/autostart @@ -0,0 +1,10 @@ +# labwv auto start +# https://github.com/labwc/labwc/blob/master/docs/autostart + +swaybg -i /usr/share/backgrounds/default.png >/dev/null 2>&1 & + +# swaybar -b bar-0 >/dev/null 2>&1 & + +foot 2>&1 & + +wayvnc 0.0.0.0 2>&1 & diff --git a/new_media/Cargo.toml b/new_media/Cargo.toml index 7d5f4e6..e21a217 100644 --- a/new_media/Cargo.toml +++ b/new_media/Cargo.toml @@ -21,8 +21,7 @@ pretty_env_logger = { workspace = true } serde = { version = "1.0.192", features = ["derive"] } serde_json = "1.0.108" tungstenite = { workspace = true } -winit = { version = "0.29.10", optional = true } -openssl = { version = "0.10.63", features = ["vendored"] } +openssl = { version = "0.10.63", features = ["vendored"], optional = true} [features] -docker = ["dep:winit","bevy/wayland", "bevy/x11"] +docker = ["dep:openssl","bevy/wayland", "bevy/x11"] diff --git a/start.sh b/start.sh new file mode 100644 index 0000000..09fafb0 --- /dev/null +++ b/start.sh @@ -0,0 +1,12 @@ +#! /bin/bash + +dbus-daemon --session --nofork --nopidfile --nosyslog --print-address > ~/tmp/dbus.addr.txt & +export DBUS_SESSION_BUS_ADDRESS=`cat ~/tmp/dbus.addr.txt` +sleep 0.5 +websockify --web /usr/share/novnc 8080 localhost:5900 & +sleep 0.5 +disown -a +[ "x$1" == "xsway" ] && exec sway +[ "x$1" == "xbash" ] && exec bash +exec labwc -C /etc/xdg/labwc/ + diff --git a/sway/autostart b/sway/autostart new file mode 100644 index 0000000..ed8b51a --- /dev/null +++ b/sway/autostart @@ -0,0 +1,8 @@ +# /etc/sway/config.d/autostart + +bindsym Mod1+Return exec foot +bindsym Mod1+r exec wofi --show drun +bindsym Mod1+F3 exec bemenu-run + +exec foot +exec wayvnc 0.0.0.0 From 64e5ddd89829e1eeefe3c505285ebd9696a19f46 Mon Sep 17 00:00:00 2001 From: "Victor A." <52110451+cs50victor@users.noreply.github.com> Date: Thu, 15 Feb 2024 15:50:50 -0500 Subject: [PATCH 5/8] fix: docker works-ish --- Dockerfile | 138 ++++++++++++------------------------------- new_media/Cargo.toml | 2 +- 2 files changed, 39 insertions(+), 101 deletions(-) diff --git a/Dockerfile b/Dockerfile index eaaed91..728c9f3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,106 +1,44 @@ -FROM mcr.microsoft.com/devcontainers/rust:1-1-bullseye as builder - -WORKDIR /usr/src/app - +FROM rust as planner +WORKDIR /app +RUN cargo install cargo-chef COPY . . - -# Build the application +RUN cargo chef prepare --recipe-path recipe.json + +FROM rust as cacher +WORKDIR /app +RUN cargo install cargo-chef +COPY --from=planner /app/recipe.json recipe.json +# Build tools +RUN apt-get update +RUN apt-get install -y -qq build-essential software-properties-common pkg-config xorg openbox xauth +RUN cargo chef cook --release --features docker --recipe-path=recipe.json + +FROM rust as builder +COPY . /app +WORKDIR /app +COPY --from=cacher /app/target target +COPY --from=cacher /usr/local/cargo /usr/local/cargo +# Build tools +RUN apt-get update +RUN apt-get install -y -qq build-essential software-properties-common pkg-config xorg openbox xauth RUN cargo build --release --features docker -# -------------------------------------------------- -# FROM fedora:latest - -# WORKDIR /usr/src/app - -# USER root - -# ENV DEBIAN_FRONTEND=noninteractive - -# # # Install necessary build dependencies -# RUN dnf update -y && dnf install -y gcc-c++ libX11-devel alsa-lib-devel systemd-devel wayland-devel libxkbcommon-devel weston libXcursor libXrandr -# # RUN dnf update -y && dnf install -y \ -# # pkg-config \ -# # weston \ -# # xwayland \ -# # kbd \ -# # dos2unix \ -# # libasound2-dev \ -# # libudev-dev \ -# # mesa-utils \ -# # vulkan-tools \ -# # libwayland-dev \ -# # libxkbcommon-dev \ -# # libvulkan1 \ -# # libvulkan-dev \ -# # libegl1-mesa-dev \ -# # libgles2-mesa-dev \ -# # libx11-dev \ -# # libxcursor-dev \ -# # libxrandr-dev \ -# # libxi-dev \ -# # libxrandr-dev \ -# # libxcb1-dev \ -# # libxcb-icccm4-dev \ -# # libxcb-image0-dev \ -# # libxcb-keysyms1-dev \ -# # libxcb-randr0-dev \ -# # libxcb-shape0-dev \ -# # libxcb-xfixes0-dev \ -# # libxcb-xkb-dev \ -# # libegl1-mesa \ -# # libgl1-mesa-glx \ -# # libgl1-mesa-dri \ -# # libglu1-mesa-dev \ -# # libglu1-mesa \ -# # libgles2-mesa \ -# # && apt-get clean \ -# # && rm -rf /var/lib/apt/lists/* - -# RUN mkdir tmp/ - -# ENV XDG_RUNTIME_DIR=tmp -# ENV WLR_BACKENDS=headless -# ENV WLR_LIBINPUT_NO_DEVICES=1 -# ENV WAYLAND_DISPLAY=wayland-0 -# ENV DISPLAY=:1 - -# COPY --from=builder /usr/src/app/target/release/new_media . -# ENV RUST_BACKTRACE=1 - -# EXPOSE 8080 +FROM ubuntu:22.04 +COPY --from=builder /app/target/release/new_media /app/new_media +WORKDIR /app + +# Build tools +RUN apt-get update +RUN apt-get install -y -qq build-essential software-properties-common pkg-config xorg openbox xauth +# Bevy dependencies +RUN DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -yq libasound2-dev libudev-dev libxkbcommon-x11-0 +RUN apt-get update -y -qq +RUN add-apt-repository ppa:kisak/turtle -y +RUN apt-get update +RUN apt install -y xvfb libegl1-mesa libgl1-mesa-dri libxcb-xfixes0-dev mesa-vulkan-drivers +ENV CARGO_TARGET_DIR="../rust-target" +ENV PATH="/root/.cargo/bin:${PATH}" -# CMD ["./new_media"] - - -# ----------------- TESTING - -FROM registry.fedoraproject.org/fedora-minimal:37 -RUN microdnf install -y --setopt install_weak_deps=0 busybox spice-html5 python3-websockify novnc weston labwc sway wayvnc dbus-daemon procps-ng foot wofi bemenu google-noto-naskh-arabic-fonts dejavu-fonts-all ; microdnf clean all - -RUN mkdir /opt/busybox; \ - /sbin/busybox --install -s /opt/busybox -ENV PATH=/usr/share/Modules/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/opt/busybox -RUN cp /usr/share/weston/background.png /usr/share/backgrounds/default.png ; \ - busybox adduser -D app ; \ - busybox passwd -l app ; \ - mkdir -p /home/app/tmp ; busybox chown app:app /home/app/tmp -ADD sway /etc/sway/config.d/sway -ADD labwc /etc/xdg/labwc - -USER app -ENV SHELL=/bin/bash -ENV PATH=/home/app/.local/bin:/home/app/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/opt/busybox -ENV XDG_RUNTIME_DIR=/home/app/tmp -ENV WLR_BACKENDS=headless -ENV WLR_LIBINPUT_NO_DEVICES=1 -ENV WAYLAND_DISPLAY=wayland-1 - -ADD start.sh /start.sh - -EXPOSE 5900 EXPOSE 8080 - -ENTRYPOINT ["/start.sh"] - - +CMD xvfb-run -s "-screen 0 1280x1024x24" "./new_media" \ No newline at end of file diff --git a/new_media/Cargo.toml b/new_media/Cargo.toml index e21a217..5bc410f 100644 --- a/new_media/Cargo.toml +++ b/new_media/Cargo.toml @@ -24,4 +24,4 @@ tungstenite = { workspace = true } openssl = { version = "0.10.63", features = ["vendored"], optional = true} [features] -docker = ["dep:openssl","bevy/wayland", "bevy/x11"] +docker = ["dep:openssl","bevy/x11"] From 43f1caa56d342b7092da9d7b80b94099df445044 Mon Sep 17 00:00:00 2001 From: "Victor A." <52110451+cs50victor@users.noreply.github.com> Date: Thu, 15 Feb 2024 16:11:08 -0500 Subject: [PATCH 6/8] chore: clippy + fmt --- crates/bevy_headless/src/plugin.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/bevy_headless/src/plugin.rs b/crates/bevy_headless/src/plugin.rs index c14689a..61772a8 100644 --- a/crates/bevy_headless/src/plugin.rs +++ b/crates/bevy_headless/src/plugin.rs @@ -265,7 +265,7 @@ impl Plugin for HeadlessPlugin { exit_condition: bevy::window::ExitCondition::DontExit, close_when_requested: false, }) - .disable::() + .disable::(), ); // TODO: From 6beb3d5941beee3cd2f7d2b6b59a3e525699e61f Mon Sep 17 00:00:00 2001 From: "Victor A." <52110451+cs50victor@users.noreply.github.com> Date: Thu, 15 Feb 2024 21:15:26 -0500 Subject: [PATCH 7/8] chore: remove unused files --- .dockerignore | 3 --- Dockerfile | 8 +++----- labwc/autostart | 10 ---------- start.sh | 12 ------------ sway/autostart | 8 -------- 5 files changed, 3 insertions(+), 38 deletions(-) delete mode 100644 labwc/autostart delete mode 100644 start.sh delete mode 100644 sway/autostart diff --git a/.dockerignore b/.dockerignore index 615f1a8..f5284ad 100644 --- a/.dockerignore +++ b/.dockerignore @@ -4,9 +4,6 @@ # Allow files and directories !/.cargo/ !/Cargo.toml -!/start.sh -!/labwc -!/sway !/crates/bevy_ws_server !/crates/bevy_headless !/new_media/Cargo.toml diff --git a/Dockerfile b/Dockerfile index 728c9f3..520f946 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,8 +9,7 @@ WORKDIR /app RUN cargo install cargo-chef COPY --from=planner /app/recipe.json recipe.json # Build tools -RUN apt-get update -RUN apt-get install -y -qq build-essential software-properties-common pkg-config xorg openbox xauth +RUN apt-get update && apt-get install -y -qq xorg xauth RUN cargo chef cook --release --features docker --recipe-path=recipe.json FROM rust as builder @@ -19,8 +18,7 @@ WORKDIR /app COPY --from=cacher /app/target target COPY --from=cacher /usr/local/cargo /usr/local/cargo # Build tools -RUN apt-get update -RUN apt-get install -y -qq build-essential software-properties-common pkg-config xorg openbox xauth +RUN apt-get update && apt-get install -y -qq xorg xauth RUN cargo build --release --features docker FROM ubuntu:22.04 @@ -41,4 +39,4 @@ ENV PATH="/root/.cargo/bin:${PATH}" EXPOSE 8080 -CMD xvfb-run -s "-screen 0 1280x1024x24" "./new_media" \ No newline at end of file +CMD xvfb-run -l -s "-screen 0 1024x768x24" "./new_media" \ No newline at end of file diff --git a/labwc/autostart b/labwc/autostart deleted file mode 100644 index 758f4f0..0000000 --- a/labwc/autostart +++ /dev/null @@ -1,10 +0,0 @@ -# labwv auto start -# https://github.com/labwc/labwc/blob/master/docs/autostart - -swaybg -i /usr/share/backgrounds/default.png >/dev/null 2>&1 & - -# swaybar -b bar-0 >/dev/null 2>&1 & - -foot 2>&1 & - -wayvnc 0.0.0.0 2>&1 & diff --git a/start.sh b/start.sh deleted file mode 100644 index 09fafb0..0000000 --- a/start.sh +++ /dev/null @@ -1,12 +0,0 @@ -#! /bin/bash - -dbus-daemon --session --nofork --nopidfile --nosyslog --print-address > ~/tmp/dbus.addr.txt & -export DBUS_SESSION_BUS_ADDRESS=`cat ~/tmp/dbus.addr.txt` -sleep 0.5 -websockify --web /usr/share/novnc 8080 localhost:5900 & -sleep 0.5 -disown -a -[ "x$1" == "xsway" ] && exec sway -[ "x$1" == "xbash" ] && exec bash -exec labwc -C /etc/xdg/labwc/ - diff --git a/sway/autostart b/sway/autostart deleted file mode 100644 index ed8b51a..0000000 --- a/sway/autostart +++ /dev/null @@ -1,8 +0,0 @@ -# /etc/sway/config.d/autostart - -bindsym Mod1+Return exec foot -bindsym Mod1+r exec wofi --show drun -bindsym Mod1+F3 exec bemenu-run - -exec foot -exec wayvnc 0.0.0.0 From 1d1d87d0fd96737c04214e75e5d80be3ca9e2768 Mon Sep 17 00:00:00 2001 From: "Victor A." <52110451+cs50victor@users.noreply.github.com> Date: Thu, 15 Feb 2024 23:19:22 -0500 Subject: [PATCH 8/8] refactor: docker works --- Dockerfile | 2 +- README.md | 4 ++++ new_media/src/main.rs | 6 +++--- new_media/src/server.rs | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 520f946..4748d08 100644 --- a/Dockerfile +++ b/Dockerfile @@ -39,4 +39,4 @@ ENV PATH="/root/.cargo/bin:${PATH}" EXPOSE 8080 -CMD xvfb-run -l -s "-screen 0 1024x768x24" "./new_media" \ No newline at end of file +CMD xvfb-run -s "-screen 0 1024x768x24" "./new_media" \ No newline at end of file diff --git a/README.md b/README.md index 855f0ec..98baed6 100644 --- a/README.md +++ b/README.md @@ -3,3 +3,7 @@ ## notes to self - only "audio" feature MUST be real-time "lipsync" - focus on primarily building realistic camera features not visual effects existing video editing programs (i.e Davinci) work on. + + +- run web: `pnpm --dir=demo dev` +- run server: `docker run -it -p 8080:8080 $(docker build -q .)` diff --git a/new_media/src/main.rs b/new_media/src/main.rs index 6b8c3ab..7198dbf 100644 --- a/new_media/src/main.rs +++ b/new_media/src/main.rs @@ -23,7 +23,7 @@ use server::{receive_message, start_ws}; fn setup_gaussian_cloud( mut commands: Commands, asset_server: Res, - _gaussian_assets: ResMut>, + mut gaussian_assets: ResMut>, mut scene_controller: ResMut, mut images: ResMut>, export_sources: ResMut>, @@ -32,9 +32,9 @@ fn setup_gaussian_cloud( // TODO: figure out how to load remote files later let splat_file = "splats/garden/point_cloud/iteration_7000/point_cloud.gcloud"; log::info!("loading {}", splat_file); - let cloud = asset_server.load(splat_file.to_string()); + // let cloud = asset_server.load(splat_file.to_string()); - // let cloud = gaussian_assets.add(GaussianCloud::test_model()); + let cloud = gaussian_assets.add(GaussianCloud::test_model()); let render_target = bevy_headless::setup_render_target( &mut commands, diff --git a/new_media/src/server.rs b/new_media/src/server.rs index cc04fd8..7fc7774 100644 --- a/new_media/src/server.rs +++ b/new_media/src/server.rs @@ -38,7 +38,7 @@ pub fn start_ws(listener: Res) { .parse::() .expect("PORT couldn't be set"); - match listener.listen(([127, 0, 0, 1], port), None) { + match listener.listen(([0, 0, 0, 0], port), None) { Ok(host) => { log::info!("Websocket Server listening on {host:?}"); },