0
votes

I have set up an angular 4 app inside asp.net core. When I build it from VS, all is good and works.

Now I would like to use docker to create an image to run a container. The Dockerfile is like:

FROM microsoft/aspnetcore-build as build-env

WORKDIR /source

COPY . .

RUN dotnet restore

RUN dotnet publish -o /publish --configuration Release

FROM microsoft/aspnetcore:

WORKDIR /app

COPY --from=build-env /publish .

ENTRYPOINT ["dotnet", "MyApp.dll"]

When I run docker-compose up, I can see the website is running without angular. It seems I need to install npm or more stuff, however, I couldn't find a proper solution on who to configure dockerfile to build the asp.net core and angular 4.

Could anyone provide an example?

Thanks

1

1 Answers

0
votes

That's what I did and it works perfectly for us:

FROM microsoft/aspnetcore-build:2.0.1 AS my-dotNet-Build

WORKDIR /myApp

COPY . ./

RUN dotnet publish -o publish

FROM node:8.9.1 AS my-angular-build

WORKDIR /myApp

COPY . ./

RUN npm install \ && npm run build:prod

FROM microsoft/aspnetcore:2.0.3

WORKDIR /app

COPY --from=my-dotNet-Build /myApp/publish .

COPY --from=my-angular-build /myApp/wwwroot /myApp/wwwroot

ENTRYPOINT ["dotnet", "yourApp.dll"]