Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .devcontainer/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
---
title: Dev Container
description: Pre-configured development environment for HVE Core with all required tools and extensions
Expand Down Expand Up @@ -100,7 +100,10 @@

Container won't build: Ensure Docker Desktop is running and you have sufficient disk space (5GB+).

Extensions not loading: Reload the window (`F1` → **Developer: Reload Window**).
1. Extensions not loading: Reload the window (`F1` → **Developer: Reload Window**).

2. HTTP/TLS errors during build: Machines with corporate firewalls performing TLS inspection should ensure they are using the default `desktop-linux` builder, which honors OS root certificate trust stores.
You can change the active builder back to `desktop-linux` by running `docker buildx use desktop-linux`.

For more help, see [SUPPORT.md](../SUPPORT.md).

Expand Down
45 changes: 37 additions & 8 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
{
"name": "HVE Core - Markdown Editing",
"image": "${localEnv:HVE_DEVCONTAINER_IMAGE:mcr.microsoft.com/devcontainers/base:2-jammy}",
// Rename the mount to /workspace for consistency, otherwise its mounted using
// whatever folder name the user cloned the repo as
"workspaceMount": "\"source=${localWorkspaceFolder}\",target=/workspace,type=bind",
"workspaceFolder": "/workspace",
"mounts": [
// Put GitHub local user data in a volume
{
"type": "volume",
"source": "${devcontainerId}-userconfig",
"target": "/home/vscode/.config"
},
// Put node modules into volume for better performance
{
"type": "volume",
"source": "${devcontainerId}-nodemodules",
"target": "/workspace/node_modules"
}
],
"features": {
"ghcr.io/devcontainers/features/node:1": {
"version": "20"
Expand All @@ -9,28 +27,39 @@
"version": "3.11"
},
"ghcr.io/devcontainers/features/git:1": {},
"ghcr.io/devcontainers/features/github-cli:1": {},
"ghcr.io/devcontainers/features/azure-cli:1": {},
"ghcr.io/devcontainers/features/github-cli:1": {},
"ghcr.io/devcontainers/features/powershell:1": {}
},
"customizations": {
"vscode": {
"extensions": [
"streetsidesoftware.code-spell-checker",
"davidanson.vscode-markdownlint",
"yzhang.markdown-all-in-one",
"bierner.markdown-preview-github-styles",
"bierner.markdown-mermaid",
"bierner.markdown-preview-github-styles",
"bpruitt-goddard.mermaid-markdown-syntax-highlighting",
"charliermarsh.ruff",
"davidanson.vscode-markdownlint",
"github.vscode-pull-request-github",
"ms-python.python",
"ms-python.vscode-pylance",
"charliermarsh.ruff"
]
"streetsidesoftware.code-spell-checker",
"yzhang.markdown-all-in-one"
],
"settings": {
// Prevent extensions from stealing focus, see microsoft/vscode#205225
"workbench.view.showQuietly": {
"workbench.panel.output": true
}
}
}
},
// This is to ensure support for config includes is properly handled, see microsoft/vscode-remote-release/2084
"initializeCommand": {
"extractGitGlobals": "(git config -l --global --include || true) > .gitconfig.global",
"extractGitLocals": "(git config -l --local --include || true) > .gitconfig.local"
},
"postAttachCommand": "/bin/bash .devcontainer/scripts/post-attach.sh",
"onCreateCommand": "bash .devcontainer/scripts/on-create.sh",
"updateContentCommand": "npm ci",
"postCreateCommand": "bash .devcontainer/scripts/post-create.sh",
"remoteEnv": {
"HVE_GITHUB_RELEASES_URL": "${localEnv:HVE_GITHUB_RELEASES_URL}",
Expand Down
34 changes: 34 additions & 0 deletions .devcontainer/scripts/post-attach.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: MIT
#
# post-attach.sh
# Post-attach setup for HVE Core development container

set -euo pipefail

# devcontainers copy your local gitconfig but do not parse conditional includes.
# This re-configures the devcontainer git identities based on the prior exported
# global and local git configurations *after* parsing host includes. See also:
# https://github.com/microsoft/vscode-remote-release/issues/2084#issuecomment-2289987894
copy_user_gitconfig() {
for conf in .gitconfig.global .gitconfig.local; do
if [[ -f "$conf" ]]; then
echo "*** Parsing ${conf##.gitconfig.} Git configuration export"
local key value
while IFS='=' read -r key value; do
case "$key" in
user.name | user.email | user.signingkey | commit.gpgsign)
echo "Set Git config ${key}=${value}"
git config --global "$key" "$value"
;;
esac
done < "$conf"
rm -f "${conf}"
fi
done
}

# Main execution path

copy_user_gitconfig
30 changes: 30 additions & 0 deletions .devcontainer/scripts/post-create.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,36 @@ set -euo pipefail
main() {
echo "Creating logs directory..."
mkdir -p logs

fix_volume_ownerships
npm_clean_install
}

# Volume ownership is not set automatically due to a bug:
# https://github.com/microsoft/vscode-remote-release/issues/9931
#
# IMPORTANT: workaround requires Docker base image to have password-less sudo.
fix_volume_ownership() {
local volume_path="$1"

if [[ ! -d "$volume_path" ]]; then
echo "ERROR: the volume path provided '$volume_path' does not exist." >&2
exit 1
fi

echo "Setting volume ownership for $volume_path"
sudo -n chown "${USER}":"${USER}" "$volume_path"
}

fix_volume_ownerships() {
echo "Applying volume ownership workaround (see microsoft/vscode-remote-release#9931)..."
fix_volume_ownership "/home/${USER}/.config"
fix_volume_ownership "/workspace/node_modules"
}

npm_clean_install() {
echo "Running npm ci..."
npm ci
}

main "$@"
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
**/.git/
**/node_modules/
11 changes: 10 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
# Set the default behavior, in case core.autocrlf has not been set.
* text=auto

# Declare files that will always have LF line endings on checkout.
# Declare files that must have specific line endings on checkout.
## Windows scripts - must be CRLF
*.bat text eol=crlf
*.cmd text eol=crlf

## Cross-platform PowerShell scripts - use LF for shebang compatibility
*.ps1 text eol=lf
## Linux scripts - must be LF
*.sh text eol=lf
*.Dockerfile text eol=lf
Dockerfile* text eol=lf

# Denote all files that are truly binary and should not be modified.
*.docx binary
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -466,3 +466,7 @@ dependency-pinning-artifacts/
docs/docusaurus/build/
docs/docusaurus/.docusaurus/
docs/docusaurus/node_modules/

# devcontainer
/.gitconfig.global
/.gitconfig.local
Loading