dockerfile: Bundle the gui as a web application

This commit is contained in:
2025-12-29 19:27:48 +01:00
parent 9230b79cdb
commit c3deb04a14
+13 -16
View File
@@ -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"]