Skip to content

Commit 2b1fd84

Browse files
committed
feat: enhance devcontainer for OSDCloudCustomBuilder development
- Refactor devcontainer.json with features, settings, and extensions for improved PowerShell and .NET development - Update Dockerfile to use multi-stage build, install .NET SDK, PowerShell 7, and development tools - Add ubuntutools.sh script to install essential Ubuntu development tools and configure the environment - Enhance devsetup.ps1 script to install and configure PowerShell modules with version management and testing functions
1 parent ffe4bd4 commit 2b1fd84

File tree

7 files changed

+1661
-52
lines changed

7 files changed

+1661
-52
lines changed

.devcontainer/.gitignore

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# DevContainer specific ignores
2+
3+
# Cache directory (mounted volume)
4+
cache/
5+
6+
# Temporary files
7+
*.tmp
8+
*.temp
9+
.tmp/
10+
.temp/
11+
12+
# Logs
13+
*.log
14+
logs/
15+
16+
# OS generated files
17+
.DS_Store
18+
.DS_Store?
19+
._*
20+
.Spotlight-V100
21+
.Trashes
22+
ehthumbs.db
23+
Thumbs.db
24+
25+
# IDE files
26+
.vscode/settings.json.bak
27+
.vscode/launch.json.bak
28+
.vscode/tasks.json.bak
29+
30+
# Build artifacts that might be generated during setup
31+
TestResults/
32+
coverage/
33+
*.coverage
34+
*.coveragexml
35+
36+
# PowerShell temporary files
37+
*.ps1xml
38+
profile.ps1.tmp
39+
40+
# Package manager files
41+
packages-microsoft-prod.deb

.devcontainer/Dockerfile

Lines changed: 107 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,109 @@
1-
FROM mcr.microsoft.com/powershell/test-deps:preview-alpine-3.16
1+
# Multi-stage Dockerfile for OSDCloudCustomBuilder Development
2+
FROM mcr.microsoft.com/devcontainers/base:ubuntu-22.04 AS base
23

4+
# Set environment variables
5+
ENV DEBIAN_FRONTEND=noninteractive
6+
ENV DOTNET_CLI_TELEMETRY_OPTOUT=1
7+
ENV DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
8+
ENV DOTNET_NOLOGO=1
9+
ENV POWERSHELL_TELEMETRY_OPTOUT=1
10+
11+
# Install system dependencies
12+
RUN apt-get update && apt-get install -y \
13+
apt-transport-https \
14+
ca-certificates \
15+
curl \
16+
gnupg \
17+
lsb-release \
18+
software-properties-common \
19+
git \
20+
unzip \
21+
wget \
22+
jq \
23+
nano \
24+
vim \
25+
tree \
26+
htop \
27+
build-essential \
28+
python3 \
29+
python3-pip \
30+
&& rm -rf /var/lib/apt/lists/*
31+
32+
# Install .NET SDK 8.0
33+
RUN curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --channel 8.0 --install-dir /usr/share/dotnet \
34+
&& ln -s /usr/share/dotnet/dotnet /usr/local/bin/dotnet
35+
36+
# Install PowerShell 7
37+
RUN curl -sSL https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb -o packages-microsoft-prod.deb \
38+
&& dpkg -i packages-microsoft-prod.deb \
39+
&& rm packages-microsoft-prod.deb \
40+
&& apt-get update \
41+
&& apt-get install -y powershell \
42+
&& rm -rf /var/lib/apt/lists/*
43+
44+
# Create a non-root user
45+
ARG USERNAME=vscode
46+
ARG USER_UID=1000
47+
ARG USER_GID=$USER_UID
48+
49+
RUN groupadd --gid $USER_GID $USERNAME \
50+
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
51+
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
52+
&& chmod 0440 /etc/sudoers.d/$USERNAME
53+
54+
# Switch to the non-root user
55+
USER $USERNAME
56+
57+
# Set PowerShell as the default shell for the user
58+
RUN echo 'exec pwsh -NoLogo' >> ~/.bashrc
59+
60+
# Install PowerShell modules for development and testing
361
RUN pwsh -NoProfile -Command \
4-
Install-Module Pester -Force -Scope AllUsers; \
5-
Install-Module PSScriptAnalyzer -Force -Scope AllUsers; \
6-
Install-Module PSReadLine -Force -Scope AllUsers; \
7-
Install-Module PSFramework -Force -Scope AllUsers; \
8-
Install-Module PSDepend -Force -Scope AllUsers; \
9-
Install-Module PSRule -Force -Scope AllUsers; \
10-
Install-Module PSRule.Rules.Azure -Force -Scope AllUsers; \
11-
Install-Module OSD -Force -Scope AllUsers; \
12-
Install-Module PowershellProTools -Force -Scope AllUsers
62+
'Set-PSRepository -Name PSGallery -InstallationPolicy Trusted; \
63+
$modules = @( \
64+
@{Name="Pester"; Version="5.5.0"}, \
65+
@{Name="PSScriptAnalyzer"; Version="1.21.0"}, \
66+
@{Name="PSReadLine"; Version="2.3.4"}, \
67+
@{Name="PSFramework"; Version="1.7.270"}, \
68+
@{Name="PSDepend"; Version="0.3.8"}, \
69+
@{Name="InvokeBuild"; Version="5.10.4"}, \
70+
@{Name="ModuleBuilder"; Version="2.0.0"}, \
71+
@{Name="PSModuleDevelopment"; Version="2.2.9.94"}, \
72+
@{Name="Plaster"; Version="1.1.3"}, \
73+
@{Name="PowerShellGet"; Version="2.2.5"}, \
74+
@{Name="PackageManagement"; Version="1.4.8.1"}, \
75+
@{Name="PSRule"; Version="2.9.0"}, \
76+
@{Name="PSRule.Rules.Azure"; Version="1.30.1"}, \
77+
@{Name="OSD"; Version="23.5.26.1"}, \
78+
@{Name="PowerShellProTools"; Version="5.8.6"} \
79+
); \
80+
foreach ($module in $modules) { \
81+
Write-Host "Installing $($module.Name) v$($module.Version)..."; \
82+
try { \
83+
Install-Module -Name $module.Name -RequiredVersion $module.Version -Scope AllUsers -Force -AllowClobber -ErrorAction Stop; \
84+
Write-Host "✅ $($module.Name) installed successfully"; \
85+
} catch { \
86+
Write-Warning "❌ Failed to install $($module.Name): $_"; \
87+
} \
88+
}'
89+
90+
# Set up .NET global tools
91+
RUN dotnet tool install --global dotnet-reportgenerator-globaltool --version 5.2.0 \
92+
&& dotnet tool install --global coverlet.console --version 6.0.0 \
93+
&& dotnet tool install --global dotnet-format --version 5.1.250801 \
94+
&& dotnet tool install --global dotnet-outdated-tool --version 4.6.0
95+
96+
# Configure Git (will be overridden by user settings)
97+
RUN git config --global init.defaultBranch main \
98+
&& git config --global core.autocrlf input \
99+
&& git config --global core.eol lf
100+
101+
# Create workspace directory and set appropriate permissions
102+
WORKDIR /workspaces/OSDCloudCustomBuilder
103+
RUN sudo chown -R $USERNAME:$USERNAME /workspaces
104+
105+
# Expose ports for potential web interfaces or debugging
106+
EXPOSE 8080 5000 5001
107+
108+
# Set the default command
109+
CMD ["pwsh", "-NoLogo"]

0 commit comments

Comments
 (0)