From c3deb04a14f23469dd1c05fbb3e01f6e087356ec Mon Sep 17 00:00:00 2001 From: Joakim Hulthe Date: Mon, 29 Dec 2025 19:27:48 +0100 Subject: [PATCH] dockerfile: Bundle the gui as a web application --- Dockerfile | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3374a97..efc1be7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,12 +3,14 @@ ################## FROM rust:1.92.0 AS base -# Install build dependencies -# RUN cargo install --locked trunk@^0.18.8 strip_cargo_version -RUN cargo install --locked strip_cargo_version@0.0.3 -# RUN rustup target add wasm32-unknown-unknown +RUN rustup target add wasm32-unknown-unknown RUN rustup target add x86_64-unknown-linux-musl +# Install build dependencies +RUN curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash +RUN cargo install --locked strip_cargo_version@0.0.3 +RUN cargo binstall wasm-pack@0.13.1 + # required by "ring" RUN apt-get update && apt-get install -y musl-tools @@ -43,10 +45,8 @@ COPY --from=strip-version /app/Cargo.toml /app/Cargo.lock /app/ # Compile dependencies first, so that they are cached by Docker WORKDIR /app/srv RUN cargo build --release --target x86_64-unknown-linux-musl - -# TODO: build gui for wasm -# WORKDIR /app/gui -# RUN cargo build --release --target wasm32-unknown-unknown +WORKDIR /app/gui +RUN cargo build --release --target wasm32-unknown-unknown WORKDIR /app COPY . . @@ -54,10 +54,8 @@ COPY . . WORKDIR /app/srv RUN cargo build --release --target x86_64-unknown-linux-musl RUN strip /app/target/x86_64-unknown-linux-musl/release/inkopslista-srv - -# TODO: build gui for wasm -# WORKDIR /app/gui -# RUN trunk build --release +WORKDIR /app/gui +RUN wasm-pack build --release --target web ######################## ### PRODUCTION STAGE ### @@ -75,9 +73,8 @@ WORKDIR / # Copy application binary COPY --from=build /app/target/x86_64-unknown-linux-musl/release/inkopslista-srv / - -# TODO: -# # Copy static web files -# COPY --from=build /app/frontend/dist /www +# Copy web bundle +COPY --from=build /app/gui/index.html /www/index.html +COPY --from=build /app/gui/pkg /www/pkg CMD ["/inkopslista-srv"]