-
Notifications
You must be signed in to change notification settings - Fork 4.1k
corrected devcontainer to work on arm64 computers #28939
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
1b390d3
d2a8529
bc262d1
b611cd1
159369f
a7222e6
f953f43
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,9 @@ | ||||||||
| # Dockerfile for Azure PowerShell devcontainer | ||||||||
| # Use official .NET 8.0 image for amd64 architecture | ||||||||
| FROM --platform=linux/amd64 mcr.microsoft.com/devcontainers/dotnet:1-8.0 | ||||||||
|
|
||||||||
| # Set working directory | ||||||||
| WORKDIR /workspace | ||||||||
|
|
||||||||
|
Comment on lines
+5
to
+7
|
||||||||
| # Set working directory | |
| WORKDIR /workspace |
Copilot
AI
Jan 27, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The USER root directive is redundant here because the base image mcr.microsoft.com/devcontainers/dotnet:1-8.0 already runs as a non-root user by default, and the devcontainer.json explicitly sets "remoteUser": "root" on line 47, which will override any USER directive in the Dockerfile.
This line can be safely removed as it has no effect given the devcontainer.json configuration.
| # Set default user to root for pwsh compatibility | |
| USER root |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -2,8 +2,11 @@ | |||||
| // README at: https://github.com/devcontainers/templates/tree/main/src/dotnet | ||||||
| { | ||||||
| "name": "C# (.NET)", | ||||||
| // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile | ||||||
| "image": "mcr.microsoft.com/devcontainers/dotnet:1-8.0", | ||||||
| // Use a Dockerfile for custom configuration | ||||||
|
|
||||||
| "context": "..", | ||||||
|
|
||||||
| "dockerFile": "Dockerfile", | ||||||
|
|
||||||
| // Features to add to the dev container. More info: https://containers.dev/features. | ||||||
| "features": { | ||||||
|
|
@@ -15,28 +18,34 @@ | |||||
| } | ||||||
| }, | ||||||
|
|
||||||
| // Use 'forwardPorts' to make a list of ports inside the container available locally. | ||||||
| // "forwardPorts": [5000, 5001], | ||||||
| // "portsAttributes": { | ||||||
| // "5001": { | ||||||
| // "protocol": "https" | ||||||
| // } | ||||||
| // } | ||||||
|
|
||||||
| // Use 'postCreateCommand' to run commands after the container is created. | ||||||
RenSilvaAU marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| "postCreateCommand": "npm install -g autorest", | ||||||
| "postCreateCommand": "./.devcontainer/post-create.ps1", | ||||||
|
|
||||||
| // Configure tool-specific properties. | ||||||
| "customizations": { | ||||||
| "vscode": { | ||||||
| // Add the IDs of extensions you want installed when the container is created. | ||||||
| "extensions": [ | ||||||
| "ms-dotnettools.csharp" | ||||||
| ] | ||||||
| ], | ||||||
| // Minimal settings to improve file search and git performance | ||||||
| "settings": { | ||||||
| "files.watcherExclude": { | ||||||
| "**/artifacts/**": true, | ||||||
| "**/.git/objects/**": true, | ||||||
| "**/node_modules/**": true | ||||||
| }, | ||||||
| "search.exclude": { | ||||||
| "**/artifacts/**": true | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
| }, | ||||||
|
|
||||||
| // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. | ||||||
| // this will allow us to call pwsh in scripts | ||||||
| "remoteUser": "root" | ||||||
| "remoteUser": "root", | ||||||
|
|
||||||
| // Mount optimization for macOS | ||||||
| "workspaceMount": "source=${localWorkspaceFolder},target=/workspaces/${localWorkspaceFolderBasename},type=bind,consistency=cached" | ||||||
|
||||||
| "workspaceMount": "source=${localWorkspaceFolder},target=/workspaces/${localWorkspaceFolderBasename},type=bind,consistency=cached" | |
| "workspaceMount": "source=${localWorkspaceFolder},target=/workspaces/${localWorkspaceFolderBasename},type=bind" |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,27 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #!/usr/bin/env pwsh | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #Requires -Version 7.0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $ErrorActionPreference = "Stop" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $ErrorActionPreference = "Stop" | |
| $ErrorActionPreference = "Stop" | |
| Set-StrictMode -Version 2.0 |
Copilot
AI
Jan 27, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The script includes proper error handling with $ErrorActionPreference = "Stop", try-catch blocks for exit codes, and -ErrorAction Stop for PowerShell cmdlets. However, the npm update and npm install commands could fail in non-obvious ways. Consider adding informative error messages that include troubleshooting hints, such as checking network connectivity or npm installation.
For example, wrap the npm operations in a try-catch that provides more context about common failure scenarios.
| Write-Host "📦 Updating npm..." -ForegroundColor Cyan | |
| npm update -g npm | |
| if ($LASTEXITCODE -ne 0) { | |
| throw "Failed to update npm" | |
| } | |
| Write-Host "🚀 Installing AutoRest..." -ForegroundColor Cyan | |
| npm install -g autorest | |
| if ($LASTEXITCODE -ne 0) { | |
| throw "Failed to install AutoRest" | |
| try { | |
| Write-Host "📦 Updating npm..." -ForegroundColor Cyan | |
| npm update -g npm | |
| if ($LASTEXITCODE -ne 0) { | |
| throw "npm update failed with exit code $LASTEXITCODE" | |
| } | |
| Write-Host "🚀 Installing AutoRest..." -ForegroundColor Cyan | |
| npm install -g autorest | |
| if ($LASTEXITCODE -ne 0) { | |
| throw "AutoRest installation failed with exit code $LASTEXITCODE" | |
| } | |
| } catch { | |
| Write-Error "npm tooling setup failed: $($_.Exception.Message)" | |
| Write-Error ("Troubleshooting tips:`n" + | |
| " - Verify that Node.js and npm are installed and on the PATH (run 'npm --version').`n" + | |
| " - Check your network connectivity and any proxy/firewall settings that might block npm.`n" + | |
| " - If behind a proxy, configure npm to use it (e.g. 'npm config set proxy <url>').`n" + | |
| " - Retry this script after addressing the above issues.") | |
| exit 1 |
Uh oh!
There was an error while loading. Please reload this page.