[
I have created an angular application on a windows machine using the following code.
dotnet new angular
Next I saw that there is an option to add Docker support from within Visual Studio .NET, so I installed that using the option.
Here is the file that is produced.
FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
WORKDIR /src
COPY ["MOCK3/PBS.Mock3.csproj", "MOCK3/PBS.Mock3/"]
RUN dotnet restore "MOCK3/PBS.Mock3.csproj"
COPY . .
WORKDIR "/src/MOCK3/PBS.Mock3"
RUN dotnet build "PBS.Mock3.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "PBS.Mock3.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "PBS.Mock3.dll"]
Unfortunately, the application cannot find npm installed on the docker instance when it is run and produces the following error.
The error output was: 'npm' is not recognized as an internal or external command,
After researching, I found examples of how to run and install npm in the docker file but this doesn’t work so I assume that it is for Linux users. Those posts generally have the following (which as mentioned does not work on my machine).
RUN apt-get update -yq \
&& apt-get install curl gnupg -yq \
&& curl -sL https://deb.nodesource.com/setup_14.x | bash \
&& apt-get install nodejs -yq
This doesn’t work as advertised and there is no mention of environment in which it should work. Before, I go and start installing unneeded windows cli applications which is the tried and true Windows approach that I have been unable to find anywhere?
,
The Docker Images comes with the simplest environment inside the containers. You can use Node Image(https://hub.docker.com/_/node), that contains only the node installed. Or the aspnet, containing only aspnet instead. But to a combined scenario you need to install one or another.
In docker, you can install some image based on Linux distribution like Debian or alpine, which is very small and light. You can find a lot of examples.
You can try to install the node with powershell commands. I don’t know an specific script to get and install the node, but you can research or use some examples, like this one (https://github.com/dotnet/dotnet-docker/blob/e216a0d5e9f56c464bd46e7155c84dbcf832f1d9/src/sdk/5.0/windowsservercore-ltsc2019/amd64/Dockerfile)
You can also try to “merge” two containers. (https://abdelrahmanhosny.wordpress.com/2015/07/11/how-to-merge-two-docker-images/). In fact, what it says is to generate the history and reproduce the command stack.
I think the best option is to use a specific distribution tag image. I recommend alpine.
]