diff --git a/crates/leptos-chat/.dockerignore b/crates/leptos-chat/.dockerignore new file mode 100644 index 0000000..c3a75d1 --- /dev/null +++ b/crates/leptos-chat/.dockerignore @@ -0,0 +1,7 @@ +* +!src/ +!style/ +!Cargo.toml/ +!index.html +!Trunk.toml + diff --git a/crates/leptos-chat/Dockerfile b/crates/leptos-chat/Dockerfile new file mode 100644 index 0000000..aa0e39b --- /dev/null +++ b/crates/leptos-chat/Dockerfile @@ -0,0 +1,28 @@ +# Build stage +FROM rust:1-alpine AS builder + +# Install build dependencies +RUN apk add --no-cache npm nodejs musl-dev pkgconfig openssl-dev git curl bash + +RUN curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash + +WORKDIR /app + +# Copy manifest first (cache deps) +COPY . . +# Install trunk +RUN cargo install wasm-bindgen-cli + +RUN cargo binstall trunk + +# Build release artifacts +RUN rustup target add wasm32-unknown-unknown && export RUSTFLAGS='--cfg getrandom_backend="wasm_js"' && trunk build --release + +# Final stage: static web server +FROM caddy:2-alpine + +# Copy built assets into Caddy's web root +COPY --from=builder /app/dist /usr/share/caddy + +EXPOSE 8788 +CMD ["caddy", "file-server", "--root", "/usr/share/caddy", "--listen", ":8788"] \ No newline at end of file