Skip to content

Commit 7e37baa

Browse files
authored
Fix alpine test dep images (#214)
Fix alpine test dep images - Also, add tests cases as this is the second image with this issue
1 parent 861c856 commit 7e37baa

File tree

12 files changed

+89
-8
lines changed

12 files changed

+89
-8
lines changed

release/community-stable/archlinux/docker/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ ENV PS_INSTALL_FOLDER=/opt/microsoft/powershell/$PS_INSTALL_VERSION \
2929
# Set up PowerShell module analysis cache path
3030
PSModuleAnalysisCachePath=/var/cache/microsoft/powershell/PSModuleAnalysisCache/ModuleAnalysisCache \
3131
# Opt out of SocketsHttpHandler in DotNet Core 2.1 to use HttpClientHandler
32-
# with installed libcurl4 package to resolve
32+
# with installed libcurl4 package to resolve
3333
# Invoke-WebRequest : Authentication failed" issue when executing using
3434
# docker run [OPTIONS] IMAGE[:TAG|@DIGEST] [Invoke-WebRequest] [-Uri <HTTPS URL>]
3535
DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER=0
@@ -60,6 +60,8 @@ RUN \
6060
&& rm -f /tmp/powershell-linux.tar.gz \
6161
# Create the pwsh symbolic link that points to powershell
6262
&& ln -s ${PS_INSTALL_FOLDER}/pwsh /usr/bin/pwsh \
63+
# Give all user execute permissions
64+
&& chmod a+x ${PS_INSTALL_FOLDER}/pwsh \
6365
# intialize powershell module cache
6466
&& pwsh \
6567
-NoLogo \

release/community-stable/blackarch/docker/Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ ENV PS_INSTALL_FOLDER=/opt/microsoft/powershell/$PS_INSTALL_VERSION \
3636
# Set up PowerShell module analysis cache path
3737
PSModuleAnalysisCachePath=/var/cache/microsoft/powershell/PSModuleAnalysisCache/ModuleAnalysisCache \
3838
# Opt out of SocketsHttpHandler in DotNet Core 2.1 to use HttpClientHandler
39-
# with installed libcurl4 package to resolve
39+
# with installed libcurl4 package to resolve
4040
# Invoke-WebRequest : Authentication failed" issue when executing using
4141
# docker run [OPTIONS] IMAGE[:TAG|@DIGEST] [Invoke-WebRequest] [-Uri <HTTPS URL>]
4242
DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER=0
@@ -49,7 +49,7 @@ RUN \
4949
&& locale-gen \
5050
# set execute permission on BlackArch strap shell script
5151
&& chmod +x /tmp/strap.sh \
52-
# update keyring server in /tmp/strap.sh
52+
# update keyring server in /tmp/strap.sh
5353
&& sed -i "s|pgp.mit.edu|hkp://pool.sks-keyservers.net|g" /tmp/strap.sh \
5454
# run BlackArch strap shell script
5555
&& /tmp/strap.sh \
@@ -75,6 +75,8 @@ RUN \
7575
&& rm -f /tmp/powershell-linux.tar.gz \
7676
# Create the pwsh symbolic link that points to powershell
7777
&& ln -s ${PS_INSTALL_FOLDER}/pwsh /usr/bin/pwsh \
78+
# Give all user execute permissions
79+
&& chmod a+x ${PS_INSTALL_FOLDER}/pwsh \
7880
# intialize powershell module cache
7981
&& pwsh \
8082
-NoLogo \

release/community-stable/parrot/docker/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ ENV PS_INSTALL_FOLDER=/opt/microsoft/powershell/$PS_INSTALL_VERSION \
3838
# Set up PowerShell module analysis cache path
3939
PSModuleAnalysisCachePath=/var/cache/microsoft/powershell/PSModuleAnalysisCache/ModuleAnalysisCache \
4040
# Opt out of SocketsHttpHandler in DotNet Core 2.1 to use HttpClientHandler
41-
# with installed libcurl4 package to resolve
41+
# with installed libcurl4 package to resolve
4242
# Invoke-WebRequest : Authentication failed" issue when executing using
4343
# docker run [OPTIONS] IMAGE[:TAG|@DIGEST] [Invoke-WebRequest] [-Uri <HTTPS URL>]
4444
DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER=0
@@ -69,6 +69,8 @@ RUN \
6969
&& apt-get install -y /tmp/powershell.deb \
7070
# remove powershell package
7171
&& rm -f /tmp/powershell.deb \
72+
# Give all user execute permissions
73+
&& chmod a+x ${PS_INSTALL_FOLDER}/pwsh \
7274
# intialize powershell module cache
7375
&& pwsh \
7476
-NoLogo \

release/community-stable/photon/docker/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ ENV PS_INSTALL_FOLDER=/opt/microsoft/powershell/$PS_INSTALL_VERSION \
5353
# Set up PowerShell module analysis cache path
5454
PSModuleAnalysisCachePath=/var/cache/microsoft/powershell/PSModuleAnalysisCache/ModuleAnalysisCache \
5555
# Opt out of SocketsHttpHandler in DotNet Core 2.1 to use HttpClientHandler
56-
# with installed libcurl4 package to resolve
56+
# with installed libcurl4 package to resolve
5757
# Invoke-WebRequest : Authentication failed" issue when executing using
5858
# docker run [OPTIONS] IMAGE[:TAG|@DIGEST] [Invoke-WebRequest] [-Uri <HTTPS URL>]
5959
DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER=0 \
@@ -79,6 +79,8 @@ RUN \
7979
&& locale-gen.sh \
8080
# create the pwsh symbolic link that points to powershell
8181
&& ln -s ${PS_INSTALL_FOLDER}/pwsh /usr/bin/pwsh \
82+
# Give all user execute permissions
83+
&& chmod a+x ${PS_INSTALL_FOLDER}/pwsh \
8284
# intialize powershell module cache
8385
&& pwsh \
8486
-NoLogo \

release/preview/alpine/docker/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ RUN apk add --no-cache \
7070
\
7171
# Create the pwsh-preview symbolic link that points to powershell
7272
&& ln -s ${PS_INSTALL_FOLDER}/pwsh /usr/bin/pwsh-preview \
73+
# Give all user execute permissions
74+
&& chmod a+x ${PS_INSTALL_FOLDER}/pwsh \
7375
# intialize powershell module cache
7476
&& pwsh \
7577
-NoLogo \

release/preview/opensuse423/docker/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ FROM ${imageRepo}:${fromTag} AS installer-env
1313
ARG PS_VERSION=6.2.0-preview.3
1414
ARG PS_PACKAGE=powershell-${PS_VERSION}-linux-x64.tar.gz
1515
ARG PS_PACKAGE_URL=https://github.com/PowerShell/PowerShell/releases/download/v${PS_VERSION}/${PS_PACKAGE}
16-
ARG PS_INSTALL_VERSION=6
16+
ARG PS_INSTALL_VERSION=6-preview
1717

1818
# define the folder we will be installing PowerShell to
1919
ENV PS_INSTALL_FOLDER=/opt/microsoft/powershell/$PS_INSTALL_VERSION
@@ -41,7 +41,7 @@ FROM ${imageRepo}:${fromTag}
4141
COPY --from=installer-env ["/opt/microsoft/powershell", "/opt/microsoft/powershell"]
4242

4343
# Define Args and Env needed to create links
44-
ARG PS_INSTALL_VERSION=6
44+
ARG PS_INSTALL_VERSION=6-preview
4545
ENV PS_INSTALL_FOLDER=/opt/microsoft/powershell/$PS_INSTALL_VERSION \
4646
\
4747
# Define ENVs for Localization/Globalization

release/servicing/alpine/docker/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ RUN apk add --no-cache \
6767
\
6868
# Create the pwsh symbolic link that points to powershell
6969
&& ln -s ${PS_INSTALL_FOLDER}/pwsh /usr/bin/pwsh \
70+
# Give all user execute permissions
71+
&& chmod a+x ${PS_INSTALL_FOLDER}/pwsh \
7072
# intialize powershell module cache
7173
&& pwsh \
7274
-NoLogo \

release/stable/alpine/docker/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ RUN apk add --no-cache \
6767
\
6868
# Create the pwsh symbolic link that points to powershell
6969
&& ln -s ${PS_INSTALL_FOLDER}/pwsh /usr/bin/pwsh \
70+
# Give all user execute permissions
71+
&& chmod a+x ${PS_INSTALL_FOLDER}/pwsh \
7072
# intialize powershell module cache
7173
&& pwsh \
7274
-NoLogo \

tests/container.tests.ps1

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,40 @@ Describe "Linux Containers" -Tags 'Behavior', 'Linux' {
315315
}
316316
}
317317

