Skip to content

Commit

Permalink
feat: docker (#18)
Browse files Browse the repository at this point in the history
* chore: remove unused files
* refactor: docker works
  • Loading branch information
cs50victor authored Feb 16, 2024
1 parent ee219d1 commit 0258a91
Show file tree
Hide file tree
Showing 11 changed files with 65 additions and 46 deletions.
9 changes: 6 additions & 3 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[workspace]
resolver = "2"
members = ["crates/*"]
members = ["crates/*", "new_media"]

package.rust-version = "1.75.0"

Expand Down Expand Up @@ -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"
Expand Down
25 changes: 21 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,35 @@ 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
# Build tools
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
COPY . /app
WORKDIR /app
COPY --from=cacher /app/target target
COPY --from=cacher /usr/local/cargo /usr/local/cargo
RUN cargo build --release
# Build tools
RUN apt-get update && apt-get install -y -qq xorg xauth
RUN cargo build --release --features docker

FROM bitnami/minideb:bookworm
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}"

EXPOSE 8080
CMD ["./new_media"]

CMD xvfb-run -s "-screen 0 1024x768x24" "./new_media"
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 .)`
6 changes: 0 additions & 6 deletions crates/bevy_headless/src/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,12 +238,6 @@ fn capture_img_bytes<P: Pixel + PixelWithColorType>(
match ImageBuffer::<P, _>::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}'");
Expand Down
26 changes: 0 additions & 26 deletions crates/new_media/Cargo.toml

This file was deleted.

27 changes: 27 additions & 0 deletions new_media/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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 }
openssl = { version = "0.10.63", features = ["vendored"], optional = true}

[features]
docker = ["dep:openssl","bevy/x11"]
File renamed without changes.
7 changes: 3 additions & 4 deletions crates/new_media/src/main.rs → new_media/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use server::{receive_message, start_ws};
fn setup_gaussian_cloud(
mut commands: Commands,
asset_server: Res<AssetServer>,
_gaussian_assets: ResMut<Assets<GaussianCloud>>,
mut gaussian_assets: ResMut<Assets<GaussianCloud>>,
mut scene_controller: ResMut<bevy_headless::SceneInfo>,
mut images: ResMut<Assets<Image>>,
export_sources: ResMut<Assets<ImageExportSource>>,
Expand All @@ -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,
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion crates/new_media/src/server.rs → new_media/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub fn start_ws(listener: Res<WsListener>) {
.parse::<u16>()
.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:?}");
},
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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}\"",
Expand Down

0 comments on commit 0258a91

Please sign in to comment.