mirror of
https://github.com/prometheus-community/smartctl_exporter.git
synced 2024-11-16 01:33:07 +01:00
Add: Devcontainer support
Signed-off-by: David Randall <David@NiceGuyIT.biz>
This commit is contained in:
parent
1f56220657
commit
715f3a465c
3 changed files with 61 additions and 0 deletions
38
.devcontainer/devcontainer.json
Normal file
38
.devcontainer/devcontainer.json
Normal file
|
@ -0,0 +1,38 @@
|
|||
{
|
||||
"name": "Default dev container",
|
||||
"image": "mcr.microsoft.com/devcontainers/go:1.20",
|
||||
// GitHub's devcontainers are in increments of 2 core/8GB memory. Specifying less will use the minimum.
|
||||
// https://docs.github.com/en/billing/managing-billing-for-github-codespaces/about-billing-for-github-codespaces#pricing-for-paid-usage
|
||||
"hostRequirements": {
|
||||
"cpus": 1,
|
||||
"memory": "4gb"
|
||||
},
|
||||
"waitFor": "onCreateCommand",
|
||||
"updateContentCommand": {
|
||||
"install": "sudo apt-get update && sudo apt-get install --no-install-recommends -y smartmontools vim",
|
||||
// Modify the environment to provide better developer experience.
|
||||
"modify-environment": "${PWD}/scripts/modify-environment.sh"
|
||||
},
|
||||
"postCreateCommand": {
|
||||
},
|
||||
"customizations": {
|
||||
"codespaces": {
|
||||
// Open files upon start
|
||||
"openFiles": [
|
||||
"metrics.go",
|
||||
"smartctl.go"
|
||||
]
|
||||
},
|
||||
"vscode": {
|
||||
// VS Code extensions to install
|
||||
"extensions": [
|
||||
"streetsidesoftware.code-spell-checker",
|
||||
"timonwong.shellcheck",
|
||||
"golang.Go"
|
||||
],
|
||||
"settings": {
|
||||
"shellcheck.customArgs": ["-x"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -4,6 +4,9 @@
|
|||
/.tarballs
|
||||
debug/
|
||||
|
||||
# .cache is used to store transient data (bash history) in devcontainers.
|
||||
.cache/
|
||||
|
||||
Manifest
|
||||
smartctl_exporter
|
||||
*.exe
|
||||
|
|
20
scripts/modify-environment.sh
Normal file
20
scripts/modify-environment.sh
Normal file
|
@ -0,0 +1,20 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# This script modifies the environemnt, namely ~/.bashrc, to preserve the bash history.
|
||||
|
||||
# The workspace in the devcontainer is preserved across rebuilds.
|
||||
# Use .cache to keep history and local scripts.
|
||||
# .cache is excluded from git (i.e. in .gitignore)
|
||||
mkdir -p "${PWD}/.cache/"
|
||||
|
||||
# Preserve history
|
||||
[[ ! -L "${HOME}/.bash_history" ]] && ln -sf "${PWD}/.cache/bash_history" "${HOME}/.bash_history"
|
||||
[[ ! -f "${PWD}/.cache/bash_history" ]] && touch "${PWD}/.cache/bash_history"
|
||||
|
||||
# Write history after every command to preserve it across rebuilds.
|
||||
if ! grep -q '^### CUSTOM: Preserve Bash History ###$' "${HOME}/.bashrc"; then
|
||||
cat >> "${HOME}/.bashrc" <<'EOT'
|
||||
### CUSTOM: Preserve Bash History ###
|
||||
PROMPT_COMMAND="history -a; ${PROMPT_COMMAND}"
|
||||
EOT
|
||||
fi
|
Loading…
Reference in a new issue