Skip to content

Commit 1e96ed6

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

File tree

5 files changed

+38
-2
lines changed

5 files changed

+38
-2
lines changed

.devcontainer/Dockerfile

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

.devcontainer/devcontainer.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
"remoteUser": "vscode",
10+
"containerUser": "vscode",
11+
"features": {
12+
"ghcr.io/devcontainers/features/node:1": {}
13+
},
14+
"containerEnv": {
15+
"DEVICE": "/dev/kvm",
16+
"REMOTE_USER": "vscode",
17+
"REMOTE_GROUP": "vscode"
18+
},
19+
"runArgs": [
20+
"--device=/dev/kvm"
21+
],
22+
"postStartCommand": "bash .devcontainer/setup.sh"
23+
}

.devcontainer/setup.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
3+
# Change device ownership
4+
sudo chown -R $REMOTE_USER:$REMOTE_GROUP $DEVICE
5+
# resolves a npm bug related to these being set to root
6+
sudo chown -R vscode "/home/vscode/.npm"

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ 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 GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/jsturtevant/hyperlight-wasm-calculator-example/tree/dev-container)
16+
17+
[![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)
18+
19+
To build and run this example locally, you need the following tools installed on your system:
1620

1721
- [Rust toolchain](https://www.rust-lang.org/tools/install) including `x86_unknown-none` target
1822
- 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)