|
| 1 | +FROM rust:1.91.1-trixie AS builder |
| 2 | + |
| 3 | +# Install cargo-binstall, which makes it easier to install other |
| 4 | +# cargo extensions like cargo-leptos |
| 5 | +RUN wget https://github.com/cargo-bins/cargo-binstall/releases/latest/download/cargo-binstall-x86_64-unknown-linux-musl.tgz |
| 6 | +RUN tar -xvf cargo-binstall-x86_64-unknown-linux-musl.tgz |
| 7 | +RUN cp cargo-binstall /usr/local/cargo/bin |
| 8 | + |
| 9 | +# Install required tools |
| 10 | +RUN apt-get update -y \ |
| 11 | + && apt-get install -y --no-install-recommends clang |
| 12 | + |
| 13 | +# Install cargo-leptos |
| 14 | +RUN cargo binstall cargo-leptos -y |
| 15 | + |
| 16 | +# Add the WASM target |
| 17 | +RUN rustup target add wasm32-unknown-unknown |
| 18 | + |
| 19 | +# Make an /explorer_service dir, which everything will eventually live in |
| 20 | +RUN mkdir -p /explorer_service |
| 21 | +WORKDIR /explorer_service |
| 22 | +COPY . . |
| 23 | + |
| 24 | +# Build the app |
| 25 | +RUN cargo leptos build --release -vv |
| 26 | + |
| 27 | +FROM debian:trixie-slim AS runtime |
| 28 | +WORKDIR /explorer_service |
| 29 | +RUN apt-get update -y \ |
| 30 | + && apt-get install -y --no-install-recommends openssl ca-certificates \ |
| 31 | + && apt-get autoremove -y \ |
| 32 | + && apt-get clean -y \ |
| 33 | + && rm -rf /var/lib/apt/lists/* |
| 34 | + |
| 35 | +# Copy the server binary to the /explorer_service directory |
| 36 | +COPY --from=builder /explorer_service/target/release/explorer_service /explorer_service/ |
| 37 | + |
| 38 | +# /target/site contains our JS/WASM/CSS, etc. |
| 39 | +COPY --from=builder /explorer_service/target/site /explorer_service/site |
| 40 | + |
| 41 | +# Copy Cargo.toml as it’s needed at runtime |
| 42 | +COPY --from=builder /explorer_service/Cargo.toml /explorer_service/ |
| 43 | + |
| 44 | +# Set any required env variables |
| 45 | +ENV RUST_LOG="info" |
| 46 | +ENV LEPTOS_SITE_ADDR="0.0.0.0:8080" |
| 47 | +ENV LEPTOS_SITE_ROOT="site" |
| 48 | +ENV INDEXER_RPC_URL="http://localhost:8779" |
| 49 | +EXPOSE 8080 |
| 50 | + |
| 51 | +# Run the server |
| 52 | +CMD ["/explorer_service/explorer_service"] |
0 commit comments