-
Notifications
You must be signed in to change notification settings - Fork 558
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WCF Docker Containers #4876
Draft
afifi-ins
wants to merge
12
commits into
dotnet:main
Choose a base branch
from
afifi-ins:users/v-aafifi
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
WCF Docker Containers #4876
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
3186f77
WCF Docker Containers
afifi-ins 6380f49
Merge branch 'dotnet:main' into users/v-aafifi
afifi-ins c1d7638
Merge branch 'dotnet:main' into users/v-aafifi
afifi-ins 01fda6e
update docker scripts
afifi-ins e50b359
Merge branch 'dotnet:main' into users/v-aafifi
afifi-ins 300418b
Merge branch 'users/v-aafifi' of https://github.com/afifi-ins/wcf int…
afifi-ins 8e8dca9
update docker ignore
afifi-ins 200a22e
update scripts
afifi-ins e32c128
env script updates
afifi-ins 5954336
Add extra comments
afifi-ins 62bf3d1
Update NegotiateTestDomain value
afifi-ins 2f6fc7e
Merge branch 'dotnet:main' into users/v-aafifi
afifi-ins File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# https://docs.docker.com/engine/reference/builder/#dockerignore-file | ||
# Exclude files not relevant to the build | ||
# This helps to avoid unnecessarily sending large or sensitive files and directories to Docker daemon | ||
|
||
# Ignore everything and use Docker volumes | ||
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Linux Docker image - Host WCF Client | ||
FROM mcr.microsoft.com/dotnet/sdk:6.0.300-focal-amd64 | ||
|
||
# Run commands: | ||
# Setup environment variables | ||
# Install Root certificate | ||
# Run WCF Tests | ||
CMD /wcf/src/System.Private.ServiceModel/tools/scripts/SetClientEnv-Linux.sh && /wcf/src/System.Private.ServiceModel/tools/scripts/InstallRootCertificate.sh --cert-file /tmp/wcfrootca.crt && /wcf/eng/common/cibuild.sh -configuration Release --prepareMachine --ci --test --integrationTest | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Windows Docker image - Host WCF Client | ||
FROM mcr.microsoft.com/dotnet/framework/sdk:4.8 | ||
|
||
# Set Powershell as default Container shell | ||
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'Continue'; $verbosePreference='Continue';"] | ||
|
||
# Run commands: | ||
# Setup environment variables | ||
# Run WCF Tests | ||
CMD C:\wcf\src\System.Private.ServiceModel\tools\scripts\SetClientEnv-Windows.cmd; C:\wcf\eng\common\cibuild.cmd -configuration Release -prepareMachine /p:Restore=true /p:Sign=false /p:Test=true /p:IntegrationTest=true /p:Pack=false /p:Publish=false; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Windows Docker image - Host WCF Service | ||
FROM mcr.microsoft.com/dotnet/framework/wcf | ||
|
||
# Open IIS Hosted ports | ||
EXPOSE 80 808 443 44345 | ||
|
||
# Open Self Hosted ports | ||
EXPOSE 8081 8083 8084 44285 809 | ||
|
||
# Set Powershell as default Container shell | ||
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'Continue'; $verbosePreference='Continue';"] | ||
|
||
# Set ENTRYPOINT to Powershell | ||
# Keeps the Service Container always running | ||
ENTRYPOINT ["powershell"] | ||
|
||
# Container Startup command: | ||
# Setup WCF IIS Hosted and Self Hosted Services, using Docker Volume at C:\wcf | ||
CMD ./wcf/src/System.Private.ServiceModel/tools/scripts/SetupWcfIISHostedService.cmd 38 /p:"c:\wcf"; ./wcf/src/System.Private.ServiceModel/tools/scripts/StartWCFSelfHostedSvc.cmd; powershell |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
src/System.Private.ServiceModel/tools/scripts/BuildSource.cmd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
:: Build tools on Docker host machine. | ||
:: This saves time during container startup and running tests (simply mount a volume for the build artifacts) | ||
|
||
:: Build certifcate generator tool | ||
call BuildCertUtil.cmd | ||
:: Build Self Hosted service | ||
call BuildWCFSelfHostedService.cmd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
:: Build tests on Docker host machine. | ||
|
||
:: Windows Release Build | ||
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 | ||
|
||
|
||
|
||
|
68 changes: 68 additions & 0 deletions
68
src/System.Private.ServiceModel/tools/scripts/DockerStartWCFService.cmd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
echo off | ||
setlocal | ||
echo ********************************** | ||
echo Starting WCF Service on Docker | ||
echo ********************************** | ||
|
||
:: Use this script to start docker container for WCF Services - IIS Hosted and Self Hosted | ||
|
||
:: Variables | ||
set _exitCode=0 | ||
set "ServiceImageTag=wcf:service" | ||
set "ServiceContainerName=WCFServiceContainer" | ||
set "ServiceHostName=wcfservicehost" | ||
|
||
:: Check if docker is running | ||
docker ps>nul 2>&1 | ||
if ERRORLEVEL 1 ( | ||
echo. & echo ERROR: Please make sure docker is running. | ||
goto :Failure | ||
) | ||
|
||
:: Check if docker is 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 %ServiceImageTag% . | ||
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 | ||
:: Run docker container and mount current directory for wcf source as container volume - C:\wcf | ||
docker run --name %ServiceContainerName% --rm -it -d -h %ServiceHostName% -v "%cd%":"C:\wcf" %ServiceImageTag% | ||
if ERRORLEVEL 1 ( | ||
echo. & echo ERROR: Starting WCF service container failed. | ||
goto :Failure | ||
) | ||
|
||
echo. & echo Started WCF Service Container. | ||
:: Print service container IP address and host name | ||
echo. & echo WCF Service Container IP address and Host name: | ||
docker inspect --format="{{.NetworkSettings.Networks.nat.IPAddress}}" %ServiceContainerName% | ||
echo %ServiceHostName% | ||
|
||
exit /b | ||
|
||
:Failure | ||
echo. & echo Error... | ||
set _exitCode=1 | ||
|
||
:Done | ||
exit /b %_exitCode% | ||
endlocal |
77 changes: 77 additions & 0 deletions
77
src/System.Private.ServiceModel/tools/scripts/DockerStartWCFTest-Linux.cmd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
echo off | ||
setlocal | ||
echo ********************************** | ||
echo Starting WCF Client on Docker | ||
echo ********************************** | ||
|
||
:: Use this script to start docker Linux container for WCF Client | ||
|
||
:: Variables | ||
set _exitCode=0 | ||
set "TestContainerName=WCFTestContainerLinux" | ||
set "ServiceContainerName=WCFServiceContainer" | ||
set "ServiceHostName=wcfservicehost" | ||
|
||
:: Check if 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 | ||
START /B /WAIT "" "C:\Program Files\Docker\Docker\DockerCli.exe" -SwitchWindowsEngine | ||
|
||
:: Check if WCF service is already running | ||
docker container inspect -f '{{.State.Status}}' %ServiceContainerName% | ||
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}}" %ServiceContainerName%`) DO ( | ||
:: SET ServiceIPAddress=%%F | ||
SET ServiceUri=%ServiceHostName%/WcfService38 | ||
) | ||
echo %ServiceUri% | ||
|
||
:: Switch to Linux Containers to run Linux tests | ||
START /B /WAIT "" "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 | ||
:: run docker container and mount current directory for wcf source as container volume '/wcf' | ||
:: mount volume '.dotnet-linux' CLI cache directory inside the container as '.dotnet' | ||
:: mount volume 'artifacts-linux' inside the container as 'artifacts' | ||
:: mount volumes 'artifacts/bin' and 'artifacts/obj' inside the container, since it contains the test assemblies | ||
docker run --name %TestContainerName% --rm -it --memory=4g -v "%cd%":"/wcf" -v "%cd%/.dotnet-linux":"/wcf/.dotnet" -v "%cd%/artifacts-linux":"/wcf/artifacts" -v "%cd%/artifacts/bin":"/wcf/artifacts/bin" -v "%cd%/artifacts/obj":"/wcf/artifacts/obj" -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 |
72 changes: 72 additions & 0 deletions
72
src/System.Private.ServiceModel/tools/scripts/DockerStartWCFTest-Windows.cmd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
echo off | ||
setlocal | ||
echo ********************************** | ||
echo Starting WCF Client on Docker | ||
echo ********************************** | ||
|
||
:: Use this script to start docker Windows container for WCF Client | ||
|
||
:: Variables | ||
set _exitCode=0 | ||
set "TestContainerName=WCFTestContainerWin" | ||
set "ServiceContainerName=WCFServiceContainer" | ||
set "ServiceHostName=wcfservicehost" | ||
|
||
:: Check if 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 | ||
START /B /WAIT "" "C:\Program Files\Docker\Docker\DockerCli.exe" -SwitchWindowsEngine | ||
|
||
:: Check if WCF service is already running | ||
docker container inspect -f '{{.State.Status}}' %ServiceContainerName% | ||
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}}" %ServiceContainerName%`) DO ( | ||
:: SET ServiceIPAddress=%%F | ||
SET ServiceUri=%ServiceHostName%/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 | ||
:: run docker container and mount current directory for wcf source as container volume C:\wcf | ||
docker run --name %TestContainerName% --rm -it --memory=4g -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/System.Private.ServiceModel/tools/scripts/SetClientEnv-Linux.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Setup environment variables | ||
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 | ||
# Set username and password | ||
#export ExplicitUserName= | ||
#export ExplicitPassword= | ||
export SSL_Available=true | ||
export Root_Certificate_Installed=true | ||
export Client_Certificate_Installed=true | ||
export Peer_Certificate_Installed=true | ||
#export NegotiateTestDomain= |
15 changes: 15 additions & 0 deletions
15
src/System.Private.ServiceModel/tools/scripts/SetClientEnv-Windows.cmd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
:: Setup environment variables | ||
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 | ||
:: Set username and password | ||
::setx ExplicitUserName | ||
::setx ExplicitPassword | ||
setx Domain_Available true | ||
setx UPN_Available true | ||
setx Root_Certificate_Installed true | ||
setx Client_Certificate_Installed true | ||
setx Peer_Certificate_Installed true |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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