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