Back to Blog
How to Write a Dockerfile for an ABP Framework Application
DevOps

How to Write a Dockerfile for an ABP Framework Application

Mihadul IslamOctober 21, 20255 min read

Summary

Learn how to create a production-ready Dockerfile for your ABP Framework application using .NET 9 multi-stage builds. It installs Node.js, Yarn, and ABP CLI to handle both backend and frontend assets efficiently. The final lightweight image runs your ABP app seamlessly in any environment.

What is ABP Framework?

ABP Framework is a complete open-source application development platform built on ASP.NET Core. It provides modular architecture, dependency injection, multi-tenancy, and ready-to-use application templates.

When we containerize an ABP app, we are basically packaging an ASP.NET Core project (with front-end libraries) into a Docker image that can run independently.

Prerequisites

Before you start, make sure you have:

  1. Docker installed on your system

  2. An ABP web project (for example: ChatUapp.Web)

  3. Basic understanding of .NET SDK commands

Project Structure Example

Here’s what a common ABP solution looks like:

ChatUapp/
│
├── src/
│   ├── ChatUapp.Domain/
│   ├── ChatUapp.Application/
│   ├── ChatUapp.EntityFrameworkCore/
│   └── ChatUapp.Web/          ← our main web app
│
├── .dockerignore
├── Dockerfile
└── docker-compose.yml

We’ll focus mainly on the ChatUapp.Web project since it’s the entry point of the application.

Step 1: Start with the Base Image

The base image contains the ASP.NET Core runtime.
We’ll use .NET 9.0 here.

FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base
WORKDIR /app
EXPOSE 44361
ENV ASPNETCORE_URLS=http://+:44361

This part defines the environment where your app will run.
It exposes port 44361 and sets up the base working directory.

Step 2: Create the Build Stage

The build stage installs SDK tools, Node.js, and Yarn (required by ABP for client-side assets).

FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
WORKDIR /buildprocess

# Install Node.js
ENV NODE_VERSION=24.4.0
ENV NODE_DOWNLOAD_URL=https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-x64.tar.gz
RUN apt-get update && apt-get install -y curl \
    && curl -SL "$NODE_DOWNLOAD_URL" --output nodejs.tar.gz \
    && tar -xzf "nodejs.tar.gz" -C /usr/local --strip-components=1 \
    && rm nodejs.tar.gz \
    && ln -s /usr/local/bin/node /usr/local/bin/nodejs \
    && apt-get purge -y curl && rm -rf /var/lib/apt/lists/*

# Install Yarn
ENV YARN_VERSION=1.22.22
RUN npm install -g yarn@$YARN_VERSION

ABP needs Node.js and Yarn for front-end package management.
We install them only in the build image to keep the final image small.

Step 3: Copy Source Code

Copy the entire project into the build container.

COPY . .
WORKDIR /buildprocess/src/ChatUapp.Web
RUN ls -l

Step 4: Install ABP CLI and Client Libraries

ABP uses its own CLI tool (Volo.Abp.Cli) to install UI libraries under wwwroot/libs.

RUN dotnet tool install -g Volo.Abp.Cli
ENV PATH="${PATH}:/root/.dotnet/tools"
RUN abp install-libs

This step ensures that all client-side dependencies (like jQuery, Bootstrap, etc.) are included inside your Docker image.

Step 5: Build and Publish

Now we compile and publish the web app into a folder called /app/publish.

RUN dotnet publish "/buildprocess/src/ChatUapp.Web/ChatUapp.Web.csproj" -c Release -o /app/publish /p:UseAppHost=false

This command creates a ready-to-run output for your ABP web application.

Step 6: Build the Final Image

The final image only contains the runtime and your published files.

FROM base AS final
WORKDIR /app
COPY --from=build /app/publish .
ENTRYPOINT ["dotnet", "ChatUapp.Web.dll"]

This is the image that will actually run in production.

Step 7: Add a .dockerignore File

To make builds faster, exclude unnecessary files:

**/bin
**/obj
**/.vs
**/.vscode
**/node_modules
**/dist
.git
Dockerfile
docker-compose.yml

This keeps the Docker build context small.

Step 8: Build and Run the Container

Run these commands from your project root:

docker build -t chatuapp-web:latest .
docker run -d -p 8080:44361 chatuapp-web:latest

Then open your browser at:

http://localhost:8080

Your ABP application should be running inside Docker!

Step 9: Using docker-compose (Optional)

You can also create a docker-compose.yml file to run the app easily:

services:
  chatuapp:
    image: chatuapp-web:latest
    container_name: chatuapp-web
    ports:
      - "8080:44361"
    environment:
      ASPNETCORE_ENVIRONMENT: "Production"

Then just run:

docker compose up -d

Step 10: Environment Configuration

ABP supports environment variables automatically.

For example, you can pass database connection strings like this:

-e ConnectionStrings__Default="Server=db;Database=ChatUapp;User Id=sa;Password=StrongPassword;"

ASP.NET Core replaces double underscores (__) with colons (:), so this maps to ConnectionStrings:Default in your appsettings.json.

Step 11: Production Tips

  1. Use multi-stage builds (as shown) to keep images small.

  2. Avoid running ABP CLI inside the final image — only in the build stage.

  3. Use a reverse proxy like Nginx or Traefik for SSL termination.

  4. Always tag your image versions for easy rollback.

Full Dockerfile (Final Version)

Here’s the full Dockerfile you can copy directly:

# Base image
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base
WORKDIR /app
EXPOSE 44361
ENV ASPNETCORE_URLS=http://+:44361

# Build image
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
WORKDIR /buildprocess

# Install Node.js
ENV NODE_VERSION=24.4.0
ENV NODE_DOWNLOAD_URL=https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-x64.tar.gz
RUN apt-get update && apt-get install -y curl \
    && curl -SL "$NODE_DOWNLOAD_URL" --output nodejs.tar.gz \
    && tar -xzf "nodejs.tar.gz" -C /usr/local --strip-components=1 \
    && rm nodejs.tar.gz \
    && ln -s /usr/local/bin/node /usr/local/bin/nodejs \
    && apt-get purge -y curl && rm -rf /var/lib/apt/lists/*

# Install Yarn
ENV YARN_VERSION=1.22.22
RUN npm install -g yarn@$YARN_VERSION

# Copy project files
COPY . .
WORKDIR /buildprocess/src/ChatUapp.Web

# Install ABP CLI and libs
RUN dotnet tool install -g Volo.Abp.Cli
ENV PATH="${PATH}:/root/.dotnet/tools"
RUN abp install-libs

# Publish
RUN dotnet publish "/buildprocess/src/ChatUapp.Web/ChatUapp.Web.csproj" -c Release -o /app/publish /p:UseAppHost=false

# Final image
FROM base AS final
WORKDIR /app
COPY --from=build /app/publish .
ENTRYPOINT ["dotnet", "ChatUapp.Web.dll"]

Conclusion

That’s it! You’ve just learned how to write a complete Dockerfile for an ABP Framework application.

With this setup:

  • The build process installs Node.js, Yarn, and ABP CLI

  • Client libraries are bundled automatically

  • The final Docker image stays lightweight and production-ready

Now your ABP app can run anywhere — whether on local Docker, cloud containers, or Kubernetes.

Tags
dockerfileabp frameworkhow to write a dockerfile for an abp framework application