From de70221c49c3d5369788d7c5ae423997dd66f1d6 Mon Sep 17 00:00:00 2001 From: Orual Date: Wed, 15 Apr 2026 13:06:12 -0400 Subject: [PATCH] docker build, moved vod.place onto same docker host as weaver --- .dockerignore | 6 ++++++ .gitignore | 1 + Cargo.lock | 1 + Cargo.toml | 3 +++ Dockerfile | 19 ++++++++++++++----- build.rs | 29 +++++++++++++++++++++++++++++ src/env.rs | 26 ++++++++++++++++++++++++++ 7 files changed, 80 insertions(+), 5 deletions(-) create mode 100644 .dockerignore create mode 100644 build.rs create mode 100644 src/env.rs diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..8028734 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +**/target +**/dist +LICENSES +LICENSE +temp +**/README.md diff --git a/.gitignore b/.gitignore index dababa5..feadee6 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ !.github !.cargo !.gitignore +!.dockerignore /.pre-commit-config.yaml /plans /data diff --git a/Cargo.lock b/Cargo.lock index 49e117e..efa2625 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8529,6 +8529,7 @@ dependencies = [ "dioxus-free-icons", "dioxus-primitives", "dioxus-sdk", + "dotenvy", "ffmpeg-next", "futures", "gloo-events", diff --git a/Cargo.toml b/Cargo.toml index 6de61f9..a306a32 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -90,6 +90,9 @@ ffmpeg-next = "7" image = { version = "0.25", default-features = false, features = ["jpeg"] } mini-moka-wasm = { git = "https://tangled.org/nonbinary.computer/jacquard", branch = "main"} +[build-dependencies] +dotenvy = "0.15.7" + [dev-dependencies] insta = { version = "1.40", features = ["yaml"] } tokio = { version = "1.50", features = ["rt", "macros"] } diff --git a/Dockerfile b/Dockerfile index 3fc2c39..a07b925 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ FROM rust:1-trixie AS builder WORKDIR /app -RUN rustup default nightly && rustup component add rust-src +RUN rustup default nightly-2026-03-30 && rustup component add rust-src llvm-tools-preview --toolchain nightly-2026-03-30 # Install build dependencies RUN apt-get update && apt-get install -y \ @@ -11,9 +11,14 @@ RUN apt-get update && apt-get install -y \ libssl-dev \ clang \ llvm \ + build-essential \ + curl \ + wget \ + file \ binutils \ libavcodec-dev \ libavformat-dev \ + libavdevice-dev \ libavutil-dev \ libswscale-dev \ libavfilter-dev \ @@ -23,7 +28,7 @@ RUN apt-get update && apt-get install -y \ # Install wasm target and tools RUN rustup target add wasm32-unknown-unknown -RUN cargo install wasm-bindgen-cli +RUN cargo install wasm-bindgen-cli --locked --version 0.2.117 # Install dioxus-cli RUN curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash @@ -32,6 +37,8 @@ RUN cargo binstall dioxus-cli --root /usr/local -y --force # Copy source code COPY . . +RUN cp .env-prod .env + # Build wasm worker RUN RUSTFLAGS='--cfg getrandom_backend="wasm_js"' cargo build -p vodplace-player-worker --bin player_worker \ --target wasm32-unknown-unknown --profile worker-release @@ -62,6 +69,7 @@ RUN apt-get update && apt-get install -y \ libssl3 \ libavcodec61 \ libavformat61 \ + libavdevice61 \ libavutil59 \ libswscale8 \ libsqlite3-0 \ @@ -71,14 +79,15 @@ WORKDIR /app # Copy the bundled app COPY --from=builder /app/target/dx/vodplace/release/web/ /app/ +# COPY --from=builder /app/public/ /app/public # Create data directory for sqlite cache RUN mkdir -p /app/data -ENV PORT=8080 +ENV PORT=8090 ENV IP=0.0.0.0 ENV VODPLACE_CACHE_DIR=/app/data -EXPOSE 8080 +EXPOSE 8090 -ENTRYPOINT ["/app/vodplace"] +ENTRYPOINT ["/app/server"] diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..7b49672 --- /dev/null +++ b/build.rs @@ -0,0 +1,29 @@ +use dotenvy::dotenv; +use std::env; +use std::fs::File; +use std::io::Write; + +fn main() { + println!("cargo:rerun-if-changed=.env"); + let dest_path = "./src/env.rs"; + let mut f = File::create(&dest_path).unwrap(); + + dotenv().ok(); + f.write_all(b"// This file is automatically generated by build.rs\n\n") + .unwrap(); + + // Track which keys we've written + let mut written_keys = std::collections::HashSet::new(); + + for (key, value) in env::vars() { + if key.starts_with("VODPLACE_") { + let line = format!( + "#[allow(unused)]\npub const {}: &'static str = \"{}\";\n", + key, + value.replace("\"", "\\\"") + ); + f.write_all(line.as_bytes()).unwrap(); + written_keys.insert(key); + } + } +} diff --git a/src/env.rs b/src/env.rs new file mode 100644 index 0000000..4189e28 --- /dev/null +++ b/src/env.rs @@ -0,0 +1,26 @@ +// This file is automatically generated by build.rs + +#[allow(unused)] +pub const VODPLACE_APP_ENV: &'static str = "dev"; +#[allow(unused)] +pub const VODPLACE_APP_HOST: &'static str = "http://localhost"; +#[allow(unused)] +pub const VODPLACE_APP_DOMAIN: &'static str = ""; +#[allow(unused)] +pub const VODPLACE_PORT: &'static str = "8080"; +#[allow(unused)] +pub const VODPLACE_APP_SCOPES: &'static str = "atproto transition:generic"; +#[allow(unused)] +pub const VODPLACE_CLIENT_NAME: &'static str = "Weaver"; +#[allow(unused)] +pub const VODPLACE_LOGO_URI: &'static str = ""; +#[allow(unused)] +pub const VODPLACE_TOS_URI: &'static str = ""; +#[allow(unused)] +pub const VODPLACE_PRIVACY_POLICY_URI: &'static str = ""; +#[allow(unused)] +pub const VODPLACE_INDEXER_URL: &'static str = "https://index.weaver.sh"; +#[allow(unused)] +pub const VODPLACE_INDEXER_DID: &'static str = "did:web:index.weaver.sh"; +#[allow(unused)] +pub const VODPLACE_OWNER_DID: &'static str = "did:plc:yfvwmnlztr4dwkb7hwz55r2g"; -- 2.51.2