Build docker container from Rust workspace with multiple projects

I have a Rust workspace project with multiple sub projects. I would like to build these inside of docker. I cannot use cargo build at root because some of these projects are wasm projects and use Trunk to build.
The core issue I'm finding is that when I do WORKDIR and move to a new directory, the parent directories are no longer accessible. For example the dockerfile shown below copies my entire workspace into /usr/src/rustyindie-web and then later on it switches WORKDIR to /usr/src/rustyindie-web/web and runs its Trunk build. This build fails because since the project is a workspace the target folder is in the parent /usr/src/rustyindie-web folder, which seems inaccessible from /usr/src/rustyindie-web/web. And so I get this error

101.4 2024-02-11T22:38:17.466542Z INFO installing wasm-bindgen
101.5 2024-02-11T22:38:17.584484Z INFO calling wasm-bindgen for rustyindie-web
101.5 2024-02-11T22:38:17.587681Z ERROR error
101.5 error from build pipeline
101.5 Caused by:
101.5 0: HTML build pipeline failed (1 errors), showing first
101.5 1: error from asset pipeline
101.5 2: wasm-bindgen not found
101.5 3: error running wasm-bindgen using executable '/root/.cache/trunk/wasm-bindgen-0.2.89/wasm-bindgen' with args: '["--target=web", "--out-dir=/usr/src/rustyindie-web/target/wasm-bindgen/release", "--out-name=rustyindie-web-bb804058ded840db", "/usr/src/rustyindie-web/target/wasm32-unknown-unknown/release/rustyindie-web.wasm", "--no-typescript"]'
101.5 4: No such file or directory (os error 2)
101.5 Error: error from build pipeline

FROM rustlang/rust:nightly-alpine as builder
WORKDIR /usr/src/rustyindie-web
COPY . .
RUN apk add musl-dev
RUN rustup target add wasm32-unknown-unknown
RUN cargo install wasm-bindgen-cli
RUN cargo install trunk
# first setup web build
WORKDIR /usr/src/rustyindie-web/web
RUN cargo install wasm-bindgen-cli
RUN cargo install trunk
RUN trunk build --release

Could you replace the second WORKDIR with RUN cd?

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.