Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
WCF Docker Containers
  • Loading branch information
afifi-ins committed Jul 15, 2022
commit 3186f778cf8850ad99a31628491ecf6e258f0729
10 changes: 10 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Ignore everything
*

# Allow files and directories
#!global.json
#!NuGet.config
#!/eng
#!/src/System.Private.ServiceModel/tools
#!/artifacts/bin/CertificateGenerator
#!/artifacts/bin/SelfHostedWCFService
3 changes: 3 additions & 0 deletions Docker/Client/Linux.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM mcr.microsoft.com/dotnet/sdk:6.0.300-focal-amd64

CMD /wcf/src/System.Private.ServiceModel/tools/scripts/SetClientEnv-Linux.sh && /wcf/eng/common/cibuild.sh -configuration Release -prepareMachine -t --integrationTest
7 changes: 7 additions & 0 deletions Docker/Client/Windows.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM mcr.microsoft.com/dotnet/framework/sdk:4.8

SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'Continue'; $verbosePreference='Continue';"]

CMD C:\wcf\src\System.Private.ServiceModel\tools\scripts\SetClientEnv-Windows.cmd; C:\wcf\eng\common\cibuild.cmd -configuration Release -prepareMachine /p:Restore=false /p:Sign=false /p:Test=true /p:IntegrationTest=true /p:Pack=false /p:Publish=false;


13 changes: 13 additions & 0 deletions Docker/Service/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM mcr.microsoft.com/dotnet/framework/wcf

# IIS Hosted
EXPOSE 80 808 443 44345

# Self Hosted
EXPOSE 8081 8083 8084 44285 809

SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'Continue'; $verbosePreference='Continue';"]
ENTRYPOINT ["powershell"]

# Setup WCF web hosted and self hosted services - Container Startup CMD
CMD ./wcf/src/System.Private.ServiceModel/tools/scripts/SetupWcfIISHostedService.cmd 38 /p:"c:\wcf"; ./wcf/src/System.Private.ServiceModel/tools/scripts/StartWCFSelfHostedSvc.cmd; powershell
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
<add key="CrlFileLocation" value="c:\wcftest\test.crl"/>
</appSettings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
</startup>
Copy link
Member

Choose a reason for hiding this comment

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

What was the reason for raising the supported runtime version to 4.8?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Building the CertificateGenerator tool using VS 2022 Developer Command Prompt requires to install .NET 4.5 SDK/Targeting Pack manually, I thought it would be nice to upgrade the runtime version and build the tool directly. This is what I get when using .NET 4.5:
Error MSB3644: The reference assemblies for .NETFramework,Version=v4.5 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks

</configuration>
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
<OutputType>Exe</OutputType>
<RootNamespace>CertificateGenerator</RootNamespace>
<AssemblyName>CertificateGenerator</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BouncyCastle.Crypto.dll" Version="1.8.1" GeneratePathProperty="true" />
</ItemGroup>

<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Configuration" />
Expand Down
4 changes: 4 additions & 0 deletions src/System.Private.ServiceModel/tools/scripts/BuildSource.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
:: Build certifcate generator tool
call BuildCertUtil.cmd
:: Build Selfhosted service
call BuildWCFSelfHostedService.cmd
8 changes: 8 additions & 0 deletions src/System.Private.ServiceModel/tools/scripts/BuildTest.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
:: Build tests
::Windows Build
cd ..\..\..\..\
call eng\common\cibuild.cmd -configuration Release -prepareMachine /p:Root_Certificate_Installed=true /p:Client_Certificate_Installed=true /p:SSL_Available=true /p:Test=false

::Linux Build
::call eng\common\cibuild.sh -configuration Release -preparemachine /p:Root_Certificate_Installed=true /p:Client_Certificate_Installed=true /p:SSL_Available=true /p:Test=false

Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
echo off
setlocal
echo **********************************
echo Starting WCF Service on Docker
echo **********************************

set _exitCode=0
::todo use vars
set ServiceImageTag = "wcf:service"
set "ServiceContainerName=WCFServiceContainer"


:: Make sure docker is running
docker ps>nul 2>&1
if ERRORLEVEL 1 (
echo. & echo ERROR: Please make sure docker is running.
goto :Failure
)

::make sure we are using Windows Containers
CALL "C:\Program Files\Docker\Docker\DockerCli.exe" -SwitchWindowsEngine

:: Check if WCF service is already running
FOR /F "tokens=* USEBACKQ" %%F IN (`docker container inspect -f '{{.State.Status}}' %ServiceContainerName%`) DO (
if %%F == 'running' (
echo. & echo WCF Service container is already running.
goto :Done
))

:: change directory to wcf folder
cd ../../../..

echo. & echo Building Docker image for WCF service

:: Building docker image.
docker build -f ./Docker/Service/Dockerfile -t wcf:service .
if ERRORLEVEL 1 (
echo. & echo ERROR: Building docker image failed.
goto :Failure
)
echo. & echo Building image success..

:: Starting docker container from the image.
echo. & echo Starting WCF Service Container
:: mount current directory for wcf source as container volume - C:\wcf
docker run --name %ServiceContainerName% --rm -it -d -v "%cd%":"C:\wcf" wcf:service
if ERRORLEVEL 1 (
echo. & echo ERROR: Starting WCF service container failed.
goto :Failure
)

