Skip to content

Commit 6e50106

Browse files
committed
Add dev container
Signed-off-by: James Sturtevant <jsturtevant@gmail.com>
1 parent 861ab29 commit 6e50106

File tree

5 files changed

+37
-2
lines changed

5 files changed

+37
-2
lines changed

.devcontainer/Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
FROM ghcr.io/hyperlight-dev/hyperlight-wasm-devcontainer:latest
2+
RUN cargo install wac-cli
3+
RUN cargo install --git https://github.com/hyperlight-dev/hyperlight-wasm hyperlight-wasm-aot
4+
RUN cargo install cargo-component --locked

.devcontainer/devcontainer.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/rust
3+
{
4+
"name": "Rust",
5+
"build": {
6+
// Path is relative to the devcontainer.json file.
7+
"dockerfile": "Dockerfile"
8+
},
9+
"containerUser": "vscode",
10+
"features": {
11+
"ghcr.io/devcontainers/features/node:1": {}
12+
},
13+
"containerEnv": {
14+
"DEVICE": "/dev/kvm",
15+
"REMOTE_USER": "vscode",
16+
"REMOTE_GROUP": "vscode"
17+
},
18+
"runArgs": [
19+
"--device=/dev/kvm"
20+
],
21+
"postStartCommand": "bash .devcontainer/setup.sh",
22+
}

.devcontainer/setup.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
# Change device ownership
4+
sudo chown -R $REMOTE_USER:$REMOTE_GROUP $DEVICE

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@ The [example](./example/) program loads the composed calculator/wasm component i
1212

1313
## Requirements
1414

15-
To build and run this example, you need the following tools installed on your system:
15+
[![Open in VS Code Container](https://img.shields.io/static/v1?label=Remote%20-%20Containers&message=Open&color=blue&logo=visualstudiocode)](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/jsturtevant/hyperlight-wasm-calculator-example/tree/dev-container)
16+
17+
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/jsturtevant/hyperlight-wasm-calculator-example/tree/dev-container)
18+
19+
20+
To build and run this example locally, you need the following tools installed on your system:
1621

1722
- [Rust toolchain](https://www.rust-lang.org/tools/install) including `x86_unknown-none` target
1823
- https://www.rust-lang.org/tools/install

example/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ fn main() {
4141
let rt = crate::bindings::register_host_functions(&mut sb, state);
4242
// Initialise the Wasm engine inside the sandbox
4343
let sb = sb.load_runtime().unwrap();
44-
let sb = sb.load_module("calculator-composed.bin").unwrap();
44+
let sb = sb.load_module("calculator-composed.bin").expect("missing calculator module. build the components first");
4545
// Wrap up the sandbox and the resources to get something which
4646
// we can instantiate and run methods against
4747
let mut wrapped = bindings::CalculatorSandbox {sb, rt};

0 commit comments

Comments
 (0)