# ── Javascript ────────────────────────────────────────────────────────── FROM oven/bun:1 AS base-js WORKDIR /usr/src/app # install dependencies into temp directory # this will cache them and speed up future builds FROM base-js AS install COPY package.json bun.lock /temp/dev/ RUN cd /temp/dev && bun install --frozen-lockfile # copy node_modules from temp directory # then copy all (non-ignored) project files into the image FROM base-js AS prerelease COPY --from=install /temp/dev/node_modules node_modules COPY frontend frontend COPY .devfiles/scripts/build-frontend.ts .devfiles/scripts/build-frontend.ts ENV NODE_ENV=production RUN bun ./.devfiles/scripts/build-frontend.ts # ── Rust ──────────────────────────────────────────────────────────────── FROM rust:slim AS base-rust WORKDIR /app COPY . . COPY --from=prerelease /usr/src/app/dist dist RUN cargo build --locked --release FROM scratch AS runner ENV RUST_LOG="compendium=debug,info" COPY --from=base-rust /app/target/release/compendium / EXPOSE 3000 ENTRYPOINT ["./compendium"] CMD ["./compendium"]