diff --git a/DockerSupport.md b/DockerSupport.md new file mode 100644 index 00000000..da18983b --- /dev/null +++ b/DockerSupport.md @@ -0,0 +1,48 @@ +# Docker Support JavaScriptServices + +Using Visual Studio 2017 you can right click each project and Add Docker Support. Visual Studio will create a Dockerfile for the project and register it in the docker-compose section of your solution. +The Dockerfile created by Visual Studio looks like this: +``` +FROM microsoft/aspnetcore:1.1 +ARG source +WORKDIR /app +EXPOSE 80 +COPY ${source:-obj/Docker/publish} . +ENTRYPOINT ["dotnet", "MusicStore.dll"] +``` + +The problem is that JavaScriptServices needs NodeJS to run, which is not available on the microsoft/aspnetcore:1.1 image. We need to install it before starting the application. +Change the Dockerfile like this: +``` +FROM microsoft/aspnetcore:1.1 +RUN apt-get update +RUN apt-get install curl +RUN curl -sL https://deb.nodesource.com/setup_6.x | bash +RUN apt-get install -y build-essential nodejs +ARG source +WORKDIR /app +EXPOSE 80 +COPY ${source:-obj/Docker/publish} . +ENTRYPOINT ["dotnet", "MusicStore.dll"] +``` + +Docker support was added to all sample projects. The React MusicStore is not work properly due to a webpack error. + +## Running with Docker +To run the application inside Docker, make sure that docker-compose is the Start-up project on your solution. Then, simply press F5 which will run all configured samples in a docker container. +To browse go to the command line and type: +``` +docker ps +CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES +8da5f8ec45fe reactmusicstore:dev "tail -f /dev/null" 12 minutes ago Up 12 minutes 0.0.0.0:32779->80/tcp dockercompose3094088439_reactmusicstore_1 +16593eafd06a reactgrid:dev "tail -f /dev/null" 12 minutes ago Up 12 minutes 0.0.0.0:32780->80/tcp dockercompose3094088439_reactgrid_1 +7fda780decb0 ngmusicstore:dev "tail -f /dev/null" 12 minutes ago Up 12 minutes 0.0.0.0:32778->80/tcp dockercompose3094088439_ngmusicstore_1 +7c0d49413df6 nodeservicesexamples:dev "tail -f /dev/null" 12 minutes ago Up 12 minutes 0.0.0.0:32777->80/tcp dockercompose3094088439_nodeservicesexamples_1 +0f15ba2c085c reactgrid:dev "tail -f /dev/null" About an hour ago Up About an hour 0.0.0.0:32772->80/tcp dockercompose4052802262_reactgrid_1 +``` + +If you open your browser on localhost:32778 you will see the Angular Music Store Sample. I've added in page footer information about the hosting environment. +Under docker (at least for Windows) the footer should look like: +``` +Running on 7fda780decb0 (Linux 4.9.12-moby #1 SMP Tue Feb 28 12:11:36 UTC 2017) +``` diff --git a/JavaScriptServices.sln b/JavaScriptServices.sln index ba91c6bb..9cbba938 100644 --- a/JavaScriptServices.sln +++ b/JavaScriptServices.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26228.4 +VisualStudioVersion = 15.0.26228.9 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{27304DDE-AFB2-4F8B-B765-E3E2F11E886C}" EndProject @@ -64,6 +64,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{E415FE14 EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VueSpa", "templates\VueSpa\VueSpa.csproj", "{49D7665A-20EC-43FC-B8E8-EA0204F2D8C3}" EndProject +Project("{E53339B2-1760-4266-BCC7-CA923CBCF16C}") = "docker-compose", "docker-compose.dcproj", "{C3E26FF2-401F-4E8A-BF19-49E868529039}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -142,6 +144,10 @@ Global {49D7665A-20EC-43FC-B8E8-EA0204F2D8C3}.Debug|Any CPU.Build.0 = Debug|Any CPU {49D7665A-20EC-43FC-B8E8-EA0204F2D8C3}.Release|Any CPU.ActiveCfg = Release|Any CPU {49D7665A-20EC-43FC-B8E8-EA0204F2D8C3}.Release|Any CPU.Build.0 = Release|Any CPU + {C3E26FF2-401F-4E8A-BF19-49E868529039}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C3E26FF2-401F-4E8A-BF19-49E868529039}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C3E26FF2-401F-4E8A-BF19-49E868529039}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C3E26FF2-401F-4E8A-BF19-49E868529039}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/docker-compose.ci.build.yml b/docker-compose.ci.build.yml new file mode 100644 index 00000000..586954da --- /dev/null +++ b/docker-compose.ci.build.yml @@ -0,0 +1,9 @@ +version: '2' + +services: + ci-build: + image: microsoft/aspnetcore-build:1.0-1.1 + volumes: + - .:/src + working_dir: /src + command: /bin/bash -c "dotnet restore ./JavaScriptServices.sln && dotnet publish ./JavaScriptServices.sln -c Release -o ./obj/Docker/publish" diff --git a/docker-compose.dcproj b/docker-compose.dcproj new file mode 100644 index 00000000..5c148203 --- /dev/null +++ b/docker-compose.dcproj @@ -0,0 +1,22 @@ + + + + c3e26ff2-401f-4e8a-bf19-49e868529039 + True + http://localhost:{ServicePort} + musicstore + + + + + docker-compose.yml + + + docker-compose.yml + + + docker-compose.yml + + + + \ No newline at end of file diff --git a/docker-compose.override.yml b/docker-compose.override.yml new file mode 100644 index 00000000..93fdff5a --- /dev/null +++ b/docker-compose.override.yml @@ -0,0 +1,26 @@ +version: '2' + +services: + ngmusicstore: + environment: + - ASPNETCORE_ENVIRONMENT=Development + ports: + - "80" + + nodeservicesexamples: + environment: + - ASPNETCORE_ENVIRONMENT=Development + ports: + - "80" + + reactmusicstore: + environment: + - ASPNETCORE_ENVIRONMENT=Development + ports: + - "80" + + reactgrid: + environment: + - ASPNETCORE_ENVIRONMENT=Development + ports: + - "80" diff --git a/docker-compose.vs.debug.yml b/docker-compose.vs.debug.yml new file mode 100644 index 00000000..097a3a40 --- /dev/null +++ b/docker-compose.vs.debug.yml @@ -0,0 +1,62 @@ +version: '2' + +services: + ngmusicstore: + image: ngmusicstore:dev + build: + args: + source: ${DOCKER_BUILD_SOURCE} + environment: + - DOTNET_USE_POLLING_FILE_WATCHER=1 + volumes: + - ./samples/angular/MusicStore:/app + - ~/.nuget/packages:/root/.nuget/packages:ro + - ~/clrdbg:/clrdbg:ro + entrypoint: tail -f /dev/null + labels: + - "com.microsoft.visualstudio.targetoperatingsystem=linux" + + nodeservicesexamples: + image: nodeservicesexamples:dev + build: + args: + source: ${DOCKER_BUILD_SOURCE} + environment: + - DOTNET_USE_POLLING_FILE_WATCHER=1 + volumes: + - ./samples/misc/NodeServicesExamples:/app + - ~/.nuget/packages:/root/.nuget/packages:ro + - ~/clrdbg:/clrdbg:ro + entrypoint: tail -f /dev/null + labels: + - "com.microsoft.visualstudio.targetoperatingsystem=linux" + + reactmusicstore: + image: reactmusicstore:dev + build: + args: + source: ${DOCKER_BUILD_SOURCE} + environment: + - DOTNET_USE_POLLING_FILE_WATCHER=1 + volumes: + - ./samples/react/MusicStore:/app + - ~/.nuget/packages:/root/.nuget/packages:ro + - ~/clrdbg:/clrdbg:ro + entrypoint: tail -f /dev/null + labels: + - "com.microsoft.visualstudio.targetoperatingsystem=linux" + + reactgrid: + image: reactgrid:dev + build: + args: + source: ${DOCKER_BUILD_SOURCE} + environment: + - DOTNET_USE_POLLING_FILE_WATCHER=1 + volumes: + - ./samples/react/ReactGrid:/app + - ~/.nuget/packages:/root/.nuget/packages:ro + - ~/clrdbg:/clrdbg:ro + entrypoint: tail -f /dev/null + labels: + - "com.microsoft.visualstudio.targetoperatingsystem=linux" diff --git a/docker-compose.vs.release.yml b/docker-compose.vs.release.yml new file mode 100644 index 00000000..0bbbea5a --- /dev/null +++ b/docker-compose.vs.release.yml @@ -0,0 +1,42 @@ +version: '2' + +services: + ngmusicstore: + build: + args: + source: ${DOCKER_BUILD_SOURCE} + volumes: + - ~/clrdbg:/clrdbg:ro + entrypoint: tail -f /dev/null + labels: + - "com.microsoft.visualstudio.targetoperatingsystem=linux" + + nodeservicesexamples: + build: + args: + source: ${DOCKER_BUILD_SOURCE} + volumes: + - ~/clrdbg:/clrdbg:ro + entrypoint: tail -f /dev/null + labels: + - "com.microsoft.visualstudio.targetoperatingsystem=linux" + + reactmusicstore: + build: + args: + source: ${DOCKER_BUILD_SOURCE} + volumes: + - ~/clrdbg:/clrdbg:ro + entrypoint: tail -f /dev/null + labels: + - "com.microsoft.visualstudio.targetoperatingsystem=linux" + + reactgrid: + 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 new file mode 100644 index 00000000..a636c85c --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,26 @@ +version: '2' + +services: + ngmusicstore: + image: ngmusicstore + build: + context: ./samples/angular/MusicStore + dockerfile: Dockerfile + + nodeservicesexamples: + image: nodeservicesexamples + build: + context: ./samples/misc/NodeServicesExamples + dockerfile: Dockerfile + + reactmusicstore: + image: reactmusicstore + build: + context: ./samples/react/MusicStore + dockerfile: Dockerfile + + reactgrid: + image: reactgrid + build: + context: ./samples/react/ReactGrid + dockerfile: Dockerfile diff --git a/samples/angular/MusicStore/.dockerignore b/samples/angular/MusicStore/.dockerignore new file mode 100644 index 00000000..d8f8175f --- /dev/null +++ b/samples/angular/MusicStore/.dockerignore @@ -0,0 +1,3 @@ +* +!obj/Docker/publish/* +!obj/Docker/empty/ diff --git a/samples/angular/MusicStore/Dockerfile b/samples/angular/MusicStore/Dockerfile new file mode 100644 index 00000000..81c499e1 --- /dev/null +++ b/samples/angular/MusicStore/Dockerfile @@ -0,0 +1,10 @@ +FROM microsoft/aspnetcore:1.1 +RUN apt-get update +RUN apt-get install curl +RUN curl -sL https://deb.nodesource.com/setup_6.x | bash +RUN apt-get install -y build-essential nodejs +ARG source +WORKDIR /app +EXPOSE 80 +COPY ${source:-obj/Docker/publish} . +ENTRYPOINT ["dotnet", "MusicStore.dll"] diff --git a/samples/angular/MusicStore/MusicStore.csproj b/samples/angular/MusicStore/MusicStore.csproj index 61b754bd..f43f72f9 100644 --- a/samples/angular/MusicStore/MusicStore.csproj +++ b/samples/angular/MusicStore/MusicStore.csproj @@ -6,6 +6,7 @@ netcoreapp1.1 true false + ..\..\..\docker-compose.dcproj diff --git a/samples/angular/MusicStore/Views/Home/Index.cshtml b/samples/angular/MusicStore/Views/Home/Index.cshtml index a2799f70..8386afb5 100755 --- a/samples/angular/MusicStore/Views/Home/Index.cshtml +++ b/samples/angular/MusicStore/Views/Home/Index.cshtml @@ -2,7 +2,7 @@ ViewData["Title"] = "Home Page"; } - + Loading... @await Html.PrimeCacheAsync(Url.Action("GenreMenuList", "GenresApi")) @await Html.PrimeCacheAsync(Url.Action("MostPopular", "AlbumsApi")) diff --git a/samples/angular/MusicStore/Views/Shared/_Layout.cshtml b/samples/angular/MusicStore/Views/Shared/_Layout.cshtml index 562ccf83..fb86b8fa 100755 --- a/samples/angular/MusicStore/Views/Shared/_Layout.cshtml +++ b/samples/angular/MusicStore/Views/Shared/_Layout.cshtml @@ -1,4 +1,4 @@ - + @@ -35,6 +35,13 @@ +
+
+