318+
Context "permissions" {
319+
BeforeAll{
320+
321+
$permissionsTestCases = @(
322+
$script:linuxContainerRunTests | ForEach-Object {
323+
@{
324+
Name = $_.Name
325+
Channel = $_.Channel
326+
}
327+
}
328+
)
329+
}
330+
331+
it "The permissions for pwsh should be correct in <channel>-<Name>" -TestCases $permissionsTestCases -Skip:$script:skipLinuxRun {
332+
param(
333+
[Parameter(Mandatory=$true)]
334+
[string]
335+
$name,
336+
[string]
337+
$Channel
338+
)
339+
340+
$path = '/opt/microsoft/powershell/6/pwsh'
341+
342+
if($Channel -eq 'preview')
343+
{
344+
$path = '/opt/microsoft/powershell/6-preview/pwsh'
345+
}
346+
347+
$permissions = Get-DockerImagePwshPermissions -Name $name -Path $path
348+
$permissions | Should -Match '^[\-rw]{3}x([\-rw]{2}x){2}$' -Because 'Everyone should be able to execute'
349+
}
350+
}
351+
318352
Context "default executables" {
319353
BeforeAll{
320354
#apt-utils ca-certificates curl wget apt-transport-https locales gnupg2 inetutils-ping git sudo less procps

tests/containerTestCommon.psm1

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ function Get-LinuxContainer
142142
SkipPull = $skipPull
143143
OptionalTests = $testArgs.OptionalTests
144144
TestProperties = $testArgs.TestProperties
145+
Channel = $testArgs.Channel
145146
}
146147
}
147148
}
@@ -175,6 +176,9 @@ function Get-WindowsContainer
175176
SkipGssNtlmSspTests = $testArgs.SkipGssNtlmSspTests
176177
ImageName = $testArgs.BuildArgs.IMAGE_NAME
177178
SkipPull = $skipPull
179+
OptionalTests = $testArgs.OptionalTests
180+
TestProperties = $testArgs.TestProperties
181+
Channel = $testArgs.Channel
178182
}
179183
}
180184
}
@@ -429,6 +433,32 @@ function Get-DockerImageSize
429433
return ($size / 1mb)
430434
}
431435

436+
# get the size of an image
437+
function Get-DockerImagePwshPermissions
438+
{
439+
param(
440+
[parameter(Mandatory)]
441+
[string] $Name,
442+
[string] $Path = '/opt/microsoft/powershell/6/pwsh'
443+
)
444+
445+
$imageTag = ${Name}
446+
447+
$runParams = @()
448+
$runParams += '--rm'
449+
450+
$runParams += $imageTag
451+
$runParams += 'pwsh'
452+
$runParams += '-nologo'
453+
$runParams += '-noprofile'
454+
$runParams += '-c'
455+
$runParams += "ls -l $Path"
456+
457+
$result = Invoke-Docker -Command run -Params $runParams -SuppressHostOutput -PassThru
458+
Write-Verbose $result -Verbose
459+
return ($result) -split ' ' | select-object -First 1
460+
}
461+
432462
# Builds a Docker image
433463
function Invoke-DockerBuild
434464
{

0 commit comments

Comments
 (0)