Visual Studio 2017 docker support not available for ASP.Net Core Angular or React projects

Does anyone have an idea why Visual Studio 2017 has a checkbox that allows Docker support for ASP.NET Core templates for empty web applications, web applications and web applications (MVC), but not for Angular SPA templates React.js or React.js and Redux?

Are there any resources showing how to add Docker support to these SPA templates? My google-fu is strong, but I can not find.

+7
source share
2 answers

I am not sure why this check box is disabled when selecting a template during project installation. However, you can add Docker support by following these steps:

  1. Installation project
  2. Right-click project in solution explorer
  3. Mouse over add
  4. Click Docker Support

What this will do is create some docker build files and one Docker file, which basically uses only the dotnet CLI to run the publish command in the solution. There is nothing special about the interface code. By default, using these templates, webpack assembly information is placed in the .csproj file. You can learn more about the function "Add docker support" here .

Below is how to add docker support in Visual Studio for Mac 2017, but it works the same on Windows.

Adding Docker support to project (on Visual Studio for Mac, but is the same for Windows)

+5
source

The reason you see this error is because for SPA projects, csproj contains commands to follow the steps defined in package.json, to create the package (ng build, webpack, etc.). And this requires Node to be INSIDE the build container, which needs to be added explicitly. You will need to make sure that the version of the node that you are using in the container will work with the assembly sample of your choice. In most cases, this should not be a problem, but in the case, at least, you now know.

You will need to add the following to the Docker file after building the dotnet and before the dotnet steps are published, as shown below. My example uses node 10.13, because it supports the build image that we extract to deploy Azure Container.

RUN dotnet build ... # **** Adding Node - Start ADD https://nodejs.org/dist/v10.13.0/node-v10.13.0-win-x64.zip "C:\build\node-v10.13.0-win-x64.zip" RUN PowerShell Expand-Archive C:\build\node-v10.13.0-win-x64.zip C:/ RUN PowerShell Rename-Item C:\node-v10.13.0-win-x64 node RUN SETX PATH C:\node ENTRYPOINT C:\node\node.exe # **** Adding Node - End FROM build AS publish RUN dotnet publish ... 
0
source

Source: https://habr.com/ru/post/1272773/


All Articles