Running on @Environment.MachineName (@System.Runtime.InteropServices.RuntimeInformation.OSDescription)

+
+
+ @RenderSection("scripts", required: false) + diff --git a/samples/misc/NodeServicesExamples/.dockerignore b/samples/misc/NodeServicesExamples/.dockerignore new file mode 100644 index 00000000..d8f8175f --- /dev/null +++ b/samples/misc/NodeServicesExamples/.dockerignore @@ -0,0 +1,3 @@ +* +!obj/Docker/publish/* +!obj/Docker/empty/ diff --git a/samples/misc/NodeServicesExamples/Dockerfile b/samples/misc/NodeServicesExamples/Dockerfile new file mode 100644 index 00000000..ff8ba83e --- /dev/null +++ b/samples/misc/NodeServicesExamples/Dockerfile @@ -0,0 +1,10 @@ +FROM microsoft/aspnetcore:1.1 +RUN apt-get update +RUN apt-get install curl +RUN curl -sL https://deb.nodesource.com/setup_6.x | bash +RUN apt-get install -y build-essential nodejs +ARG source +WORKDIR /app +EXPOSE 80 +COPY ${source:-obj/Docker/publish} . +ENTRYPOINT ["dotnet", "NodeServicesExamples.dll"] diff --git a/samples/misc/NodeServicesExamples/NodeServicesExamples.csproj b/samples/misc/NodeServicesExamples/NodeServicesExamples.csproj index 62343096..5d3fc910 100644 --- a/samples/misc/NodeServicesExamples/NodeServicesExamples.csproj +++ b/samples/misc/NodeServicesExamples/NodeServicesExamples.csproj @@ -1,4 +1,4 @@ - + @@ -6,6 +6,7 @@ netcoreapp1.1 true false + ..\..\..\docker-compose.dcproj diff --git a/samples/misc/NodeServicesExamples/Views/Shared/_Layout.cshtml b/samples/misc/NodeServicesExamples/Views/Shared/_Layout.cshtml index 93314312..84894bf5 100755 --- a/samples/misc/NodeServicesExamples/Views/Shared/_Layout.cshtml +++ b/samples/misc/NodeServicesExamples/Views/Shared/_Layout.cshtml @@ -7,6 +7,14 @@ @RenderBody() + +
+
+

Running on @Environment.MachineName (@System.Runtime.InteropServices.RuntimeInformation.OSDescription)

+
+
+ @RenderSection("scripts", required: false) + diff --git a/samples/react/MusicStore/.dockerignore b/samples/react/MusicStore/.dockerignore new file mode 100644 index 00000000..d8f8175f --- /dev/null +++ b/samples/react/MusicStore/.dockerignore @@ -0,0 +1,3 @@ +* +!obj/Docker/publish/* +!obj/Docker/empty/ diff --git a/samples/react/MusicStore/Dockerfile b/samples/react/MusicStore/Dockerfile new file mode 100644 index 00000000..81c499e1 --- /dev/null +++ b/samples/react/MusicStore/Dockerfile @@ -0,0 +1,10 @@ +FROM microsoft/aspnetcore:1.1 +RUN apt-get update +RUN apt-get install curl +RUN curl -sL https://deb.nodesource.com/setup_6.x | bash +RUN apt-get install -y build-essential nodejs +ARG source +WORKDIR /app +EXPOSE 80 +COPY ${source:-obj/Docker/publish} . +ENTRYPOINT ["dotnet", "MusicStore.dll"] diff --git a/samples/react/MusicStore/MusicStore.csproj b/samples/react/MusicStore/MusicStore.csproj index 388bcc73..e93e455f 100644 --- a/samples/react/MusicStore/MusicStore.csproj +++ b/samples/react/MusicStore/MusicStore.csproj @@ -1,4 +1,4 @@ - + @@ -6,6 +6,7 @@ netcoreapp1.1 true false + ..\..\..\docker-compose.dcproj diff --git a/samples/react/MusicStore/Views/Shared/_Layout.cshtml b/samples/react/MusicStore/Views/Shared/_Layout.cshtml index 47e4e48f..453c33d5 100755 --- a/samples/react/MusicStore/Views/Shared/_Layout.cshtml +++ b/samples/react/MusicStore/Views/Shared/_Layout.cshtml @@ -1,4 +1,4 @@ - + @@ -7,6 +7,13 @@ @RenderBody() + +
+
+

Running on @Environment.MachineName (@System.Runtime.InteropServices.RuntimeInformation.OSDescription)

+
+
+ @RenderSection("scripts", required: false) diff --git a/samples/react/ReactGrid/.dockerignore b/samples/react/ReactGrid/.dockerignore new file mode 100644 index 00000000..d8f8175f --- /dev/null +++ b/samples/react/ReactGrid/.dockerignore @@ -0,0 +1,3 @@ +* +!obj/Docker/publish/* +!obj/Docker/empty/ diff --git a/samples/react/ReactGrid/Dockerfile b/samples/react/ReactGrid/Dockerfile new file mode 100644 index 00000000..04f7971f --- /dev/null +++ b/samples/react/ReactGrid/Dockerfile @@ -0,0 +1,10 @@ +FROM microsoft/aspnetcore:1.1 +RUN apt-get update +RUN apt-get install curl +RUN curl -sL https://deb.nodesource.com/setup_6.x | bash +RUN apt-get install -y build-essential nodejs +ARG source +WORKDIR /app +EXPOSE 80 +COPY ${source:-obj/Docker/publish} . +ENTRYPOINT ["dotnet", "ReactGrid.dll"] diff --git a/samples/react/ReactGrid/ReactGrid.csproj b/samples/react/ReactGrid/ReactGrid.csproj index 55717763..069958ea 100644 --- a/samples/react/ReactGrid/ReactGrid.csproj +++ b/samples/react/ReactGrid/ReactGrid.csproj @@ -1,4 +1,4 @@ - + @@ -6,6 +6,7 @@ netcoreapp1.1 true false + ..\..\..\docker-compose.dcproj diff --git a/samples/react/ReactGrid/Views/Shared/_Layout.cshtml b/samples/react/ReactGrid/Views/Shared/_Layout.cshtml index 7ea62731..53d449cf 100755 --- a/samples/react/ReactGrid/Views/Shared/_Layout.cshtml +++ b/samples/react/ReactGrid/Views/Shared/_Layout.cshtml @@ -1,4 +1,4 @@ - + @@ -9,6 +9,13 @@
@RenderBody()
+ + + @RenderSection("scripts", required: false)