-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.psscriptanalyzer
More file actions
31 lines (23 loc) · 1.44 KB
/
Copy pathDockerfile.psscriptanalyzer
File metadata and controls
31 lines (23 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# syntax=docker/dockerfile:1
FROM mcr.microsoft.com/dotnet/sdk:10.0
LABEL org.opencontainers.image.title="psscriptanalyzer-lint"
LABEL org.opencontainers.image.description="PowerShell lint container using the .NET 10 SDK image with PSScriptAnalyzer from PSGallery"
ENV POWERSHELL_TELEMETRY_OPTOUT=1 \
DOTNET_CLI_TELEMETRY_OPTOUT=1 \
PSModuleAnalysisCachePath=/tmp/psmoduleanalysiscache/ModuleAnalysisCache
SHELL ["pwsh", "-NoLogo", "-NoProfile", "-NonInteractive", "-Command"]
RUN $minimumVersion = [version]'7.4.6'; \
$actualVersion = $PSVersionTable.PSVersion; \
if ($actualVersion -lt $minimumVersion) { \
throw \"PowerShell $actualVersion is too old. PSScriptAnalyzer requires PowerShell $minimumVersion or newer.\"; \
}; \
Install-PSResource -Name PSScriptAnalyzer -Repository PSGallery -Scope AllUsers -TrustRepository -AcceptLicense -Reinstall; \
Import-Module PSScriptAnalyzer -Force; \
$module = Get-Module PSScriptAnalyzer -ListAvailable | Sort-Object Version -Descending | Select-Object -First 1; \
Write-Host \"PowerShell version: $($PSVersionTable.PSVersion)\"; \
Write-Host \"PSScriptAnalyzer version: $($module.Version)\"; \
Write-Host \"PSScriptAnalyzer path: $($module.ModuleBase)\"
WORKDIR /workspace
COPY psscriptanalyzer.ps1 /usr/local/bin/psscriptanalyzer.ps1
ENTRYPOINT ["pwsh", "-NoLogo", "-NoProfile", "-NonInteractive", "-File", "/usr/local/bin/psscriptanalyzer.ps1"]
CMD ["/workspace"]