I've created the ASP.NET Core Angular project with dotnet new angular and hosted in the docker.
How to look for file changes without having to reboot the docker containers again?
Dockerfile
FROM mcr.microsoft.com/dotnet/sdk:5.0-buster-slim AS build
WORKDIR /app
COPY "3_UI/MyAccounts.Web/MyAccounts.Web.csproj" ./myapp/
RUN dotnet restore "./myapp/MyAccounts.Web.csproj"
COPY "3_UI/MyAccounts.Web/." ./myapp/
WORKDIR /app/myapp
# Install Node, NPM and VS Debugger
RUN apt-get update && apt-get install -y curl sudo unzip procps
RUN apt-get install -y --no-install-recommends apt-utils
RUN curl -sSL https://aka.ms/getvsdbgsh | bash /dev/stdin -v latest -l /publish/vsdbg;
RUN sudo apt-get install -y nodejs
RUN curl -L https://npmjs.org/install.sh | sudo sh
RUN echo "NODE Version:" && node --version
RUN echo "NPM Version:" && npm --version
RUN dotnet publish -c Debug -o out
FROM mcr.microsoft.com/dotnet/aspnet:5.0-buster-slim AS runtime
WORKDIR /app
EXPOSE 9000
# Install Node, NPM and VS Debugger
RUN apt-get update && apt-get install -y curl sudo unzip procps
RUN apt-get install -y --no-install-recommends apt-utils
RUN curl -sSL https://aka.ms/getvsdbgsh | bash /dev/stdin -v latest -l /publish/vsdbg;
RUN sudo apt-get install -y nodejs
RUN curl -L https://npmjs.org/install.sh | sudo sh
RUN echo "NODE Version:" && node --version
RUN echo "NPM Version:" && npm --version
# ENV ASPNETCORE_ENVIRONMENT=development
ENV ASPNETCORE_URLS=http://+:9000
COPY --from=build /app/myapp/out .
ENTRYPOINT [ "dotnet", "MyAccounts.Web.dll"]
Thought adding ENV ASPNETCORE_ENVIRONMENT=development will watch for client app file changes but it is throwing the below error after the container is up.
app_web_service | npmfail: Microsoft.AspNetCore.SpaServices[0]
app_web_service | npm ERR! code ENOENT
app_web_service |
app_web_service | fail: Microsoft.AspNetCore.SpaServices[0]
app_web_service | npm ERR! syscall open
app_web_service |
app_web_service | fail: Microsoft.AspNetCore.SpaServices[0]
app_web_service | npm ERR! path /app/ClientApp/package.json
app_web_service |
app_web_service | fail: Microsoft.AspNetCore.SpaServices[0]
app_web_service | npm ERR! errno -2
app_web_service |
app_web_service | fail: Microsoft.AspNetCore.SpaServices[0]
app_web_service | npm ERR! enoent ENOENT: no such file or directory, open '/app/ClientApp/package.json'
app_web_service |
app_web_service | fail: Microsoft.AspNetCore.SpaServices[0]
app_web_service | npm ERR! enoent This is related to npm not being able to find a file.
app_web_service |
app_web_service | fail: Microsoft.AspNetCore.SpaServices[0]
app_web_service | npm ERR! enoent
app_web_service |
app_web_service | npm ERR!fail: Microsoft.AspNetCore.SpaServices[0]
app_web_service | npm ERR! A complete log of this run can be found in:
app_web_service |
app_web_service | fail: Microsoft.AspNetCore.SpaServices[0]
app_web_service | npm ERR! /root/.npm/_logs/2021-05-08T11_54_23_879Z-debug.log
Any other configurations missing to watch for file changes?
I am having this working but still not the optimised way. I have split .NET Core and Angular in its own container.
Angular ClientApp
.NET Core App
Docker Compose