Answer the question
In order to leave comments, you need to log in
What is the correct way to create a Docker file in a .net core + react project?
Tell me how to create a docker file for two projects, .net core + react? Separately, for each project, a separate file and then combine via docker-compose or one common file?
Project structure:
TestApp:
- TestApp
- TestApp.Core
- TestApp.Database
- ClientApp
And below current Docker file is shared but it doesn't work correctly:
ARG REPO=mcr.microsoft.com/dotnet/core
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
ENV BuildingDocker true
WORKDIR /src
COPY ["TestApp/TestApp.csproj", "TestApp/"]
COPY ["TestApp.Core/TestApp.Core.csproj", "TestApp.Core/"]
COPY ["TestApp.Database/TestApp.Database.csproj", "TestApp.Database/"]
RUN dotnet restore "TestApp/TestApp.csproj"
COPY . .
WORKDIR "/src/TestApp"
RUN dotnet build "TestApp.csproj" -c Release -o /app/build
FROM node:12-alpine as build-node
WORKDIR ClientApp
COPY ClientApp/package.json .
COPY ClientApp/package-lock.json .
RUN npm install
COPY ClientApp/ .
RUN npm run-script build
FROM build AS publish
RUN dotnet publish "TestApp.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
COPY --from=build-node /ClientApp/build ./ClientApp/build
CMD ASPNETCORE_URLS=http://*:$PORT dotnet TestApp.dll
Answer the question
In order to leave comments, you need to log in
In general, static is usually not included in the container - it can be distributed immediately with nginx.
An example of a Dockerfile for backing is in the documentation .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question