Oordering.API migrated to the latest version of VS Tools for Docker
This commit is contained in:
parent
eb1df7593a
commit
7a0e4ab7f0
@ -1,5 +1,2 @@
|
||||
# Docker support files
|
||||
docker-compose.yml
|
||||
docker-compose.debug.yml
|
||||
Dockerfile
|
||||
Dockerfile.debug
|
||||
|
@ -1,392 +0,0 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Deploys an ASP .NET Core Web Application into a docker container running in a specified Docker machine.
|
||||
|
||||
.DESCRIPTION
|
||||
The following script will execute a set of Docker commands against the designated dockermachine.
|
||||
|
||||
.PARAMETER Build
|
||||
Builds the containers using docker-compose build.
|
||||
|
||||
.PARAMETER Clean
|
||||
Clears out any running containers (docker-compose kill, docker-compose rm -f).
|
||||
|
||||
.PARAMETER Exec
|
||||
Executes a command in the container using docker exec.
|
||||
|
||||
.PARAMETER Refresh
|
||||
Kills the running command in the container, publishes the project and restarts executing the command.
|
||||
|
||||
.PARAMETER Run
|
||||
Removes any conflicting containers running on the same port, then instances the containers using docker-compose up.
|
||||
|
||||
.PARAMETER Environment
|
||||
Specifies the configuration under which the project will be built and run (Debug or Release).
|
||||
|
||||
.PARAMETER Machine
|
||||
Specifies the docker machine name to connect to. This is optional and if left blank or not provided it will use the currently configured docker host, or if no host is set, will use the Docker for Windows beta.
|
||||
|
||||
.PARAMETER ProjectFolder
|
||||
Specifies the project folder, defaults to the parent of the directory containing this script.
|
||||
|
||||
.PARAMETER ProjectName
|
||||
Specifies the project name used by docker-compose, defaults to the name of $ProjectFolder.
|
||||
|
||||
.PARAMETER NoCache
|
||||
Specifies the build argument --no-cache.
|
||||
|
||||
.PARAMETER RemoteDebugging
|
||||
Specifies if remote debugging is needed, defaults to $False.
|
||||
|
||||
.PARAMETER ClrDebugVersion
|
||||
Specifies the version of the debugger, defaults to 'VS2015U2'.
|
||||
|
||||
.PARAMETER Command
|
||||
Specifies the command to run in the container.
|
||||
|
||||
.INPUTS
|
||||
None. You cannot pipe inputs to DockerTask.
|
||||
|
||||
.EXAMPLE
|
||||
Compiles the project and builds the docker image using the currently configured docker host, or when no host is set, used for the Docker for Windows beta. To see the container running, use the -Run parameter
|
||||
C:\PS> .\DockerTask.ps1 -Build -Environment Release
|
||||
|
||||
.EXAMPLE
|
||||
Will use 'docker-compose up' on the project, using the docker-machine instance named 'default', and opens a browser once the container responds. Assumes -Build was previously run. For the Docker for Windows Beta, remove the -Machine parameter or pass '' as the value.
|
||||
C:\PS> .\DockerTask.ps1 -Run -Environment Release -Machine 'default'
|
||||
|
||||
.LINK
|
||||
http://aka.ms/DockerToolsForVS
|
||||
#>
|
||||
|
||||
Param(
|
||||
[Parameter(ParameterSetName = "Build", Position = 0, Mandatory = $True)]
|
||||
[switch]$Build,
|
||||
[Parameter(ParameterSetName = "Clean", Position = 0, Mandatory = $True)]
|
||||
[switch]$Clean,
|
||||
[Parameter(ParameterSetName = "Run", Position = 0, Mandatory = $True)]
|
||||
[switch]$Run,
|
||||
[Parameter(ParameterSetName = "Exec", Position = 0, Mandatory = $True)]
|
||||
[switch]$Exec,
|
||||
[Parameter(ParameterSetName = "Refresh", Position = 0, Mandatory = $True)]
|
||||
[switch]$Refresh,
|
||||
[Parameter(ParameterSetName = "ValidateVolumeMapping", Position = 0, Mandatory = $True)]
|
||||
[switch]$ValidateVolumeMapping,
|
||||
[parameter(ParameterSetName = "Clean", Position = 1, Mandatory = $True)]
|
||||
[parameter(ParameterSetName = "Build", Position = 1, Mandatory = $True)]
|
||||
[parameter(ParameterSetName = "Run", Position = 1, Mandatory = $True)]
|
||||
[parameter(ParameterSetName = "Refresh", Position = 1, Mandatory = $True)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[String]$Environment,
|
||||
[parameter(ParameterSetName = "Clean", Position = 2, Mandatory = $False)]
|
||||
[parameter(ParameterSetName = "Build", Position = 2, Mandatory = $False)]
|
||||
[parameter(ParameterSetName = "Run", Position = 2, Mandatory = $False)]
|
||||
[parameter(ParameterSetName = "Exec", Position = 1, Mandatory = $False)]
|
||||
[parameter(ParameterSetName = "Refresh", Position = 2, Mandatory = $False)]
|
||||
[parameter(ParameterSetName = "ValidateVolumeMapping", Position = 1, Mandatory = $False)]
|
||||
[String]$Machine,
|
||||
[parameter(ParameterSetName = "Clean", Position = 3, Mandatory = $False)]
|
||||
[parameter(ParameterSetName = "Build", Position = 3, Mandatory = $False)]
|
||||
[parameter(ParameterSetName = "Run", Position = 3, Mandatory = $False)]
|
||||
[parameter(ParameterSetName = "Exec", Position = 2, Mandatory = $False)]
|
||||
[parameter(ParameterSetName = "Refresh", Position = 3, Mandatory = $False)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[String]$ProjectFolder = (Split-Path -Path $MyInvocation.MyCommand.Definition),
|
||||
[parameter(ParameterSetName = "Clean", Position = 4, Mandatory = $False)]
|
||||
[parameter(ParameterSetName = "Build", Position = 4, Mandatory = $False)]
|
||||
[parameter(ParameterSetName = "Run", Position = 4, Mandatory = $False)]
|
||||
[parameter(ParameterSetName = "Exec", Position = 3, Mandatory = $False)]
|
||||
[parameter(ParameterSetName = "Refresh", Position = 4, Mandatory = $False)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[String]$ProjectName = (Split-Path -Path (Resolve-Path $ProjectFolder) -Leaf).ToLowerInvariant(),
|
||||
[parameter(ParameterSetName = "Build", Position = 5, Mandatory = $False)]
|
||||
[switch]$NoCache,
|
||||
[parameter(ParameterSetName = "Run", Position = 6, Mandatory = $False)]
|
||||
[bool]$RemoteDebugging = $False,
|
||||
[parameter(ParameterSetName = "Build", Position = 6, Mandatory = $False)]
|
||||
[String]$ClrDebugVersion = "VS2015U2",
|
||||
[parameter(ParameterSetName = "Exec", Position = 4, Mandatory = $True)]
|
||||
[parameter(ParameterSetName = "Refresh", Position = 5, Mandatory = $True)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[String]$Command
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
# Turns VERBOSE output ON
|
||||
$VerbosePreference = "Continue"
|
||||
|
||||
# Docker Working Directory for validating volume mapping. Should be in sync with Dockerfile and Docker.props.
|
||||
$DockerWorkingDirectory = "/app/"
|
||||
|
||||
# Path for the launch URL to be opened
|
||||
$launchURLPath = ""
|
||||
|
||||
# The project name can only contain alphanumeric charecters, replace everything else with empty string
|
||||
$ProjectName = $ProjectName -replace "[^a-zA-Z0-9]", ""
|
||||
|
||||
# The name of the image created by the compose file
|
||||
$ImageName = "username/eshopconsole"
|
||||
|
||||
# Calculate the name of the container created by the compose file
|
||||
$ContainerName = "${ProjectName}_eshopconsole"
|
||||
|
||||
# .net core runtime ID for the container (used to publish the app correctly)
|
||||
$RuntimeID = "debian.8-x64"
|
||||
# .net core framework (used to publish the app correctly)
|
||||
$Framework = "netcoreapp1.0"
|
||||
|
||||
# Kills all containers using an image, removes all containers using an image, and removes the image.
|
||||
function Clean () {
|
||||
$composeFilePath = GetComposeFilePath($ProjectFolder)
|
||||
|
||||
# Call compose-down to clean up the containers
|
||||
$shellCommand = "docker-compose -f '$composeFilePath' -p $ProjectName down"
|
||||
Write-Verbose "Executing: $shellCommand"
|
||||
Invoke-Expression "cmd /c $shellCommand `"2>&1`""
|
||||
if ($LastExitCode -ne 0) {
|
||||
Write-Error "Failed to clean up the containers"
|
||||
}
|
||||
|
||||
# If $ImageName exists remove it
|
||||
$ImageNameRegEx = "\b$ImageName\b"
|
||||
docker images | select-string -pattern $ImageNameRegEx | foreach {
|
||||
$imageName = $_.Line.split(" ", [System.StringSplitOptions]::RemoveEmptyEntries)[0];
|
||||
$tag = $_.Line.split(" ", [System.StringSplitOptions]::RemoveEmptyEntries)[1];
|
||||
$shellCommand = "docker rmi -f ${imageName}:$tag"
|
||||
Write-Verbose "Executing: $shellCommand";
|
||||
Invoke-Expression "cmd /c $shellCommand `"2>&1`""
|
||||
}
|
||||
|
||||
# Remove any dangling images (from previous builds)
|
||||
$shellCommand = "docker images -q --filter 'dangling=true'"
|
||||
Write-Verbose "Executing: $shellCommand"
|
||||
$danglingImages = $(Invoke-Expression "cmd /c $shellCommand `"2>&1`"")
|
||||
if (-not [String]::IsNullOrWhiteSpace($danglingImages)) {
|
||||
$shellCommand = "docker rmi -f $danglingImages"
|
||||
Write-Verbose "Executing: $shellCommand"
|
||||
Invoke-Expression "cmd /c $shellCommand `"2>&1`""
|
||||
}
|
||||
|
||||
# If the folder for publishing exists, delete it
|
||||
if (Test-Path $pubPath) {
|
||||
Remove-Item $pubPath -Force -Recurse
|
||||
}
|
||||
}
|
||||
|
||||
# Runs docker build.
|
||||
function Build () {
|
||||
# Publish the project
|
||||
PublishProject
|
||||
|
||||
$composeFilePath = GetComposeFilePath($pubPath)
|
||||
|
||||
$buildArgs = ""
|
||||
if ($NoCache)
|
||||
{
|
||||
$buildArgs = "--no-cache"
|
||||
}
|
||||
|
||||
# Call docker-compose on the published project to build the images
|
||||
$shellCommand = "docker-compose -f '$composeFilePath' -p $ProjectName build $buildArgs"
|
||||
Write-Verbose "Executing: $shellCommand"
|
||||
Invoke-Expression "cmd /c $shellCommand `"2>&1`""
|
||||
if ($LastExitCode -ne 0) {
|
||||
Write-Error "Failed to build the image"
|
||||
}
|
||||
}
|
||||
|
||||
function GetContainerId () {
|
||||
$containerId = (docker ps -f "name=$ContainerName" -q -n=1)
|
||||
if ([System.String]::IsNullOrWhiteSpace($containerId)) {
|
||||
Write-Error "Could not find a container named $ContainerName"
|
||||
}
|
||||
|
||||
$containerId
|
||||
}
|
||||
|
||||
# Validates volume mapping
|
||||
function ValidateVolumeMapping () {
|
||||
# Volume mapping enables shared folder mounting between host and docker container
|
||||
# If there are no files in the working directory, most likely volume mapping is misconfigured.
|
||||
$containerId = GetContainerId
|
||||
Write-Host "Validating volume mapping in the container $containerId"
|
||||
$shellCommand = "docker exec -i $containerId /bin/bash -c 'ls $DockerWorkingDirectory'"
|
||||
if (!$(Invoke-Expression $shellCommand)) {
|
||||
Write-Error "Unable to validate volume mapping. For troubleshooting, follow instructions from http://aka.ms/DockerToolsTroubleshooting"
|
||||
}
|
||||
}
|
||||
|
||||
# Runs docker run
|
||||
function Run () {
|
||||
$composeFilePath = GetComposeFilePath($pubPath)
|
||||
|
||||
$shellCommand = "docker-compose -f '$composeFilePath' -p $ProjectName up -d"
|
||||
Write-Verbose "Executing: $shellCommand"
|
||||
Invoke-Expression "cmd /c $shellCommand `"2>&1`""
|
||||
if ($LastExitCode -ne 0) {
|
||||
Write-Error "Failed to start the container(s)"
|
||||
}
|
||||
}
|
||||
|
||||
# Runs docker run
|
||||
function Exec () {
|
||||
$containerId = GetContainerId
|
||||
$shellCommand = "docker exec -i $containerId $Command"
|
||||
Write-Verbose "Executing: $shellCommand"
|
||||
Invoke-Expression $shellCommand
|
||||
if ($LastExitCode -ne 0) {
|
||||
Write-Error "Failed to exec command $Command in the container"
|
||||
}
|
||||
}
|
||||
|
||||
function Refresh () {
|
||||
# Find the container
|
||||
$containerId = GetContainerId
|
||||
|
||||
# Kill any existing process
|
||||
$shellCommand = "docker exec -i $containerId /bin/bash -c 'if PID=`$(pidof -x $Command); then kill `$PID; fi'"
|
||||
Write-Verbose "Executing: $shellCommand"
|
||||
Invoke-Expression $shellCommand
|
||||
|
||||
# Publish the project
|
||||
PublishProject
|
||||
|
||||
# Restart the process
|
||||
$shellCommand = "docker exec -i $containerId $Command"
|
||||
Write-Verbose "Executing: $shellCommand"
|
||||
Invoke-Expression $shellCommand
|
||||
if ($LastExitCode -ne 0) {
|
||||
Write-Error "Failed to exec command $Command in the container"
|
||||
}
|
||||
}
|
||||
|
||||
# Publishes the project
|
||||
function PublishProject () {
|
||||
$oldPath = $Env:Path
|
||||
|
||||
try {
|
||||
# Need to add $ProjectFolder\node_modules\.bin and the External Tools folder from the Web Tools to Path before calling publish
|
||||
$newPath = (Join-Path $ProjectFolder ".\node_modules\.bin") + ";$oldPath"
|
||||
|
||||
# Find where VS is installed
|
||||
$vsPath = $null
|
||||
if (Test-Path HKLM:\Software\WOW6432Node\Microsoft\VisualStudio\14.0\) {
|
||||
$vsPath = (Get-ItemProperty -Path HKLM:\Software\WOW6432Node\Microsoft\VisualStudio\14.0\ -Name ShellFolder).ShellFolder
|
||||
} elseif (Test-Path HKLM:\Software\Microsoft\VisualStudio\14.0\) {
|
||||
$vsPath = (Get-ItemProperty -Path HKLM:\Software\Microsoft\VisualStudio\14.0\ -Name ShellFolder).ShellFolder
|
||||
}
|
||||
|
||||
# Find where the Web Tools are installed
|
||||
if ($vsPath -ne $null) {
|
||||
$webExternalPath = $null
|
||||
# Check for the Web Tools in VS
|
||||
if (Test-Path (Join-Path $vsPath "Web")) {
|
||||
$webExternalPath = Join-Path $vsPath (Join-Path "Web" "External")
|
||||
# or the Web Exress edition
|
||||
} elseif (Test-Path (Join-Path $vsPath "WebExpress")) {
|
||||
$webExternalPath = Join-Path $vsPath (Join-Path "WebExpress" "External")
|
||||
}
|
||||
# If the Web Tools were found, add the externals from the Web Tools to Path
|
||||
if ($webExternalPath -ne $null) {
|
||||
$newPath = "$newPath;$webExternalPath;$webExternalPath\git"
|
||||
}
|
||||
}
|
||||
|
||||
# Set Path to our new path
|
||||
$Env:Path = $newPath
|
||||
|
||||
# Publish the project
|
||||
dotnet publish -f $Framework -r $RuntimeID -c $Environment -o $pubPath $ProjectFolder
|
||||
if ($? -eq $False) {
|
||||
Write-Error "Failed to publish the project"
|
||||
}
|
||||
}
|
||||
finally {
|
||||
# Restore path to its old value
|
||||
$Env:Path = $oldPath
|
||||
}
|
||||
}
|
||||
|
||||
function GetComposeFilePath([string]$folder) {
|
||||
$composeFileName = "docker-compose.yml"
|
||||
if ($Environment -ne "Release") {
|
||||
$composeFileName = "docker-compose.$($Environment.ToLower()).yml"
|
||||
}
|
||||
$composeFilePath = Join-Path $folder $composeFileName
|
||||
|
||||
if (Test-Path $composeFilePath) {
|
||||
return $composeFilePath
|
||||
} else {
|
||||
Write-Error -Message "$Environment is not a valid parameter. File '$composeFilePath' does not exist." -Category InvalidArgument
|
||||
}
|
||||
}
|
||||
|
||||
# Need the full path of the project for mapping
|
||||
$ProjectFolder = Resolve-Path $ProjectFolder
|
||||
|
||||
if (![System.String]::IsNullOrWhiteSpace($Machine)) {
|
||||
$users = Split-Path $env:USERPROFILE -Parent
|
||||
|
||||
# Set the environment variables for the docker machine to connect to
|
||||
$shellCommand = "docker-machine env $Machine --shell powershell"
|
||||
Write-Verbose "Executing: $shellCommand | Invoke-Expression"
|
||||
Invoke-Expression $shellCommand | Invoke-Expression
|
||||
if ($LastExitCode -ne 0) {
|
||||
Write-Error "Failed to set docker environment variables"
|
||||
}
|
||||
|
||||
# Get the driver name of the docker machine
|
||||
$DriverName = (docker-machine inspect $Machine | Out-String | ConvertFrom-Json)."DriverName"
|
||||
|
||||
# If the driver is virtualbox, need to check that the project location can be volume mapped
|
||||
if ($DriverName -eq "virtualbox") {
|
||||
if (!$ProjectFolder.StartsWith($users, [StringComparison]::InvariantCultureIgnoreCase)) {
|
||||
$message = "VirtualBox by default shares C:\Users as c/Users. If the project is not under c:\Users, please manually add it to the shared folders on VirtualBox. "`
|
||||
+ "Follow instructions from https://www.virtualbox.org/manual/ch04.html#sharedfolders"
|
||||
Write-Warning -Message $message
|
||||
}
|
||||
elseif (!$ProjectFolder.StartsWith($users, [StringComparison]::InvariantCulture)) {
|
||||
# If the project is under C:\Users, fix the casing if necessary. Path in Linux is case sensitive and the default shared folder c/Users
|
||||
# on VirtualBox can only be accessed if the project folder starts with the correct casing C:\Users as in $env:USERPROFILE
|
||||
$ProjectFolder = $users + $ProjectFolder.Substring($users.Length)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Our working directory in bin
|
||||
$dockerBinFolder = Join-Path $ProjectFolder (Join-Path "bin" "Docker")
|
||||
# The folder to publish the app to
|
||||
$pubPath = Join-Path (Join-Path $dockerBinFolder $Environment) "app"
|
||||
|
||||
Write-Verbose "Setting: `$env:CLRDBG_VERSION = `"$ClrDebugVersion`""
|
||||
$env:CLRDBG_VERSION = "$ClrDebugVersion"
|
||||
|
||||
if ($RemoteDebugging) {
|
||||
Write-Verbose "Setting: `$env:REMOTE_DEBUGGING = 1"
|
||||
$env:REMOTE_DEBUGGING = 1
|
||||
}
|
||||
else {
|
||||
Write-Verbose "Setting: `$env:REMOTE_DEBUGGING = 0"
|
||||
$env:REMOTE_DEBUGGING = 0
|
||||
}
|
||||
|
||||
# Call the correct functions for the parameters that were used
|
||||
if ($Clean) {
|
||||
Clean
|
||||
}
|
||||
if ($Build) {
|
||||
Build
|
||||
}
|
||||
if ($Run) {
|
||||
Run
|
||||
}
|
||||
if ($Exec) {
|
||||
Exec
|
||||
}
|
||||
if ($Refresh) {
|
||||
Refresh
|
||||
}
|
||||
if ($ValidateVolumeMapping) {
|
||||
ValidateVolumeMapping
|
||||
}
|
@ -1,10 +1,5 @@
|
||||
FROM microsoft/dotnet:1.0.0-core
|
||||
|
||||
# Set the Working Directory
|
||||
FROM microsoft/dotnet:1.0.1-core
|
||||
ENTRYPOINT ["dotnet", "eShopConsole.dll"]
|
||||
ARG source=.
|
||||
WORKDIR /app
|
||||
|
||||
# Copy the app
|
||||
COPY . /app
|
||||
|
||||
# Start the app
|
||||
ENTRYPOINT dotnet eShopConsole.dll
|
||||
COPY $source .
|
||||
|
@ -1,20 +0,0 @@
|
||||
FROM microsoft/dotnet:1.0.0-preview2-sdk
|
||||
|
||||
ENV NUGET_XMLDOC_MODE skip
|
||||
|
||||
# Install debugging components
|
||||
ARG CLRDBG_VERSION=VS2015U2
|
||||
WORKDIR /clrdbg
|
||||
RUN curl -SL https://raw.githubusercontent.com/Microsoft/MIEngine/getclrdbg-release/scripts/GetClrDbg.sh --output GetClrDbg.sh \
|
||||
&& chmod 700 GetClrDbg.sh \
|
||||
&& ./GetClrDbg.sh $CLRDBG_VERSION \
|
||||
&& rm GetClrDbg.sh
|
||||
|
||||
# Set the Working Directory
|
||||
WORKDIR /app
|
||||
|
||||
# Copy the app
|
||||
COPY . /app
|
||||
|
||||
# If we are launching through a remote debugger wait for it, otherwise start the app
|
||||
ENTRYPOINT ["/bin/bash", "-c", "if [ \"$REMOTE_DEBUGGING\" -eq 0 ]; then dotnet eShopConsole.dll; else sleep infinity; fi"]
|
@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<!-- Use this property to manually turn building the docker image as part of the project's build on and off,
|
||||
otherwise the target SetDockerProps will set it based on $(ActiveDebugProfile) -->
|
||||
<!--<DockerBuild Condition=" '$(DockerBuild)'=='' ">True</DockerBuild> -->
|
||||
|
||||
<!-- Use this property to change the docker host that is used by this project. Leave the value blank for the Docker for Windows beta or change to your docker-machine's name
|
||||
if using a host registered in docker-machine. (Note: you need to restart VS after changing this property) -->
|
||||
<DockerMachineName Condition=" '$(DockerMachineName)'=='' "></DockerMachineName>
|
||||
|
||||
<!-- Use these properties to configure the process that will be started by the debugger in the container -->
|
||||
<DockerDebugStartProcess>dotnet</DockerDebugStartProcess>
|
||||
<DockerDebugStartArgs>/app/eShopConsole.dll</DockerDebugStartArgs>
|
||||
<DockerDebugWorkingDirectory>/app/</DockerDebugWorkingDirectory>
|
||||
</PropertyGroup>
|
||||
</Project>
|
@ -1,75 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<NoDockerCache>False</NoDockerCache>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- These properties coordinate the targets used for calling docker commands -->
|
||||
<PropertyGroup>
|
||||
<DockerBuildDependsOn>
|
||||
SetDockerProps;
|
||||
CoreDockerBuild;
|
||||
</DockerBuildDependsOn>
|
||||
<DockerCleanDependsOn>
|
||||
SetDockerProps;
|
||||
CoreDockerClean;
|
||||
</DockerCleanDependsOn>
|
||||
<DockerBeforeRebuildDependsOn>
|
||||
SetDockerProps;
|
||||
CoreDockerBeforeRebuild;
|
||||
</DockerBeforeRebuildDependsOn>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- This target dynamically sets the DockerBuild property based on the ActiveDebugProfile so that docker commands will only be invoked when targeting docker -->
|
||||
<Target Name="SetDockerProps">
|
||||
<PropertyGroup>
|
||||
<DockerBuild Condition=" '$(DockerBuild)'=='' And ('$(ActiveDebugProfile)' == 'Docker' Or '$(ActiveDebugProfile)' == '')">True</DockerBuild>
|
||||
</PropertyGroup>
|
||||
</Target>
|
||||
|
||||
<!-- This target takes care of reporting failures from calling the powershell script in CoreDockerBuild -->
|
||||
<Target Name="CoreDockerBuildFailed">
|
||||
<Error File="$(MSBuildProjectDirectory)\DockerTask.ps1" Text="Error Running: $(DockerBuildCommand). See the output window for details."></Error>
|
||||
</Target>
|
||||
|
||||
<!-- These targets take care of buiding the docker image as part of the project's build -->
|
||||
<Target Name="DockerBuild" AfterTargets="Build" DependsOnTargets="$(DockerBuildDependsOn)" />
|
||||
<Target Name="CoreDockerBuild" Condition="'$(DockerBuild)'=='True'">
|
||||
<PropertyGroup>
|
||||
<DockerBuildCommand>powershell -NonInteractive -ExecutionPolicy RemoteSigned .\DockerTask.ps1 -Build -Environment $(Configuration) -Machine '$(DockerMachineName)' -ClrDebugVersion VS2015U2</DockerBuildCommand>
|
||||
<DockerBuildCommand Condition="'$(NoDockerCache)'=='True'">$(DockerBuildCommand) -NoCache</DockerBuildCommand>
|
||||
</PropertyGroup>
|
||||
<Message Importance="high" Text="$(DockerBuildCommand)" />
|
||||
<Exec
|
||||
WorkingDirectory="$(MSBuildProjectDirectory)"
|
||||
Command="$(DockerBuildCommand)" />
|
||||
<OnError ExecuteTargets="CoreDockerBuildFailed"/>
|
||||
</Target>
|
||||
|
||||
<!-- This target takes care of reporting failures from calling the powershell script in CoreDockerClean -->
|
||||
<Target Name="CoreDockerCleanFailed">
|
||||
<Error File="$(MSBuildProjectDirectory)\DockerTask.ps1" Text="Error Running: $(DockerCleanCommand). See the output window for details."></Error>
|
||||
</Target>
|
||||
|
||||
<!-- These targets take care of buiding the docker image as part of the project's clean -->
|
||||
<Target Name="DockerClean" AfterTargets="Clean" DependsOnTargets="$(DockerCleanDependsOn)" />
|
||||
<Target Name="CoreDockerClean" Condition="'$(DockerBuild)'=='True'">
|
||||
<PropertyGroup>
|
||||
<DockerCleanCommand>powershell -NonInteractive -ExecutionPolicy RemoteSigned .\DockerTask.ps1 -Clean -Environment $(Configuration) -Machine '$(DockerMachineName)'</DockerCleanCommand>
|
||||
</PropertyGroup>
|
||||
<Message Importance="high" Text="$(DockerCleanCommand)" />
|
||||
<Exec
|
||||
WorkingDirectory="$(MSBuildProjectDirectory)"
|
||||
Command="$(DockerCleanCommand)" />
|
||||
<OnError ExecuteTargets="CoreDockerCleanFailed"/>
|
||||
</Target>
|
||||
|
||||
<!-- These targets take care of buiding the docker image as part of the project's rebuild -->
|
||||
<Target Name="DockerBeforeRebuild" BeforeTargets="BeforeRebuild" DependsOnTargets="$(DockerBeforeRebuildDependsOn)" />
|
||||
<Target Name="CoreDockerBeforeRebuild" Condition="'$(DockerBuild)'=='True'">
|
||||
<!-- DockerBuild will be called later, just need to change it to not used the cached images -->
|
||||
<PropertyGroup>
|
||||
<NoDockerCache>True</NoDockerCache>
|
||||
</PropertyGroup>
|
||||
</Target>
|
||||
</Project>
|
@ -1,12 +0,0 @@
|
||||
version: '2'
|
||||
|
||||
services:
|
||||
eshopconsole:
|
||||
image: username/eshopconsole:Debug
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile.debug
|
||||
environment:
|
||||
- REMOTE_DEBUGGING=${REMOTE_DEBUGGING}
|
||||
volumes:
|
||||
- .:/app
|
14
src/Console/eShopConsole/docker-compose.dev.debug.yml
Normal file
14
src/Console/eShopConsole/docker-compose.dev.debug.yml
Normal file
@ -0,0 +1,14 @@
|
||||
version: '2'
|
||||
|
||||
services:
|
||||
eshopconsole:
|
||||
build:
|
||||
args:
|
||||
source: obj/Docker/empty/
|
||||
labels:
|
||||
- "com.microsoft.visualstudio.targetoperatingsystem=linux"
|
||||
volumes:
|
||||
- .:/app
|
||||
- ~/.nuget/packages:/root/.nuget/packages:ro
|
||||
- ~/clrdbg:/clrdbg:ro
|
||||
entrypoint: tail -f /dev/null
|
9
src/Console/eShopConsole/docker-compose.dev.release.yml
Normal file
9
src/Console/eShopConsole/docker-compose.dev.release.yml
Normal file
@ -0,0 +1,9 @@
|
||||
version: '2'
|
||||
|
||||
services:
|
||||
eshopconsole:
|
||||
labels:
|
||||
- "com.microsoft.visualstudio.targetoperatingsystem=linux"
|
||||
volumes:
|
||||
- ~/clrdbg:/clrdbg:ro
|
||||
entrypoint: tail -f /dev/null
|
@ -2,7 +2,7 @@ version: '2'
|
||||
|
||||
services:
|
||||
eshopconsole:
|
||||
image: username/eshopconsole
|
||||
image: user/eshopconsole${TAG}
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
|
@ -4,7 +4,6 @@
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
|
||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>c10c7b69-ce4f-4167-928e-33b7fa1dffc7</ProjectGuid>
|
||||
<RootNamespace>eShopConsole</RootNamespace>
|
||||
@ -14,9 +13,6 @@
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<DockerToolsMinVersion>0.21</DockerToolsMinVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="Properties\Docker.props" />
|
||||
<Import Project="Properties\Docker.targets" />
|
||||
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||
</Project>
|
@ -15,7 +15,7 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.API.Controllers
|
||||
{
|
||||
return new
|
||||
{
|
||||
Node = Environment.MachineName
|
||||
InstanceName = Environment.MachineName
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -5,16 +5,13 @@ FROM microsoft/aspnetcore:1.0.1
|
||||
# FROM microsoft/aspnetcore
|
||||
# FROM microsoft/dotnet:1.0.0-preview2-windowsservercore-sdk
|
||||
|
||||
WORKDIR /app
|
||||
EXPOSE 80
|
||||
|
||||
# Configure the listening port to 80
|
||||
# ENV ASPNETCORE_URLS http://*:80
|
||||
|
||||
COPY . /app
|
||||
|
||||
# Entry point through the copied assembly
|
||||
ENTRYPOINT ["dotnet", "Ordering.API.dll"]
|
||||
ARG source=.
|
||||
WORKDIR /app
|
||||
EXPOSE 80
|
||||
COPY $source .
|
||||
|
||||
|
||||
#################
|
||||
# Entry point running the SDK --> Requires heavy Docker .NET image, not for production
|
||||
@ -25,5 +22,3 @@ ENTRYPOINT ["dotnet", "Ordering.API.dll"]
|
||||
# Entrypoint
|
||||
#ENTRYPOINT ["dotnet", "run"]
|
||||
#################
|
||||
|
||||
|
||||
|
@ -4,7 +4,6 @@
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
|
||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>231226ce-690b-4979-8870-9a79d80928e2</ProjectGuid>
|
||||
<RootNamespace>Microsoft.eShopOnContainers.Services.Ordering.API</RootNamespace>
|
||||
@ -14,9 +13,6 @@
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<DockerToolsMinVersion>0.21</DockerToolsMinVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="Properties\Docker.props" />
|
||||
<Import Project="Properties\Docker.targets" />
|
||||
<Import Project="$(VSToolsPath)\DotNet.Web\Microsoft.DotNet.Web.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||
</Project>
|
@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<!-- Use this property to manually turn building the docker image as part of the project's build on and off,
|
||||
otherwise the target SetDockerProps will set it based on $(ActiveDebugProfile) -->
|
||||
<!--<DockerBuild Condition=" '$(DockerBuild)'=='' ">True</DockerBuild> -->
|
||||
|
||||
<!-- Use this property to change the docker host that is used by this project. Leave the value blank for the Docker for Windows beta or change to your docker-machine's name
|
||||
if using a host registered in docker-machine. (Note: you need to restart VS after changing this property) -->
|
||||
<DockerMachineName Condition=" '$(DockerMachineName)'=='' "></DockerMachineName>
|
||||
|
||||
<!-- Use these properties to configure the process that will be started by the debugger in the container -->
|
||||
<DockerDebugStartProcess>dotnet</DockerDebugStartProcess>
|
||||
<DockerDebugStartArgs>/app/Ordering.API.dll</DockerDebugStartArgs>
|
||||
<DockerDebugWorkingDirectory>/app/</DockerDebugWorkingDirectory>
|
||||
</PropertyGroup>
|
||||
</Project>
|
@ -1,75 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<NoDockerCache>False</NoDockerCache>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- These properties coordinate the targets used for calling docker commands -->
|
||||
<PropertyGroup>
|
||||
<DockerBuildDependsOn>
|
||||
SetDockerProps;
|
||||
CoreDockerBuild;
|
||||
</DockerBuildDependsOn>
|
||||
<DockerCleanDependsOn>
|
||||
SetDockerProps;
|
||||
CoreDockerClean;
|
||||
</DockerCleanDependsOn>
|
||||
<DockerBeforeRebuildDependsOn>
|
||||
SetDockerProps;
|
||||
CoreDockerBeforeRebuild;
|
||||
</DockerBeforeRebuildDependsOn>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- This target dynamically sets the DockerBuild property based on the ActiveDebugProfile so that docker commands will only be invoked when targeting docker -->
|
||||
<Target Name="SetDockerProps">
|
||||
<PropertyGroup>
|
||||
<DockerBuild Condition=" '$(DockerBuild)'=='' And ('$(ActiveDebugProfile)' == 'Docker' Or '$(ActiveDebugProfile)' == '')">True</DockerBuild>
|
||||
</PropertyGroup>
|
||||
</Target>
|
||||
|
||||
<!-- This target takes care of reporting failures from calling the powershell script in CoreDockerBuild -->
|
||||
<Target Name="CoreDockerBuildFailed">
|
||||
<Error File="$(MSBuildProjectDirectory)\DockerTask.ps1" Text="Error Running: $(DockerBuildCommand). See the output window for details."></Error>
|
||||
</Target>
|
||||
|
||||
<!-- These targets take care of buiding the docker image as part of the project's build -->
|
||||
<Target Name="DockerBuild" AfterTargets="Build" DependsOnTargets="$(DockerBuildDependsOn)" />
|
||||
<Target Name="CoreDockerBuild" Condition="'$(DockerBuild)'=='True'">
|
||||
<PropertyGroup>
|
||||
<DockerBuildCommand>powershell -NonInteractive -ExecutionPolicy RemoteSigned .\DockerTask.ps1 -Build -Environment $(Configuration) -Machine '$(DockerMachineName)' -ClrDebugVersion VS2015U2</DockerBuildCommand>
|
||||
<DockerBuildCommand Condition="'$(NoDockerCache)'=='True'">$(DockerBuildCommand) -NoCache</DockerBuildCommand>
|
||||
</PropertyGroup>
|
||||
<Message Importance="high" Text="$(DockerBuildCommand)" />
|
||||
<Exec
|
||||
WorkingDirectory="$(MSBuildProjectDirectory)"
|
||||
Command="$(DockerBuildCommand)" />
|
||||
<OnError ExecuteTargets="CoreDockerBuildFailed"/>
|
||||
</Target>
|
||||
|
||||
<!-- This target takes care of reporting failures from calling the powershell script in CoreDockerClean -->
|
||||
<Target Name="CoreDockerCleanFailed">
|
||||
<Error File="$(MSBuildProjectDirectory)\DockerTask.ps1" Text="Error Running: $(DockerCleanCommand). See the output window for details."></Error>
|
||||
</Target>
|
||||
|
||||
<!-- These targets take care of buiding the docker image as part of the project's clean -->
|
||||
<Target Name="DockerClean" AfterTargets="Clean" DependsOnTargets="$(DockerCleanDependsOn)" />
|
||||
<Target Name="CoreDockerClean" Condition="'$(DockerBuild)'=='True'">
|
||||
<PropertyGroup>
|
||||
<DockerCleanCommand>powershell -NonInteractive -ExecutionPolicy RemoteSigned .\DockerTask.ps1 -Clean -Environment $(Configuration) -Machine '$(DockerMachineName)'</DockerCleanCommand>
|
||||
</PropertyGroup>
|
||||
<Message Importance="high" Text="$(DockerCleanCommand)" />
|
||||
<Exec
|
||||
WorkingDirectory="$(MSBuildProjectDirectory)"
|
||||
Command="$(DockerCleanCommand)" />
|
||||
<OnError ExecuteTargets="CoreDockerCleanFailed"/>
|
||||
</Target>
|
||||
|
||||
<!-- These targets take care of buiding the docker image as part of the project's rebuild -->
|
||||
<Target Name="DockerBeforeRebuild" BeforeTargets="BeforeRebuild" DependsOnTargets="$(DockerBeforeRebuildDependsOn)" />
|
||||
<Target Name="CoreDockerBeforeRebuild" Condition="'$(DockerBuild)'=='True'">
|
||||
<!-- DockerBuild will be called later, just need to change it to not used the cached images -->
|
||||
<PropertyGroup>
|
||||
<NoDockerCache>True</NoDockerCache>
|
||||
</PropertyGroup>
|
||||
</Target>
|
||||
</Project>
|
@ -7,8 +7,15 @@ services:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
environment:
|
||||
- ConnectionString=Server=10.0.75.1;Database=Microsoft.eShopOnContainers.Services.OrderingDb;User Id=sa;Password=Pass@word
|
||||
- ConnectionString=Server=ordering.data;Database=Microsoft.eShopOnContainers.Services.OrderingDb;User Id=sa;Password=Pass@word
|
||||
ports:
|
||||
- "81:80"
|
||||
extra_hosts:
|
||||
- "CESARDLBOOKVHD:10.0.75.1"
|
||||
depends_on:
|
||||
- ordering.data
|
||||
|
||||
ordering.data:
|
||||
image: eshop/ordering.data.sqlserver.linux
|
||||
ports:
|
||||
- "1433:1433"
|
Loading…
x
Reference in New Issue
Block a user