Skip to content

Add dev container for the example #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM ghcr.io/hyperlight-dev/hyperlight-devcontainer:latest

RUN cargo install --git https://github.com/hyperlight-dev/hyperlight-wasm hyperlight-wasm-aot
23 changes: 23 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/rust
{
"name": "Rust",
"build": {
// Path is relative to the devcontainer.json file.
"dockerfile": "Dockerfile"
},
"remoteUser": "vscode",
"containerUser": "vscode",
"features": {
"ghcr.io/devcontainers/features/node:1": {}
},
"containerEnv": {
"DEVICE": "/dev/kvm",
"REMOTE_USER": "vscode",
"REMOTE_GROUP": "vscode"
},
"runArgs": [
"--device=/dev/kvm"
],
"postStartCommand": "bash .devcontainer/setup.sh"
}
6 changes: 6 additions & 0 deletions .devcontainer/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

# Change device ownership
sudo chown -R $REMOTE_USER:$REMOTE_GROUP $DEVICE
# resolves a npm bug related to these being set to root
sudo chown -R vscode "/home/vscode/.npm"
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ The [example](./example/) program loads the composed calculator/wasm component i

## Requirements

To build and run this example, you need the following tools installed on your system:
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/hyperlight-dev/hyperlight-wasm-calculator-example/)

[![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/hyperlight-dev/hyperlight-wasm-calculator-example)

To build and run this example locally, you need the following tools installed on your system:

- [Rust toolchain](https://www.rust-lang.org/tools/install) including `x86_unknown-none` target
- https://www.rust-lang.org/tools/install
Expand Down
2 changes: 1 addition & 1 deletion example/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ fn main() {
let rt = crate::bindings::register_host_functions(&mut sb, state);
// Initialise the Wasm engine inside the sandbox
let sb = sb.load_runtime().unwrap();
let sb = sb.load_module("calculator-composed.bin").unwrap();
let sb = sb.load_module("calculator-composed.bin").expect("missing calculator module. build the components first");
// Wrap up the sandbox and the resources to get something which
// we can instantiate and run methods against
let mut wrapped = bindings::CalculatorSandbox {sb, rt};
Expand Down