echo. & echo Started WCF Service Container.
:: print service container IP address
docker inspect --format="{{.NetworkSettings.Networks.nat.IPAddress}}" %ServiceContainerName%

exit /b

:Failure
echo. & echo Error...
set _exitCode=1

:Done
exit /b %_exitCode%
endlocal
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
echo off
setlocal
echo **********************************
echo Starting WCF Client on Docker
echo **********************************

set _exitCode=0

:: Make sure docker is running
docker ps>nul 2>&1
if ERRORLEVEL 1 (
echo. & echo ERROR: Please make sure docker is running.
goto :Failure
)

echo. & echo Checking WCF service container status and IP address.

::Switch to Windows Containers to check WCF Service status
CALL "C:\Program Files\Docker\Docker\DockerCli.exe" -SwitchWindowsEngine

:: Check if WCF service is already running
docker container inspect -f '{{.State.Status}}' WCFServiceContainer
if ERRORLEVEL 1 (
echo. & echo Warning: WCF Service container is not running.
CALL DockerStartWCFService.cmd
)

:: set ServiceUri
FOR /F "tokens=* USEBACKQ" %%F IN (`docker inspect --format="{{.NetworkSettings.Networks.nat.IPAddress}}" WCFServiceContainer`) DO (
SET ServiceUri=%%F/WcfService38
)
echo %ServiceUri%

::Switch to Linux Containers to run Linux tests
CALL "C:\Program Files\Docker\Docker\DockerCli.exe" -SwitchLinuxEngine

:: change directory to wcf src
cd ../../../..

echo. & echo Building Docker image for WCF client

:: Building docker image.
docker build -f ./Docker/Client/Linux.dockerfile --tag=wcf:client .
if ERRORLEVEL 1 (
echo. & echo ERROR: Building docker image failed.
goto :Failure
)
echo. & echo Building image success..

:: Starting docker container from the image.
echo. & echo Starting WCF client
docker run --name wcfclient_container --rm -it --memory=2g -v "%cd%":"/wcf" -e ServiceUri=%ServiceUri% wcf:client
if ERRORLEVEL 1 (
echo. & echo ERROR: Starting WCF client container failed.
goto :Failure
)


exit /b

:Failure
echo. & echo Error...
set _exitCode=1

:Done
exit /b %_exitCode%
endlocal
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
echo off
setlocal
echo **********************************
echo Starting WCF Client on Docker
echo **********************************

set _exitCode=0

:: Make sure docker is running
docker ps>nul 2>&1
if ERRORLEVEL 1 (
echo. & echo ERROR: Please make sure docker is running.
goto :Failure
)

echo. & echo Checking WCF service container status and IP address.

::Switch to Windows Containers to check WCF Service status
CALL "C:\Program Files\Docker\Docker\DockerCli.exe" -SwitchWindowsEngine

:: Check if WCF service is already running
docker container inspect -f '{{.State.Status}}' WCFServiceContainer
if ERRORLEVEL 1 (
echo. & echo Warning: WCF Service container is not running.
CALL DockerStartWCFService.cmd
)

:: set ServiceUri
FOR /F "tokens=* USEBACKQ" %%F IN (`docker inspect --format="{{.NetworkSettings.Networks.nat.IPAddress}}" WCFServiceContainer`) DO (
SET ServiceUri=%%F/WcfService38
)
echo %ServiceUri%

:: change directory to wcf src
cd ../../../..

echo. & echo Building Docker image for WCF client

:: Building docker image.
docker build -f ./Docker/Client/Windows.dockerfile --tag=wcf:client .
if ERRORLEVEL 1 (
echo. & echo ERROR: Building docker image failed.
goto :Failure
)
echo. & echo Building image success..

:: Starting docker container from the image.

echo. & echo Starting WCF client
docker run --name wcfclient_container --rm -it --memory=2g -v "%cd%":"C:\wcf" -e ServiceUri=%ServiceUri% wcf:client
if ERRORLEVEL 1 (
echo. & echo ERROR: Starting WCF client container failed.
goto :Failure
)


exit /b

:Failure
echo. & echo Error...
set _exitCode=1

:Done
exit /b %_exitCode%
endlocal
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export Windows_Authentication_Available=true
export SPN_Available=true
export Server_Domain_Joined=true
export Ambient_Credentials_Available=true
export Domain_Available=true
export Explicit_Credentials_Available=true
export ExplicitUserName=indgaunt
export ExplicitPassword=IU872_oR4189l6_HT8
export SSL_Available=true
export Root_Certificate_Installed=true
export Client_Certificate_Installed=true
export Peer_Certificate_Installed=true
export NegotiateTestDomain=REDMOND.CORP.MICROSOFT.COM
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
setx Windows_Authentication_Available true
setx Digest_Authentication_Available true
setx Ambient_Credentials_Available true
setx SPN_Available true
setx NTLM_Available true
setx Server_Domain_Joined true
setx ExplicitUserName indgaunt
setx ExplicitPassword IU872_oR4189l6_HT8
setx Domain_Available true
setx UPN_Available true
setx Root_Certificate_Installed true
setx Client_Certificate_Installed true
setx Peer_Certificate_Installed true
Loading