From 11f0fd7fd9673996d8d2381ade1a371f945f1875 Mon Sep 17 00:00:00 2001 From: Kyle VanderBeek Date: Sat, 9 Mar 2024 19:45:50 +0000 Subject: [PATCH 1/4] Convert to lightweight dev container; simplify. Instead of running `rustup` on a multi-gigabyte general-purpose Linux base, use the premade devcontainers/rust:1 which closely tracks the rust toolchain releases. Rip out excess setup steps since devcontainers come with the repo checked out; just compile/update the binary. --- .devcontainer/devcontainer.json | 8 +------- .devcontainer/setup.sh | 7 ------- 2 files changed, 1 insertion(+), 14 deletions(-) delete mode 100755 .devcontainer/setup.sh diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index e1b2cec..59f9571 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,12 +1,6 @@ { - "image": "mcr.microsoft.com/devcontainers/universal:2-linux", - "waitFor": "onCreateCommand", - "onCreateCommand": ".devcontainer/setup.sh", + "image": "mcr.microsoft.com/devcontainers/rust:1", "updateContentCommand": "cargo build", - "postCreateCommand": "", - "postAttachCommand": { - "server": "rustlings watch" - }, "customizations": { "vscode": { "extensions": [ diff --git a/.devcontainer/setup.sh b/.devcontainer/setup.sh deleted file mode 100755 index 0e090a8..0000000 --- a/.devcontainer/setup.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash -curl https://sh.rustup.rs -sSf | sh -s -- -y - -# Update current shell environment variables after install to find rustup -. "$HOME/.cargo/env" -rustup install stable -bash install.sh From e424e9f6c78ec54c5a91b942398f7012f46f6c90 Mon Sep 17 00:00:00 2001 From: Kyle VanderBeek Date: Sat, 9 Mar 2024 20:07:51 +0000 Subject: [PATCH 2/4] Add target directory to $PATH Makes the pre-built command work in the shell right away. --- .devcontainer/devcontainer.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 59f9571..643021a 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,6 +1,9 @@ { "image": "mcr.microsoft.com/devcontainers/rust:1", "updateContentCommand": "cargo build", + "remoteEnv": { + "PATH": "${containerEnv:PATH}:${containerWorkspaceFolder}/target/debug" + }, "customizations": { "vscode": { "extensions": [ From 77903200a0c19ef4ad2de7b2abec06e301d0dccc Mon Sep 17 00:00:00 2001 From: Kyle VanderBeek Date: Sat, 9 Mar 2024 20:20:14 +0000 Subject: [PATCH 3/4] Remove duplicate vscode extension list. It's already in the vendor-specific .vscode files. --- .devcontainer/devcontainer.json | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 643021a..a7f4f78 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -3,12 +3,5 @@ "updateContentCommand": "cargo build", "remoteEnv": { "PATH": "${containerEnv:PATH}:${containerWorkspaceFolder}/target/debug" - }, - "customizations": { - "vscode": { - "extensions": [ - "rust-lang.rust-analyzer" - ] - } } } From 2fb135026cd3b072a54fdd211405090afca6f75e Mon Sep 17 00:00:00 2001 From: Kyle VanderBeek Date: Sat, 9 Mar 2024 23:18:31 +0000 Subject: [PATCH 4/4] Add back the post-attach watch. --- .devcontainer/devcontainer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index a7f4f78..f25e8bd 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,6 +1,7 @@ { "image": "mcr.microsoft.com/devcontainers/rust:1", - "updateContentCommand": "cargo build", + "updateContentCommand": ["cargo", "build"], + "postAttachCommand": ["rustlings", "watch"], "remoteEnv": { "PATH": "${containerEnv:PATH}:${containerWorkspaceFolder}/target/debug" }