Application with FastReport .NET in Docker with Linux

Docker is a software platform for rapid development, testing and launching of applications. Due to it, one may locate multiple containers on one server. The containers are understood as integrity of our application, its dependences, and image. One should remember that an image is a template which represents a cast of a file system. As we have recollected a number of terms, we may speak of how to boost FastReport.Core + FastReport.Web in our container.

First, we need to install Docker onto any Linux distributive, in our case Ubuntu 20.04. On installing Docker with Linux you may read this article. After installing and checking, you may proceed to the next step.

Now we have to create DockerFile. It is an ordinary text document containing all commands for building an image. You may build and edit this file both in an ordinary word processor or in VS code. By the way, VS code has a convenient docker plug-in, which to some extent simplifies coding and editing.

An example of DockerFile:

FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base
RUN ln -s /lib/x86_64-linux-gnu/ /lib/x86_64-linux-gnu/
RUN apt-get update \
 && apt-get install -y --allow-unauthenticated \
 libc6-dev \
 libgdiplus \
 libx11-dev \
 && rm -rf /var/lib/apt/lists/*
FROM microsoft/dotnet:2.1-sdk AS build
COPY ["fastreport_net", "FastReport.Net"]
RUN dotnet restore "FastReport.Net/Demos/Core/FastReport.Core.Web21.MVC/FastReport.Core.Web21.MVC.csproj"
COPY . .
WORKDIR "/src/FastReport.Net/Demos/Core/FastReport.Core.Web21.MVC"
RUN dotnet build "FastReport.Core.Web21.MVC.csproj" -c Release -o /app
FROM build AS publish
RUN dotnet publish "FastReport.Core.Web21.MVC.csproj" -c Release -o /app
FROM base AS final
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "FastReport.Core.Web21.MVC.dll"]

This docker file unfolds the image of a Demo application of FastReport.Core.Web21.MVC, which uses FastReport.Web and FastReport.Core. You may try it yourself in the next link, or find a directory Demos\Core\FastReport.Core.Web21.MVC when downloading FastReport.NET.

After writing DockerFile you must build it. It is very simple. Start a terminal from the directory which DockerFile is located in, and write the command into it:

sudo docker build

After successful build, unfold the container with a command:

sudo docker run -d -p 8080:80 build/fastreport 

In this command we forward port 8080 and name the image as “build/fastreport”.

After the successful start of the container, we open http://localhost:8080/. Then we transfer to the page of our application; if all dependences were executed and resolved, then we will see our project:

Ready project

To sum it up, Docker executes unfolding with literally two commands, while containers take much less space than the virtual machine images, which saves a lot of time and space.

Fast Reports
  • 800-985-8986 (English, US)
  • +4930568373928 (German)
  • +55 19 98147-8148 (Portuguese)
  • 901 N Pitt Str #325 Alexandria VA 22314

© 1998-2024 Fast Reports Inc.