Create Docker image
How to create a DynamicWeb 10 Docker image.
Official DynamicWeb 10 images are available on Docker Hub, and it's recommended to use these images. Other requirements, like including certain files in a deployment that follow the application rather than the solution, might be necessary. Therefore, this guide will describe how to create approaches for accomplishing this.
Creating a custom host application
The simplest way to create a custom Docker image is to use the official NuGet packages to create a custom host application. Using the dotnet new
project templates makes this a breeze.
This Dockerfile
describes how to create an image with a DynamicWeb 10 Suite running as a non-root user with default environment variables.
FROM mcr.microsoft.com/dotnet/sdk:8.0 as base
ARG DW_PACKAGE=suite
WORKDIR /src
RUN dotnet new install Dynamicweb.ProjectTemplates
RUN dotnet new dw10-${DW_PACKAGE} -o ./App
RUN dotnet publish ./App -c Release -o ./publish
RUN dotnet dev-certs https -ep ./data/ssl/dw.pfx -p dw
RUN mkdir ./data/Files
FROM mcr.microsoft.com/dotnet/aspnet:8.0
RUN groupadd -g 999 appuser && \
useradd -r -m -u 999 -g appuser appuser
USER appuser
WORKDIR /dynamicweb
COPY --from=base --chown=999:999 /src/publish .
COPY --from=base --chown=999:999 /src/data /data
ENV DW_FilesPath=/data/Files
ENV Logging__LogLevel__Microsoft=Warning
ENV ASPNETCORE_URLS=https://+;http://+
ENV ASPNETCORE_Kestrel__Certificates__Default__Password=dw
ENV ASPNETCORE_Kestrel__Certificates__Default__Path=/data/ssl/dw.pfx
ENTRYPOINT ["dotnet", "App.dll"]
It might be necessary to inject a custom SSL certificate. In that case, leave out the RUN dotnet dev-certs
command and update the environment variables accordingly.
Building upon the official images
Another approach is to build a custom image on the official DynamicWeb images on Docker Hub.