HomeDev GuideRecipesAPI Reference
Dev GuideAPI ReferenceUser GuideGitHubNuGetDev CommunityOptimizely AcademySubmit a ticketLog In
Dev Guide

Create a Dockerfile for a CMS application

Describes how to create a Docker file for an Optimizely Content Management System (CMS) application.

Containerize an Optimizely Content Management System (CMS) 13 application so it deploys consistently across Linux and Windows hosts. This article walks through the Dockerfile, the .dockerignore file, and the commands to build and run the image.

Before you begin

  • Docker Desktop installed on your machine.
  • A buildable CMS 13 ASP.NET Core application. The project in this example is episerversample. See Install a sample site.
  • A chosen container mode (Linux or Windows) in Docker Desktop.

If you are new to ASP.NET, follow the ASP.NET Get Started tutorial to initialize a project, or clone the ASP.NET Docker Sample.

Create a Dockerfile for the application

  1. Create a Dockerfile in your project folder.

  2. Add the following content to your Dockerfile for Linux or Windows containers. The tags are multi-arch: they pull Windows or Linux containers depending on the mode set in Docker Desktop for Windows. See Switch between Windows and Linux containers.

    FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build-env
    WORKDIR /app
    
    COPY *.csproj ./
    RUN dotnet restore
    
    COPY . ./
    RUN dotnet publish -c Release -o out
    
    FROM mcr.microsoft.com/dotnet/aspnet:10.0
    WORKDIR /app
    COPY --from=build-env /app/out .
    
    EXPOSE 80
    
    ENTRYPOINT ["dotnet", "episerversample.dll"]
  3. The Dockerfile assumes the application is episerversample. Change the ENTRYPOINT line to reference the DLL of your project.

  4. To minimize the build context, add a .dockerignore file to your project folder with the following contents:

    bin/
    obj/

Build and run the Docker image

  1. Open a command prompt and go to your project folder.

  2. Build the Docker image:

    docker build -t episerversample .
  3. Run the Docker image:

    docker run -it -e "Urls=http://+:80" -p 8080:80 episerversample