FROM rust:alpine as backend WORKDIR /home/rust/src RUN apk --no-cache add musl-dev openssl-dev COPY . . RUN cargo test --release RUN cargo build --release FROM rust:alpine as wasm WORKDIR /home/rust/src RUN apk --no-cache add curl musl-dev RUN curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh COPY . . RUN wasm-pack build --target web cstudio-wasm FROM node:lts-alpine as frontend WORKDIR /usr/src/app COPY package.json package-lock.json ./ COPY --from=wasm /home/rust/src/cstudio-wasm/pkg cstudio-wasm/pkg RUN npm ci COPY . . RUN npm run build FROM scratch COPY --from=frontend /usr/src/app/dist dist COPY --from=backend /home/rust/src/target/release/cstudio-server . USER 1000:1000 CMD [ "./cstudio-server" ]