You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1.4 KiB
1.4 KiB
sidebar_position | sidebar_label | title |
---|---|---|
1 | Generate Docker file | Generate Docker file |
How to generate my docker file
It is possible to generate a Dockerfile
automaticly with Visual Studio.
On your project, click right and select Add
=> Docker Support...
:
Select the Linux
target:
A new file Dockerfile
are created in your project.
The nuget configuration
If you use specific repositories, you must use a nuget.config
file.
Don't forget to add your nuget.config
to your build image, just after WORKDIR /src
add COPY ["nuget.config", "."]
:::caution
If you don't add the file, restore nuget does not work, by default restore search on nuget.org
:::
Example of Dockerfile
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 ["nuget.config", "."]
COPY ["MyBeautifulApp/MyBeautifulApp.csproj", "MyBeautifulApp/"]
RUN dotnet restore "MyBeautifulApp/MyBeautifulApp.csproj"
COPY . .
WORKDIR "/src/MyBeautifulApp"
RUN dotnet build "MyBeautifulApp.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "MyBeautifulApp.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "MyBeautifulApp.dll"]