From 79615664cf5eb8b3a2145f581202fc4d49b360d1 Mon Sep 17 00:00:00 2001 From: etomas Date: Fri, 24 Feb 2017 18:07:52 +0100 Subject: [PATCH] Dockerfiles for win and linux containers --- .gitignore | 10 +++ _docker/nanowin/docker-compose.override.yml | 2 +- _docker/nanowin/docker-compose.vs.debug.yml | 14 ++--- _docker/nanowin/docker-compose.vs.release.yml | 14 ++--- _docker/nanowin/docker-compose.yml | 16 +++-- docker-compose.override.yml | 2 +- docker-compose.vs.debug.yml | 14 ++--- docker-compose.vs.release.yml | 62 ------------------- docker-compose.yml | 16 +++-- docker-use-platform.ps1 | 31 +++++++++- src/Services/Basket/Basket.API/Dockerfile | 2 +- .../Basket/Basket.API/Dockerfile.nanowin | 2 +- src/Services/Catalog/Catalog.API/Dockerfile | 2 +- .../Catalog/Catalog.API/Dockerfile.nanowin | 2 +- src/Services/Identity/Identity.API/Dockerfile | 2 +- .../Identity/Identity.API/Dockerfile.nanowin | 2 +- src/Services/Ordering/Ordering.API/Dockerfile | 2 +- .../Ordering/Ordering.API/Dockerfile.nanowin | 2 +- src/Web/WebMVC/Dockerfile | 2 +- src/Web/WebMVC/Dockerfile.nanowin | 2 +- src/Web/WebSPA/Dockerfile | 2 +- src/Web/WebSPA/Dockerfile.nanowin | 2 +- 22 files changed, 97 insertions(+), 108 deletions(-) delete mode 100644 docker-compose.vs.release.yml diff --git a/.gitignore b/.gitignore index e220f1e7b..86aca7c40 100644 --- a/.gitignore +++ b/.gitignore @@ -254,3 +254,13 @@ pub/ /src/Web/WebMVC/Properties/PublishProfiles/eShopOnContainersWebMVC2016 - Web Deploy-publish.ps1 /src/Web/WebMVC/Properties/PublishProfiles/publish-module.psm1 /src/Services/Identity/eShopOnContainers.Identity/Properties/launchSettings.json + +#docker-compose files are copied from nanowin or linux folders, so we need to ignore them +docker-compose.override.yml +docker-compose.vs.debug.yml +docker-compose.vs.release.yml +docker-compose.yml +docker-compose-external.override.yml +docker-compose-external.yml +#Same with Dockerfiles +/**/Dockerfile diff --git a/_docker/nanowin/docker-compose.override.yml b/_docker/nanowin/docker-compose.override.yml index 909cf4172..b6f9bb870 100644 --- a/_docker/nanowin/docker-compose.override.yml +++ b/_docker/nanowin/docker-compose.override.yml @@ -1,4 +1,4 @@ -version: '2' +version: '2.1' services: diff --git a/_docker/nanowin/docker-compose.vs.debug.yml b/_docker/nanowin/docker-compose.vs.debug.yml index 2446fdb2c..0a53cef7d 100644 --- a/_docker/nanowin/docker-compose.vs.debug.yml +++ b/_docker/nanowin/docker-compose.vs.debug.yml @@ -1,4 +1,4 @@ -version: '2' +version: '2.1' services: basket.api: @@ -14,7 +14,7 @@ services: - ~/clrdbg:/clrdbg:ro entrypoint: tail -f /dev/null labels: - - "com.microsoft.visualstudio.targetoperatingsystem=linux" + - "com.microsoft.visualstudio.targetoperatingsystem=windows" catalog.api: image: eshop/catalog.api:dev @@ -29,7 +29,7 @@ services: - ~/clrdbg:/clrdbg:ro entrypoint: tail -f /dev/null labels: - - "com.microsoft.visualstudio.targetoperatingsystem=linux" + - "com.microsoft.visualstudio.targetoperatingsystem=windows" identity.api: image: eshop/identity.api:dev @@ -44,7 +44,7 @@ services: - ~/clrdbg:/clrdbg:ro entrypoint: tail -f /dev/null labels: - - "com.microsoft.visualstudio.targetoperatingsystem=linux" + - "com.microsoft.visualstudio.targetoperatingsystem=windows" ordering.api: image: eshop/ordering.api:dev @@ -59,7 +59,7 @@ services: - ~/clrdbg:/clrdbg:ro entrypoint: tail -f /dev/null labels: - - "com.microsoft.visualstudio.targetoperatingsystem=linux" + - "com.microsoft.visualstudio.targetoperatingsystem=windows" webspa: image: eshop/webspa:dev @@ -74,7 +74,7 @@ services: - ~/clrdbg:/clrdbg:ro entrypoint: tail -f /dev/null labels: - - "com.microsoft.visualstudio.targetoperatingsystem=linux" + - "com.microsoft.visualstudio.targetoperatingsystem=windows" webmvc: image: eshop/webmvc:dev @@ -89,4 +89,4 @@ services: - ~/clrdbg:/clrdbg:ro entrypoint: tail -f /dev/null labels: - - "com.microsoft.visualstudio.targetoperatingsystem=linux" + - "com.microsoft.visualstudio.targetoperatingsystem=windows" diff --git a/_docker/nanowin/docker-compose.vs.release.yml b/_docker/nanowin/docker-compose.vs.release.yml index 4ea31f8ca..2c7b764a8 100644 --- a/_docker/nanowin/docker-compose.vs.release.yml +++ b/_docker/nanowin/docker-compose.vs.release.yml @@ -1,4 +1,4 @@ -version: '2' +version: '2.1' services: basket.api: @@ -9,7 +9,7 @@ services: - ~/clrdbg:/clrdbg:ro entrypoint: tail -f /dev/null labels: - - "com.microsoft.visualstudio.targetoperatingsystem=linux" + - "com.microsoft.visualstudio.targetoperatingsystem=windows" catalog.api: build: @@ -19,7 +19,7 @@ services: - ~/clrdbg:/clrdbg:ro entrypoint: tail -f /dev/null labels: - - "com.microsoft.visualstudio.targetoperatingsystem=linux" + - "com.microsoft.visualstudio.targetoperatingsystem=windows" identity.api: build: @@ -29,7 +29,7 @@ services: - ~/clrdbg:/clrdbg:ro entrypoint: tail -f /dev/null labels: - - "com.microsoft.visualstudio.targetoperatingsystem=linux" + - "com.microsoft.visualstudio.targetoperatingsystem=windows" ordering.api: build: @@ -39,7 +39,7 @@ services: - ~/clrdbg:/clrdbg:ro entrypoint: tail -f /dev/null labels: - - "com.microsoft.visualstudio.targetoperatingsystem=linux" + - "com.microsoft.visualstudio.targetoperatingsystem=windows" webspa: build: @@ -49,7 +49,7 @@ services: - ~/clrdbg:/clrdbg:ro entrypoint: tail -f /dev/null labels: - - "com.microsoft.visualstudio.targetoperatingsystem=linux" + - "com.microsoft.visualstudio.targetoperatingsystem=windows" webmvc: build: @@ -59,4 +59,4 @@ services: - ~/clrdbg:/clrdbg:ro entrypoint: tail -f /dev/null labels: - - "com.microsoft.visualstudio.targetoperatingsystem=linux" + - "com.microsoft.visualstudio.targetoperatingsystem=windows" diff --git a/_docker/nanowin/docker-compose.yml b/_docker/nanowin/docker-compose.yml index f3baeb346..1d27d2d43 100644 --- a/_docker/nanowin/docker-compose.yml +++ b/_docker/nanowin/docker-compose.yml @@ -1,4 +1,4 @@ -version: '2' +version: '2.1' services: basket.api: @@ -55,9 +55,17 @@ services: - basket.api sql.data: - image: microsoft/mssql-server-linux + image: microsoft/mssql-server-windows basket.data: - image: redis + image: eshop/redis + build: + context: ./extradf + dockerfile: Dockerfile ports: - - "6379:6379" + - "6379:6379" +networks: + default: + external: + name: nat + diff --git a/docker-compose.override.yml b/docker-compose.override.yml index 909cf4172..b6f9bb870 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -1,4 +1,4 @@ -version: '2' +version: '2.1' services: diff --git a/docker-compose.vs.debug.yml b/docker-compose.vs.debug.yml index 2446fdb2c..0a53cef7d 100644 --- a/docker-compose.vs.debug.yml +++ b/docker-compose.vs.debug.yml @@ -1,4 +1,4 @@ -version: '2' +version: '2.1' services: basket.api: @@ -14,7 +14,7 @@ services: - ~/clrdbg:/clrdbg:ro entrypoint: tail -f /dev/null labels: - - "com.microsoft.visualstudio.targetoperatingsystem=linux" + - "com.microsoft.visualstudio.targetoperatingsystem=windows" catalog.api: image: eshop/catalog.api:dev @@ -29,7 +29,7 @@ services: - ~/clrdbg:/clrdbg:ro entrypoint: tail -f /dev/null labels: - - "com.microsoft.visualstudio.targetoperatingsystem=linux" + - "com.microsoft.visualstudio.targetoperatingsystem=windows" identity.api: image: eshop/identity.api:dev @@ -44,7 +44,7 @@ services: - ~/clrdbg:/clrdbg:ro entrypoint: tail -f /dev/null labels: - - "com.microsoft.visualstudio.targetoperatingsystem=linux" + - "com.microsoft.visualstudio.targetoperatingsystem=windows" ordering.api: image: eshop/ordering.api:dev @@ -59,7 +59,7 @@ services: - ~/clrdbg:/clrdbg:ro entrypoint: tail -f /dev/null labels: - - "com.microsoft.visualstudio.targetoperatingsystem=linux" + - "com.microsoft.visualstudio.targetoperatingsystem=windows" webspa: image: eshop/webspa:dev @@ -74,7 +74,7 @@ services: - ~/clrdbg:/clrdbg:ro entrypoint: tail -f /dev/null labels: - - "com.microsoft.visualstudio.targetoperatingsystem=linux" + - "com.microsoft.visualstudio.targetoperatingsystem=windows" webmvc: image: eshop/webmvc:dev @@ -89,4 +89,4 @@ services: - ~/clrdbg:/clrdbg:ro entrypoint: tail -f /dev/null labels: - - "com.microsoft.visualstudio.targetoperatingsystem=linux" + - "com.microsoft.visualstudio.targetoperatingsystem=windows" diff --git a/docker-compose.vs.release.yml b/docker-compose.vs.release.yml deleted file mode 100644 index 4ea31f8ca..000000000 --- a/docker-compose.vs.release.yml +++ /dev/null @@ -1,62 +0,0 @@ -version: '2' - -services: - basket.api: - build: - args: - source: ${DOCKER_BUILD_SOURCE} - volumes: - - ~/clrdbg:/clrdbg:ro - entrypoint: tail -f /dev/null - labels: - - "com.microsoft.visualstudio.targetoperatingsystem=linux" - - catalog.api: - build: - args: - source: ${DOCKER_BUILD_SOURCE} - volumes: - - ~/clrdbg:/clrdbg:ro - entrypoint: tail -f /dev/null - labels: - - "com.microsoft.visualstudio.targetoperatingsystem=linux" - - identity.api: - build: - args: - source: ${DOCKER_BUILD_SOURCE} - volumes: - - ~/clrdbg:/clrdbg:ro - entrypoint: tail -f /dev/null - labels: - - "com.microsoft.visualstudio.targetoperatingsystem=linux" - - ordering.api: - build: - args: - source: ${DOCKER_BUILD_SOURCE} - volumes: - - ~/clrdbg:/clrdbg:ro - entrypoint: tail -f /dev/null - labels: - - "com.microsoft.visualstudio.targetoperatingsystem=linux" - - webspa: - build: - args: - source: ${DOCKER_BUILD_SOURCE} - volumes: - - ~/clrdbg:/clrdbg:ro - entrypoint: tail -f /dev/null - labels: - - "com.microsoft.visualstudio.targetoperatingsystem=linux" - - webmvc: - build: - args: - source: ${DOCKER_BUILD_SOURCE} - volumes: - - ~/clrdbg:/clrdbg:ro - entrypoint: tail -f /dev/null - labels: - - "com.microsoft.visualstudio.targetoperatingsystem=linux" diff --git a/docker-compose.yml b/docker-compose.yml index f3baeb346..1d27d2d43 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,4 @@ -version: '2' +version: '2.1' services: basket.api: @@ -55,9 +55,17 @@ services: - basket.api sql.data: - image: microsoft/mssql-server-linux + image: microsoft/mssql-server-windows basket.data: - image: redis + image: eshop/redis + build: + context: ./extradf + dockerfile: Dockerfile ports: - - "6379:6379" + - "6379:6379" +networks: + default: + external: + name: nat + diff --git a/docker-use-platform.ps1 b/docker-use-platform.ps1 index d6ac6f2b4..c0509aa37 100644 --- a/docker-use-platform.ps1 +++ b/docker-use-platform.ps1 @@ -1,10 +1,34 @@ -Param([ValidateSet(“nanowin", "linux")] [String] [Parameter(Mandatory=$true)] $Platform) +Param( + [ValidateSet(“nanowin", "linux")] [String] [Parameter(Mandatory=$true)] $Platform, + [bool] $DeleteImages = $false + +) $scriptPath = Split-Path $script:MyInvocation.MyCommand.Path +$SourcePerPlatformDockerFilesPath = "$ScriptPath\_docker\$Platform\extradf" +$TargetPerPlatformDockerFilesPath = "$ScriptPath\extradf" + Write-Host "Current script directory is $scriptPath" -ForegroundColor Yellow -Write-Host "Deleting eShop Docker images" -& "$ScriptPath\delete-images.ps1" + + +If ($DeleteImages) { + Write-Host "Deleting eShop Docker images" + & "$ScriptPath\delete-images.ps1" +} + +If (Test-Path $TargetPerPlatformDockerFilesPath) { + Write-Host "Found per-platform extra Docker files. Removing..." + Remove-Item "$TargetPerPlatformDockerFilesPath\" -Recurse -Force +} + +If (Test-Path $SourcePerPlatformDockerFilesPath) { + Write-Host "Copying per-platform extra Dockerfiles" + Copy-Item "$SourcePerPlatformDockerFilesPath\*" "$ScriptPath\extradf\" -Recurse -Force +} +else { + Write-Host "There are not extra Dockerfiles for platform $Platform" +} Write-Host "Changing Dockerfiles" Copy-Item "$ScriptPath\src\Services\Basket\Basket.API\Dockerfile.$Platform" "$ScriptPath\src\Services\Basket\Basket.API\Dockerfile" -Force @@ -17,4 +41,5 @@ Copy-Item "$ScriptPath\src\Web\WebSPA\Dockerfile.$Platform" "$ScriptPath\src\We Write-Host "Replacing Docker-compose" Copy-Item "$ScriptPath\_docker\$Platform\*.yml" "$ScriptPath\" -Force + Write-Host "Done. Docker files are set for platform: $Platform" \ No newline at end of file diff --git a/src/Services/Basket/Basket.API/Dockerfile b/src/Services/Basket/Basket.API/Dockerfile index bfc575ee1..41127e339 100644 --- a/src/Services/Basket/Basket.API/Dockerfile +++ b/src/Services/Basket/Basket.API/Dockerfile @@ -1,4 +1,4 @@ -FROM microsoft/aspnetcore:1.1 +FROM microsoft/dotnet:1.1-runtime-nanoserver ARG source WORKDIR /app EXPOSE 80 diff --git a/src/Services/Basket/Basket.API/Dockerfile.nanowin b/src/Services/Basket/Basket.API/Dockerfile.nanowin index bfc575ee1..41127e339 100644 --- a/src/Services/Basket/Basket.API/Dockerfile.nanowin +++ b/src/Services/Basket/Basket.API/Dockerfile.nanowin @@ -1,4 +1,4 @@ -FROM microsoft/aspnetcore:1.1 +FROM microsoft/dotnet:1.1-runtime-nanoserver ARG source WORKDIR /app EXPOSE 80 diff --git a/src/Services/Catalog/Catalog.API/Dockerfile b/src/Services/Catalog/Catalog.API/Dockerfile index 67f47d60d..5aad21ad1 100644 --- a/src/Services/Catalog/Catalog.API/Dockerfile +++ b/src/Services/Catalog/Catalog.API/Dockerfile @@ -1,4 +1,4 @@ -FROM microsoft/aspnetcore:1.1 +FROM microsoft/dotnet:1.1-runtime-nanoserver ARG source WORKDIR /app EXPOSE 80 diff --git a/src/Services/Catalog/Catalog.API/Dockerfile.nanowin b/src/Services/Catalog/Catalog.API/Dockerfile.nanowin index 67f47d60d..5aad21ad1 100644 --- a/src/Services/Catalog/Catalog.API/Dockerfile.nanowin +++ b/src/Services/Catalog/Catalog.API/Dockerfile.nanowin @@ -1,4 +1,4 @@ -FROM microsoft/aspnetcore:1.1 +FROM microsoft/dotnet:1.1-runtime-nanoserver ARG source WORKDIR /app EXPOSE 80 diff --git a/src/Services/Identity/Identity.API/Dockerfile b/src/Services/Identity/Identity.API/Dockerfile index 5ef6b4064..01f5eb8c5 100644 --- a/src/Services/Identity/Identity.API/Dockerfile +++ b/src/Services/Identity/Identity.API/Dockerfile @@ -1,4 +1,4 @@ -FROM microsoft/aspnetcore:1.1 +FROM microsoft/dotnet:1.1-runtime-nanoserver ARG source WORKDIR /app EXPOSE 80 diff --git a/src/Services/Identity/Identity.API/Dockerfile.nanowin b/src/Services/Identity/Identity.API/Dockerfile.nanowin index 5ef6b4064..01f5eb8c5 100644 --- a/src/Services/Identity/Identity.API/Dockerfile.nanowin +++ b/src/Services/Identity/Identity.API/Dockerfile.nanowin @@ -1,4 +1,4 @@ -FROM microsoft/aspnetcore:1.1 +FROM microsoft/dotnet:1.1-runtime-nanoserver ARG source WORKDIR /app EXPOSE 80 diff --git a/src/Services/Ordering/Ordering.API/Dockerfile b/src/Services/Ordering/Ordering.API/Dockerfile index 719bff2f4..85b1f46b4 100644 --- a/src/Services/Ordering/Ordering.API/Dockerfile +++ b/src/Services/Ordering/Ordering.API/Dockerfile @@ -1,4 +1,4 @@ -FROM microsoft/aspnetcore:1.1 +FROM microsoft/dotnet:1.1-runtime-nanoserver ARG source WORKDIR /app EXPOSE 80 diff --git a/src/Services/Ordering/Ordering.API/Dockerfile.nanowin b/src/Services/Ordering/Ordering.API/Dockerfile.nanowin index 719bff2f4..85b1f46b4 100644 --- a/src/Services/Ordering/Ordering.API/Dockerfile.nanowin +++ b/src/Services/Ordering/Ordering.API/Dockerfile.nanowin @@ -1,4 +1,4 @@ -FROM microsoft/aspnetcore:1.1 +FROM microsoft/dotnet:1.1-runtime-nanoserver ARG source WORKDIR /app EXPOSE 80 diff --git a/src/Web/WebMVC/Dockerfile b/src/Web/WebMVC/Dockerfile index 48252930c..fe622e8de 100644 --- a/src/Web/WebMVC/Dockerfile +++ b/src/Web/WebMVC/Dockerfile @@ -1,4 +1,4 @@ -FROM microsoft/aspnetcore:1.1 +FROM microsoft/dotnet:1.1-runtime-nanoserver ARG source WORKDIR /app EXPOSE 80 diff --git a/src/Web/WebMVC/Dockerfile.nanowin b/src/Web/WebMVC/Dockerfile.nanowin index 48252930c..fe622e8de 100644 --- a/src/Web/WebMVC/Dockerfile.nanowin +++ b/src/Web/WebMVC/Dockerfile.nanowin @@ -1,4 +1,4 @@ -FROM microsoft/aspnetcore:1.1 +FROM microsoft/dotnet:1.1-runtime-nanoserver ARG source WORKDIR /app EXPOSE 80 diff --git a/src/Web/WebSPA/Dockerfile b/src/Web/WebSPA/Dockerfile index 03634a256..8c784ca6e 100644 --- a/src/Web/WebSPA/Dockerfile +++ b/src/Web/WebSPA/Dockerfile @@ -1,4 +1,4 @@ -FROM microsoft/aspnetcore:1.1 +FROM microsoft/dotnet:1.1-runtime-nanoserver ARG source WORKDIR /app EXPOSE 80 diff --git a/src/Web/WebSPA/Dockerfile.nanowin b/src/Web/WebSPA/Dockerfile.nanowin index 03634a256..8c784ca6e 100644 --- a/src/Web/WebSPA/Dockerfile.nanowin +++ b/src/Web/WebSPA/Dockerfile.nanowin @@ -1,4 +1,4 @@ -FROM microsoft/aspnetcore:1.1 +FROM microsoft/dotnet:1.1-runtime-nanoserver ARG source WORKDIR /app EXPOSE 80