Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
nfrankel committed Jan 27, 2025
0 parents commit 7d4ffc3
Show file tree
Hide file tree
Showing 14 changed files with 1,936 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
target
*.iml
.idea
27 changes: 27 additions & 0 deletions Dockerfile.embed
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#docker build --platform=linux/arm64 -f Dockerfile.embed -t wasm-kubernetes:embed .
FROM --platform=$BUILDPLATFORM rust:1.84-slim AS build

RUN <<EOT bash
set -ex
apt-get update
apt-get install -y git clang
rustup target add wasm32-wasip1
EOT

WORKDIR /wasm

COPY wasm/Cargo.toml Cargo.toml

WORKDIR /

COPY src src

WORKDIR /wasm

RUN RUSTFLAGS="--cfg wasmedge --cfg tokio_unstable" cargo build --target wasm32-wasip1 --release

FROM --platform=$BUILDPLATFORM wasmedge/slim-runtime:0.13.5

COPY --from=build /wasm/target/wasm32-wasip1/release/httpbin.wasm /httpbin.wasm

CMD ["wasmedge", "--dir", ".:/", "/httpbin.wasm"]
28 changes: 28 additions & 0 deletions Dockerfile.native
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#docker build -f Dockerfile.native -t wasm-kubernetes:native .
FROM rust:1.84-slim AS build

RUN <<EOB

apt-get update
apt-get install -y musl-tools musl-dev
rustup target add aarch64-unknown-linux-musl

EOB

WORKDIR /native

COPY native/Cargo.toml Cargo.toml

WORKDIR /

COPY src src

WORKDIR /native

RUN RUSTFLAGS="-C target-feature=+crt-static" cargo build --target aarch64-unknown-linux-musl --release

FROM gcr.io/distroless/static

COPY --from=build /native/target/aarch64-unknown-linux-musl/release/httpbin httpbin

ENTRYPOINT ["./httpbin"]
27 changes: 27 additions & 0 deletions Dockerfile.runtime
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#docker build --platform=wasi/wasm,linux/arm64 -f Dockerfile.runtime -t wasm-kubernetes:runtime .
FROM --platform=$BUILDPLATFORM rust:1.84-slim AS build

RUN <<EOT bash
set -ex
apt-get update
apt-get install -y git clang
rustup target add wasm32-wasip1
EOT

WORKDIR /wasm

COPY wasm/Cargo.toml Cargo.toml

WORKDIR /

COPY src src

WORKDIR /wasm

RUN RUSTFLAGS="--cfg wasmedge --cfg tokio_unstable" cargo build --target wasm32-wasip1 --release

FROM scratch

COPY --from=build /wasm/target/wasm32-wasip1/release/httpbin.wasm /httpbin.wasm

ENTRYPOINT ["/httpbin.wasm"]
4 changes: 4 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
docker build -f Dockerfile.native -t wasm-kubernetes:native .
docker build --platform=linux/arm64 -f Dockerfile.embed -t wasm-kubernetes:embed .
docker build --platform=wasi/wasm,linux/arm64 -f Dockerfile.runtime -t wasm-kubernetes:runtime .
Empty file added deploy.yaml
Empty file.
Loading

0 comments on commit 7d4ffc3

Please sign in to comment.