Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.git/
**/target/
**/dist/
**/build/
6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@

## 8.0.0

- To migrate from Rinf version 7, refer to [this section](https://rinf.cunarist.com/upgrading/) in the documentation.
- To migrate from Rinf version 7, refer to [this section](https://rinf.cunarist.org/upgrading/) in the documentation.
- Rinf no longer uses Protobuf. It now uses Serde. You should annotate Rust structs to define signal endpoints between Dart and Rust.
- Fixed an issue with loading the app on the web.
- Improved documentation in various areas.
Expand Down Expand Up @@ -110,7 +110,7 @@

## 7.0.0

- To migrate from Rinf version 6, please refer to [this section](https://rinf.cunarist.com/upgrading/) in the documentation.
- To migrate from Rinf version 6, please refer to [this section](https://rinf.cunarist.org/upgrading/) in the documentation.
- Rinf no longer relies on `tokio`. While it is provided by default in the template, you can now choose whichever async runtime you prefer.
- The CLI output is now more compact and includes animations.
- The full `flutter run` command with the necessary arguments can now be obtained by running `rinf server`.
Expand Down Expand Up @@ -313,7 +313,7 @@

## 4.19.1

- Switched to the new official website `rinf.cunarist.com`.
- Switched to the new official website `rinf.cunarist.org`.

## 4.19.0

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Rinf is a framework for creating beautiful and performant cross-platform Rust ap

## 📖 Documentation

Visit the [documentation](https://rinf.cunarist.com) to learn everything about using this framework. You can also explore the [example code](https://github.com/cunarist/rinf/tree/main/flutter_package/example).
Visit the [documentation](https://rinf.cunarist.org) to learn everything about using this framework. You can also explore the [example code](https://github.com/cunarist/rinf/tree/main/flutter_package/example).

## 🖥️ Platform Support

Expand Down
16 changes: 16 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
services:
documentation:
build:
context: .
dockerfile: documentation/Dockerfile
ports:
- "${PORT}:80"
restart: unless-stopped

demo:
build:
context: .
dockerfile: demo/Dockerfile
ports:
- "${PORT_DEMO}:80"
restart: unless-stopped
52 changes: 52 additions & 0 deletions demo/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Build Rinf example app for web
FROM debian:bookworm-slim AS builder

# Install dependencies
RUN apt-get update && apt-get install -y \
curl git unzip xz-utils zip \
build-essential pkg-config libssl-dev

# Install Flutter
ENV FLUTTER_HOME=/opt/flutter
ENV PATH="${FLUTTER_HOME}/bin:${PATH}"
RUN git clone https://github.com/flutter/flutter.git -b stable ${FLUTTER_HOME}

# Install Rust
ENV RUSTUP_HOME=/usr/local/rustup
ENV CARGO_HOME=/usr/local/cargo
ENV PATH="/usr/local/cargo/bin:${PATH}"
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y

# Set working directory
WORKDIR /workspace

# Copy project files
COPY flutter_package/ flutter_package/
COPY rust_crate/ rust_crate/
COPY rust_crate_proc/ rust_crate_proc/
COPY rust_crate_cli/ rust_crate_cli/
COPY Cargo.toml Cargo.toml

# Install Rinf CLI from local source
RUN cargo install --path rust_crate_cli

# Build web app
WORKDIR /workspace/flutter_package/example
RUN rinf gen
RUN rinf wasm --release
RUN flutter build web --release

# Serve the app
FROM python:3.13-slim

WORKDIR /app

# Copy built web app
COPY --from=builder /workspace/flutter_package/example/build/web .

# Copy server script
COPY demo/server.py .

EXPOSE 80

CMD ["python", "server.py"]
1 change: 1 addition & 0 deletions demo/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""A demo web application made with Rinf."""
25 changes: 25 additions & 0 deletions demo/server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"""Simple HTTP server with CORS headers for demo Rinf web app."""

from http.server import HTTPServer, SimpleHTTPRequestHandler
from typing import override


class RequestHandler(SimpleHTTPRequestHandler):
"""Request handler with CORS headers for SharedArrayBuffer support."""

@override
def end_headers(self) -> None:
"""Add required headers for cross-origin isolation."""
self.send_header("cross-origin-opener-policy", "same-origin")
self.send_header("cross-origin-embedder-policy", "require-corp")
super().end_headers()


def main() -> None:
"""Start the HTTP server for serving documentation files."""
address = ("", 80)
HTTPServer(address, RequestHandler).serve_forever()


if __name__ == "__main__":
main()
64 changes: 64 additions & 0 deletions documentation/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Build Flutter web app
FROM debian:bookworm-slim AS flutter-builder

# Install dependencies
RUN apt-get update
RUN apt-get install -y \
curl git unzip xz-utils zip libglu1-mesa \
build-essential pkg-config libssl-dev

# Install Flutter
ENV FLUTTER_HOME=/opt/flutter
ENV PATH="${FLUTTER_HOME}/bin:${PATH}"
RUN git clone https://github.com/flutter/flutter.git -b stable ${FLUTTER_HOME}

# Install Rust
ENV RUSTUP_HOME=/usr/local/rustup
ENV CARGO_HOME=/usr/local/cargo
ENV PATH="/usr/local/cargo/bin:${PATH}"
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y

# Set working directory
WORKDIR /workspace

# Copy only essential files for building
COPY flutter_package/ flutter_package/
COPY rust_crate/ rust_crate/
COPY rust_crate_proc/ rust_crate_proc/
COPY rust_crate_cli/ rust_crate_cli/
COPY Cargo.toml Cargo.toml

# Install Rinf CLI from local source
RUN cargo install --path rust_crate_cli

# Build Flutter web app
WORKDIR /workspace/flutter_package/example
RUN rinf gen
RUN rinf wasm --release
RUN flutter build web --release --base-href="/_static/web_app/"

# Build documentation and serve
FROM python:3.13-slim

# Set working directory
WORKDIR /app

# Copy documentation files
COPY documentation/ .

# Copy built web app from flutter-builder stage
COPY --from=flutter-builder \
/workspace/flutter_package/example/build/web \
source/_static/web_app/

# Install dependencies
RUN pip install --no-cache-dir .

# Build documentation
RUN sphinx-build -b dirhtml source dist/dirhtml

# Expose port 80
EXPOSE 80

# Run the server
CMD ["python", "server.py"]
17 changes: 6 additions & 11 deletions documentation/server.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,26 @@
"""Simple HTTP server for serving documentation with CORS headers."""

import logging
import os
from http.server import HTTPServer, SimpleHTTPRequestHandler
from typing import override

logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.INFO, format="%(message)s")


class RequestHandler(SimpleHTTPRequestHandler):
"""HTTP request handler with additional CORS headers for cross-origin isolation."""

@override
def end_headers(self) -> None:
self.send_header("Cross-Origin-Opener-Policy", "same-origin")
self.send_header("Cross-Origin-Embedder-Policy", "require-corp")
self.send_header("cross-origin-opener-policy", "same-origin")
self.send_header("cross-origin-embedder-policy", "require-corp")
super().end_headers()


def main() -> None:
"""Start the HTTP server for serving documentation files."""
os.chdir("dist/dirhtml")
server_address = ("", 8000)
httpd = HTTPServer(server_address, RequestHandler)
logger.info("Serving on http://localhost:8000")
httpd.serve_forever()
address = ("", 80)
HTTPServer(address, RequestHandler).serve_forever()


main()
if __name__ == "__main__":
main()
1 change: 0 additions & 1 deletion documentation/source/_static/web_app/.last_build_id

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading