Application with FastReport .NET in Docker with Linux

2021-11-17

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
WORKDIR /app
 
RUN ln -s /lib/x86_64-linux-gnu/libdl-2.24.so /lib/x86_64-linux-gnu/libdl.so
RUN apt-get update \
 && apt-get install -y --allow-unauthenticated \
 libc6-dev \
 libgdiplus \
 libx11-dev \
 && rm -rf /var/lib/apt/lists/*
ENV DISPLAY :99
 
FROM microsoft/dotnet:2.1-sdk AS build
WORKDIR /src
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
WORKDIR /app
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.

October 04, 2023

How to generate a report from an ASP.NET Core application using FastReport.Core.Skia

We tell you how to generate a report on Windows and Linux using FastReport.Core.Skia and a private NuGet server.
March 22, 2023

Creating PDF report in JetBrains Rider (C#) on Ubuntu 22.04.1 LTS

In this article, we'll take a look at the world of the .NET platform on Ubuntu 22.04.1 LTS and create a PDF exportable report.
February 14, 2023

How to set up an Apache2 web server for FastReport .NET

We are launching the Apache2 web server on the Linux operating system for FastReport.NET and .NET 5 with a few simple commands.
Fast Reports
  • 800-985-8986 (English, US)
  • +4930568373928 (German)
  • +55 19 98147-8148 (Portuguese)
  • info@fast-report.com
  • 901 N Pitt Str #325 Alexandria VA 22314

© 1998-2024 Fast Reports Inc.