Dockerfile 901 B

123456789101112131415161718192021222324252627
  1. # syntax=docker/dockerfile:1
  2. FROM --platform=$BUILDPLATFORM rust:1.64 AS buildbase
  3. RUN <<EOT bash
  4. set -ex
  5. apt-get update
  6. apt-get install -y \
  7. git \
  8. clang
  9. rustup target add wasm32-wasi
  10. EOT
  11. # This line installs WasmEdge including the AOT compiler
  12. RUN curl -sSf https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/utils/install.sh | bash
  13. FROM buildbase AS build
  14. COPY Cargo.toml .
  15. COPY src ./src
  16. # Build the Wasm binary
  17. RUN --mount=type=cache,target=/usr/local/cargo/git/db \
  18. --mount=type=cache,target=/usr/local/cargo/registry/cache \
  19. --mount=type=cache,target=/usr/local/cargo/registry/index \
  20. cargo build --target wasm32-wasi --release
  21. # This line builds the AOT Wasm binary
  22. RUN /root/.wasmedge/bin/wasmedgec target/wasm32-wasi/release/kafka.wasm kafka.wasm
  23. FROM scratch
  24. ENTRYPOINT [ "kafka.wasm" ]
  25. COPY --link --from=build /kafka.wasm /kafka.wasm