-
Notifications
You must be signed in to change notification settings - Fork 151
Add devcontainer config #54
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
Merged
Merged
Changes from 8 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
030752d
Add dev container configuration
dblnz db9a21c
Change the link to GHCR image
dblnz 3beb33a
Change device ownership inside the container
dblnz c3219dd
Update Dockerfile in github action
dblnz 150821a
Update GHCR link to use the hyperlight-dev container image
dblnz 97fc75c
Add defaults to arguments of container image Dockerfile
dblnz e79297a
Fix Dockerfile and update workflow to read the rust version
dblnz 5af8753
Add codespace reference to README.md
dblnz 191a73c
Remove unused persmission for gh workflow
dblnz 16cd0d5
Small changes to comments and bash script for consistency
dblnz 6ebdefb
Merge branch 'main' into add-dev-container
dblnz 2c20636
Merge branch 'main' into add-dev-container
dblnz 8ce8fb6
Add gnuplot to devcontainer image
dblnz e2a1c1f
Merge branch 'main' into add-dev-container
dblnz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
## Dockerfile for devcontainer | ||
|
||
FROM mcr.microsoft.com/devcontainers/base:debian AS base | ||
|
||
ARG USER=vscode | ||
ARG GROUP=vscode | ||
|
||
ENV HOME="/home/${USER}" | ||
ENV PATH="$HOME/.cargo/bin:$PATH" | ||
|
||
# Install dependencies | ||
RUN apt-get update \ | ||
&& apt-get -y install \ | ||
build-essential \ | ||
cmake \ | ||
curl \ | ||
git \ | ||
gnupg \ | ||
lsb-release \ | ||
make \ | ||
software-properties-common \ | ||
sudo \ | ||
wget | ||
|
||
ARG LLVM_VERSION=17 | ||
|
||
# Install llvm | ||
RUN wget https://apt.llvm.org/llvm.sh \ | ||
&& chmod +x ./llvm.sh \ | ||
&& sudo ./llvm.sh ${LLVM_VERSION} all \ | ||
&& sudo ln -s /usr/lib/llvm-${LLVM_VERSION}/bin/clang-cl /usr/bin/clang-cl \ | ||
&& sudo ln -s /usr/lib/llvm-${LLVM_VERSION}/bin/llvm-lib /usr/bin/llvm-lib \ | ||
&& sudo ln -s /usr/lib/llvm-${LLVM_VERSION}/bin/lld-link /usr/bin/lld-link \ | ||
&& sudo ln -s /usr/lib/llvm-${LLVM_VERSION}/bin/llvm-ml /usr/bin/llvm-ml \ | ||
&& sudo ln -s /usr/lib/llvm-${LLVM_VERSION}/bin/ld.lld /usr/bin/ld.lld \ | ||
&& sudo ln -s /usr/lib/llvm-${LLVM_VERSION}/bin/clang /usr/bin/clang | ||
|
||
FROM base AS dev | ||
|
||
# Make sure the devcontainer user has sudo access | ||
RUN chown -R "${USER}:${GROUP}" /home/${USER} \ | ||
&& echo "${USER} ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers | ||
|
||
# Persist bash hystory | ||
RUN SNIPPET="export PROMPT_COMMAND='history -a' && export HISTFILE=/commandhistory/.bash_history" \ | ||
&& mkdir /commandhistory \ | ||
&& touch /commandhistory/.bash_history \ | ||
&& chown -R "${USER}" /commandhistory \ | ||
&& echo "$SNIPPET" >> "/home/${USER}/.bashrc" | ||
|
||
USER $USER | ||
|
||
ARG RUST_TOOLCHAIN=1.81.0 | ||
|
||
# Install rust | ||
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y \ | ||
&& rustup default ${RUST_TOOLCHAIN} \ | ||
&& rustup target add x86_64-unknown-linux-gnu \ | ||
&& rustup target add x86_64-unknown-none \ | ||
&& rustup target add x86_64-pc-windows-msvc \ | ||
&& cargo install just | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// For more info on the configuration below, check out the link: | ||
// https://code.visualstudio.com/docs/devcontainers/create-dev-container | ||
{ | ||
"name": "Hyperlight", | ||
|
||
"image": "ghcr.io/hyperlight-dev/hyperlight-devcontainer:latest", | ||
|
||
"containerUser": "vscode", | ||
// Environment for the container also used by in the `postCreateCommand` | ||
"containerEnv": { | ||
"DEVICE": "/dev/kvm", | ||
"KVM_SHOULD_BE_PRESENT": "true", | ||
"REMOTE_USER": "vscode", | ||
"REMOTE_GROUP": "vscode" | ||
}, | ||
|
||
"runArgs": [ | ||
"--device=/dev/kvm" | ||
], | ||
|
||
// Use 'postCreateCommand' to run commands after the container is created | ||
"postCreateCommand": "bash .devcontainer/setup.sh", | ||
|
||
"customizations": { | ||
"vscode": { | ||
"extensions": [ | ||
"ms-vscode.cmake-tools", | ||
"rust-lang.rust-analyzer", | ||
"vadimcn.vscode-lldb" | ||
] | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash | ||
|
||
# Change device ownership | ||
sudo chown -R $REMOTE_USER:$REMOTE_GROUP ${DEVICE} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
name: Create and publish devcontainer Docker image | ||
|
||
on: | ||
push: | ||
branches: | ||
- "main" | ||
paths: | ||
- ".devcontainer/Dockerfile" | ||
- ".github/workflows/CreateDevcontainerImage.yml" | ||
- "rust-toolchain.toml" | ||
|
||
# Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds. | ||
env: | ||
REGISTRY: ghcr.io | ||
IMAGE_NAME: ${{ github.repository }}-devcontainer | ||
USER: vscode | ||
GROUP: vscode | ||
LLVM_VERSION: 17 | ||
RUST_TOOLCHAIN_DEFAULT: 1.81.0 | ||
RUST_TOOLCHAIN_FILE: rust-toolchain.toml | ||
|
||
# There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu. | ||
jobs: | ||
build-and-push-image: | ||
runs-on: ubuntu-latest | ||
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job. | ||
permissions: | ||
contents: read | ||
packages: write | ||
attestations: write | ||
id-token: write | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
# Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here. | ||
|
||
- name: Read Rust toolchain version from ${{ env.RUST_TOOLCHAIN_FILE }} | ||
id: toolchain | ||
run: | | ||
version=$(cat ${{ env.RUST_TOOLCHAIN_FILE }} | sed -n '/\[toolchain\]/,/^\[/{/^\s*channel = /s/[^"]*"\([^"]*\)".*/\1/p}') | ||
cat ${{ env.RUST_TOOLCHAIN_FILE }} | grep $version &> /dev/null \ | ||
&& echo "RUST_TOOLCHAIN=${version}" >> "$GITHUB_OUTPUT" \ | ||
|| echo "RUST_TOOLCHAIN=${{ env.RUST_TOOLCHAIN_FILE }}" >> "$GITHUB_OUTPUT" | ||
|
||
- name: Log in to the Container registry | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Extract metadata (tags, labels) for Docker | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
|
||
- name: Build and push Docker image | ||
id: push | ||
uses: docker/build-push-action@v6 | ||
with: | ||
context: ./.devcontainer | ||
push: true | ||
tags: | | ||
${{ steps.meta.outputs.tags }} | ||
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest | ||
labels: ${{ steps.meta.outputs.labels }} | ||
build-args: | | ||
USER=${{ env.USER }} | ||
GROUP=${{ env.GROUP }} | ||
LLVM_VERSION=${{ env.LLVM_VERSION }} | ||
RUST_TOOLCHAIN=${{ steps.toolchain.outputs.RUST_TOOLCHAIN }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -474,4 +474,4 @@ hyperlight_guest.h | |
# created by vs code c# extension | ||
.mono | ||
|
||
!.gitkeep | ||
!.gitkeep |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.