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
31 changes: 2 additions & 29 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,45 +5,18 @@ FROM mcr.microsoft.com/devcontainers/typescript-node:24
LABEL name="relabeler-dev"

# Set environment variables for versions
# Debian version should be the same as the base image.
ENV DEBIAN_VERSION=12
ENV DOTNET_SDK_VERSION=8.0
ENV NODE_VERSION=20

# Install additional OS packages and .NET SDK
# hadolint ignore=DL3008
RUN wget --progress=dot:giga https://packages.microsoft.com/config/debian/$DEBIAN_VERSION/packages-microsoft-prod.deb -O packages-microsoft-prod.deb \
&& dpkg -i packages-microsoft-prod.deb \
&& rm packages-microsoft-prod.deb \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
dotnet-sdk-$DOTNET_SDK_VERSION \
git \
apt-transport-https \
curl \
wget \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*
ENV NODE_VERSION=24

# Install n package manager and use it to install the latest Node.js and npm
RUN npm install -g n@latest && n $NODE_VERSION \
&& npm install -g npm@latest

# Switch back to dialog for any ad-hoc use of apt-get
ENV DEBIAN_FRONTEND=dialog

# Set the default shell to bash
SHELL ["/bin/bash", "-c"]

# Switch to the node user
USER node
WORKDIR /home/node

# Install GitVersion as a dotnet tool for the node user
RUN dotnet tool install --global GitVersion.Tool

# Add alias for gitversion, ensuring a newline before the alias
# Add alias for gitversion (GitVersion will be installed in post-create command)
RUN printf "\nalias gitversion=\"dotnet-gitversion\"\n" >> /home/node/.bashrc
Comment on lines +21 to 22
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Ensure GitVersion shim is runnable without relying on PATH luck. The global tool installs its shims in $HOME/.dotnet/tools, but the alias currently calls dotnet-gitversion without adding that directory to PATH, so the alias still fails in new shells.(learn.microsoft.com) Update the .bashrc snippet to add the tools directory to PATH (and point the alias at the full path) so the command always resolves.

-RUN printf "\nalias gitversion=\"dotnet-gitversion\"\n" >> /home/node/.bashrc
+RUN printf '\nexport PATH="$PATH:$HOME/.dotnet/tools"\nalias gitversion="$HOME/.dotnet/tools/dotnet-gitversion"\n' >> /home/node/.bashrc
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# Add alias for gitversion (GitVersion will be installed in post-create command)
RUN printf "\nalias gitversion=\"dotnet-gitversion\"\n" >> /home/node/.bashrc
# Add alias for gitversion (GitVersion will be installed in post-create command)
RUN printf '\nexport PATH="$PATH:$HOME/.dotnet/tools"\nalias gitversion="$HOME/.dotnet/tools/dotnet-gitversion"\n' >> /home/node/.bashrc
🤖 Prompt for AI Agents
In .devcontainer/Dockerfile around lines 21 to 22, the .bashrc alias for
gitversion assumes dotnet global tools are on PATH; update the appended snippet
to export $HOME/.dotnet/tools onto PATH and set the alias to the full shim path
so it always resolves. Concretely, append an export that prepends or appends
$HOME/.dotnet/tools to PATH (using $HOME to be portable) and update the alias to
point to $HOME/.dotnet/tools/dotnet-gitversion in the same .bashrc line sequence
so new shells can run the gitversion shim reliably.


# Switch back to root user to install global npm packages
#USER root
9 changes: 7 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
{ // CSpell:ignore dbaeumer davidanson firsttris gruntfuggly orta usernamehw azuretools errorlens bierner
"name": "Relabeler Dev Container", // A development container for Node.js and TypeScript projects with GitVersion support.
"dockerFile": "Dockerfile",
"features": {
"ghcr.io/devcontainers/features/dotnet:2": {
"version": "8.0",
"installUsingApt": false
}
},
"build": {
"context": "..",
"args": {
Expand All @@ -21,7 +27,6 @@
"extensions": [
"dbaeumer.vscode-eslint",
"streetsidesoftware.code-spell-checker",
"codecov.codecov",
"davidanson.vscode-markdownlint",
"firsttris.vscode-jest-runner",
"gruntfuggly.todo-tree",
Expand All @@ -33,7 +38,7 @@
]
}
},
"postCreateCommand": "npm install", // Runs when the dev container has been assigned to a user for the first time.
"postCreateCommand": "npm install && dotnet tool install --global GitVersion.Tool", // Runs when the dev container has been assigned to a user for the first time.
//"postStartCommand": "bash", // Runs each time the container is successfully started
"remoteUser": "node", // The user to use when connecting to the container
"workspaceMount": "source=${localWorkspaceFolder},target=/workspaces/relabeler,type=bind,consistency=cached",
Expand Down
Loading