-
Notifications
You must be signed in to change notification settings - Fork 0
Templates
Dmitry Golubenkov edited this page Aug 9, 2023
·
1 revision
SharpDockerizer supports custom Dockerfile templates that can be used in your solutions and projects to modify the generated file. By default SharpDockerizer uses an internal hard-coded template:
# Auto-generated from default template by SharpDockerizer
FROM sdDotNetSdkImageVersion AS build
sdArgumentsList
WORKDIR /src
sdCopyOnlyProjFileInstructions
sdNuGetSourceInstructions
RUN dotnet restore "sdSelectedProjFileRelativePath"
sdCopyEverythingInstructions
FROM build AS publish
WORKDIR "sdProjectFolderRelativePath"
RUN dotnet publish "sdProjectFileName" --no-restore -c Release -o /app/publish /p:UseAppHost=false
FROM sdAspNetDockerImageVersion AS final
WORKDIR /app
sdExposedPorts
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "sdProjectName.dll"]
As you can see, it uses variable names that start from sd
to determine where to place different things.
SharpDockerizer searches for templates in solution and project folders. Template must have extension .sdtemplate
.
Priority is:
- Use project template
- Use solution template
- Fallback to default
You can copy the default template from wiki and use it to create your own custom template.
If multiple template files exist - it uses the highest in alphabetical order, so that a.sdtemplate
will be used instead of b.sdtemplate
Variable name | Description |
---|---|
sdDotNetSdkImageVersion | Version of .NET SDK image that is used in dockerfile |
sdAspNetDockerImageVersion | Version of ASP.NET image that is used in dockerfile |
sdProjectFileName | Name of project file for which dockerfile is generated |
sdProjectFolderRelativePath | Relative path from solution folder to project folder |
sdProjectName | Name of project for which dockerfile is generated |
sdExposedPorts | Ports that should be exposed inside container |
sdSelectedProjFileRelativePath | Relative path to project file from solution folder |
sdNuGetSourceInstructions | NuGet instructions generated depending on settings |
sdArgumentsList | ARG instructions generated depending on settings |
sdDetectedNuGetConfigs | NuGet config files that were detected in solution and projects |
sdCopyOnlyProjFileInstructions | All COPY instructions for proj files, without the rest of files. Can be used to restore nuget packages |
sdCopyEverythingInstructions | All COPY instructions for all files of projects that would be built |