mirror of
https://github.com/kanidm/kanidm.git
synced 2025-02-22 20:26:30 +01:00
Devcontainertainertainer (#3251)
This commit is contained in:
parent
ac3cf1f363
commit
4f53bce3d3
|
@ -2,7 +2,8 @@
|
|||
// README at: https://github.com/devcontainers/templates/tree/main/src/rust
|
||||
{
|
||||
"name": "Rust",
|
||||
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
|
||||
|
||||
// https://github.com/devcontainers/images/tree/main/src/rust
|
||||
"image": "mcr.microsoft.com/devcontainers/rust:1-1-bookworm",
|
||||
"features": {
|
||||
},
|
||||
|
@ -13,6 +14,11 @@
|
|||
"source": "devcontainer-cargo-cache-${devcontainerId}",
|
||||
"target": "/usr/local/cargo",
|
||||
"type": "volume"
|
||||
},
|
||||
{
|
||||
"source": "devcontainer-sccache-cache-${devcontainerId}",
|
||||
"target": "/home/vscode/.cache/sccache",
|
||||
"type": "volume"
|
||||
}
|
||||
],
|
||||
// Features to add to the dev container. More info: https://containers.dev/features.
|
||||
|
@ -21,7 +27,17 @@
|
|||
// Use 'forwardPorts' to make a list of ports inside the container available locally.
|
||||
"forwardPorts": [8443],
|
||||
// Use 'postCreateCommand' to run commands after the container is created.
|
||||
"postCreateCommand": "rustup update && rustup default stable && rustup component add rustfmt clippy && sudo apt-get update && sudo apt-get install -y sccache ripgrep libssl-dev pkg-config jq libpam0g-dev libudev-dev cmake build-essential && cargo install cargo-audit mdbook-mermaid mdbook && cargo install mdbook-alerts --version 0.6.4 && cargo install deno --locked"
|
||||
"postCreateCommand": "./scripts/devcontainer_postcreate.sh",
|
||||
|
||||
// postStartCommand runs things once the container's up, in this case, we're starting sccache
|
||||
"postStartCommand": "./scripts/devcontainer_poststart.sh",
|
||||
|
||||
// environment variables
|
||||
"containerEnv": {
|
||||
// "RUSTC_WRAPPER": "sccache",
|
||||
// "CC":"/usr/bin/sccache /usr/bin/clang",
|
||||
"SCCACHE_SERVER_UDS" : "/tmp/sccache.sock"
|
||||
}
|
||||
|
||||
// Configure tool-specific properties.
|
||||
// "customizations": {},
|
||||
|
|
46
scripts/devcontainer_postcreate.sh
Executable file
46
scripts/devcontainer_postcreate.sh
Executable file
|
@ -0,0 +1,46 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
echo "Installing rust stable toolchain"
|
||||
rustup update
|
||||
rustup default stable
|
||||
rustup component add rustfmt clippy
|
||||
|
||||
echo "Installing packages"
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y \
|
||||
build-essential \
|
||||
clang \
|
||||
cmake \
|
||||
libtss2-dev \
|
||||
tpm-udev \
|
||||
jq \
|
||||
libpam0g-dev \
|
||||
libssl-dev \
|
||||
libudev-dev \
|
||||
pkg-config \
|
||||
ripgrep
|
||||
|
||||
export PATH="$HOME/.cargo/bin:$PATH"
|
||||
|
||||
cargo install \
|
||||
sccache
|
||||
|
||||
|
||||
# stupid permissions issues
|
||||
sudo chown vscode ~/ -R
|
||||
sudo chgrp vscode ~/ -R
|
||||
|
||||
# shellcheck disable=SC1091
|
||||
source scripts/devcontainer_poststart.sh
|
||||
|
||||
cargo install
|
||||
cargo-audit \
|
||||
mdbook-mermaid \
|
||||
mdbook
|
||||
cargo install mdbook-alerts --version 0.6.4
|
||||
cargo install deno --locked
|
||||
|
||||
|
||||
echo "Done!"
|
21
scripts/devcontainer_poststart.sh
Executable file
21
scripts/devcontainer_poststart.sh
Executable file
|
@ -0,0 +1,21 @@
|
|||
#!/bin/bash
|
||||
|
||||
# stupid permissions issues
|
||||
sudo chown vscode ~/ -R
|
||||
sudo chgrp vscode ~/ -R
|
||||
|
||||
export PATH="$HOME/.cargo/bin:$PATH"
|
||||
SCCACHE_SERVER_UDS="/tmp/sccache.sock" sccache --start-server
|
||||
|
||||
# to set up sccache etc
|
||||
if [ "$(grep -c "devcontainer_poststart" ~/.bashrc)" -eq 0 ]; then
|
||||
echo "adding devcontainer_poststart to bashrc"
|
||||
echo "source /workspaces/kanidm/scripts/devcontainer_poststart.sh" >> ~/.bashrc
|
||||
fi
|
||||
export RUSTC_WRAPPER="sccache"
|
||||
export CC="sccache /usr/bin/clang"
|
||||
|
||||
# disable incremental builds
|
||||
# cargo docs: https://doc.rust-lang.org/cargo/reference/profiles.html#incremental
|
||||
# sccache docs on why to disable incremental builds: https://github.com/mozilla/sccache#known-caveats
|
||||
export CARGO_INCREMENTAL=false
|
Loading…
Reference in a new issue