PowerShell/test/docker/networktest/Dockerfile
James Truher [MSFT] 63c20f15b1 Add dockerfile and test so we can test simple remoting behaviors (#3470)
* Add dockerfile and test so we can test simple remoting behaviors

this docker file creates an image which can be used to test remoting with containers.
We start with the microsoft/windowsservercore image and then set up the system for
testing by adding a user, setting up configuration for basic auth, installing
PowerShell Core, and creating a configuration endpoint for PSCore.

The tests are very simple; it retrieve $PSVersionTable.PSVersion in the following
connections:
   Full -> Full
   Full -> Core
   Core -> Full
   Core -> Core

* Add new file to bootstrap the docker image

fix the tests to be more resilient to changes in the version of the PSCore package

* update script to use local user cmdlets rather than net.exe

also remove pscore.msi at the end of the image build process to save space

* clean up commented lines and remove an unused parameter from one of the functions

also use constants more consistently

* remove reference to docker image name by string and use variable instead.
2017-04-21 17:23:08 -07:00

25 lines
1.1 KiB
Docker

# escape=`
FROM microsoft/windowsservercore
SHELL ["powershell.exe","-command"]
# the source msi should change on a daily basis
# the destination should not change
ADD PSCore.msi /PSCore.msi
# the msipath (PSCore.msi) below will need to change based on the daily package
# set up for basic auth
# install-powershellremoting will restart winrm service
RUN new-LocalUser -Name testuser -password (ConvertTo-SecureString 11aa!!AA -asplaintext -force); `
add-localgroupmember -group administrators -member testuser; `
set-item wsman:/localhost/service/auth/basic $true; `
set-item WSMan:/localhost/client/trustedhosts "*" -force; `
set-item wsman:/localhost/service/AllowUnencrypted $true; `
set-item WSMan:/localhost/client/AllowUnencrypted $true; `
Start-Process -FilePath msiexec.exe -ArgumentList '-qn', `
'-i c:\PSCore.msi','-log c:\PSCore-install.log','-norestart' -wait ; `
$psexec = get-item -path ${ENV:ProgramFiles}/powershell/*/powershell.exe; `
$corehome = $psexec.directory.fullname; `
& $psexec Install-PowerShellRemoting.ps1; `
remove-item -force c:\PSCore.msi