Skip to content

Commit

Permalink
Fix Dockerfile and update workflow to read the rust version
Browse files Browse the repository at this point in the history
Signed-off-by: Doru Blânzeanu <[email protected]>
  • Loading branch information
dblnz committed Nov 13, 2024
1 parent 97fc75c commit 5722d57
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
3 changes: 2 additions & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ FROM mcr.microsoft.com/devcontainers/base:debian AS base

ARG USER=vscode
ARG GROUP=vscode
ARG RUST_TOOLCHAIN=1.81.0

ENV HOME="/home/${USER}"
ENV PATH="$HOME/.cargo/bin:$PATH"
Expand Down Expand Up @@ -49,6 +48,8 @@ RUN SNIPPET="export PROMPT_COMMAND='history -a' && export HISTFILE=/commandhisto

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} \
Expand Down
10 changes: 6 additions & 4 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
{
"name": "Hyperlight",

"image": "ghcr.io/hyperlight-dev/hyperlight-devcontainer:latest",
"image": "ghcr.io/dblnz/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",
"DEVICE": "/dev/kvm"
"REMOTE_GROUP": "vscode"
},

"runArgs": [
Expand All @@ -24,7 +25,8 @@
"vscode": {
"extensions": [
"ms-vscode.cmake-tools",
"rust-lang.rust-analyzer"
"rust-lang.rust-analyzer",
"vadimcn.vscode-lldb"
]
}
}
Expand Down
13 changes: 12 additions & 1 deletion .github/workflows/CreateDevcontainerImage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ 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:
Expand All @@ -13,6 +16,7 @@ env:
USER: vscode
GROUP: vscode
RUST_TOOLCHAIN: 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:
Expand All @@ -29,6 +33,13 @@ jobs:
- 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
id: toolchain
run: |
version=$(cat ${{ env.RUST_TOOLCHAIN_FILE }} | sed -n '/\[toolchain\]/,/^\[/{/^\s*channel = /s/[^"]*"\([^"]*\)".*/\1/p}')
echo "RUST_TOOLCHAIN=${version}" >> "$GITHUB_OUTPUT"
- name: Log in to the Container registry
uses: docker/login-action@v1
with:
Expand All @@ -55,4 +66,4 @@ jobs:
build-args: |
USER=${{ env.USER }}
GROUP=${{ env.GROUP }}
RUST_TOOLCHAIN=${{ env.RUST_TOOLCHAIN }}
RUST_TOOLCHAIN=${{ steps.toolchain.outputs.RUST_TOOLCHAIN }}

0 comments on commit 5722d57

Please sign in to comment.