Docker enables you to simplify the deployment process effectively. It allows you to quickly deploy and scale applications into any environment. It is widely being used by development teams around the world. In this blog post, you will get an overview of docker deployment using RAD Server Engine, InterBase database, and PAServer. Let’s dive in.
Table of Contents
What is Docker?
Docker is a tool that enables you to easily pack, ship, and run any application as a lightweight container. It makes your app portable. You can modify and update the program easily. Also, you can run the application virtually anywhere.
Why should you use Docker?
- Facilitates more efficient use of system resources
- Boosts software delivery lifecycles significantly
- Provides application portability
How do I deploy an application to a Docker container?
There are several ways to deploy an application to a Docker container. You will find them right here.
Docker Deployment With RAD Server Engine
With Pa-radserver, you can test, debug, and deploy Linux applications and custom RAD Server endpoints easily. Also, you can deploy RAD Server in a production environment.
Configure the Project File:
1. Create a file, called RADServerDockerDeploy.dpr. It will have the source code of the main file in the project.
2. Then start adding the code. First, you have to specify the program.
1 2 3 4 5 6 |
program RADServerDockerDeploy; {$APPTYPE CONSOLE} {$R *.res} |
3. Now, you have to use different units, like System.Classes, System.Types, and System.SysUtil.
1 2 3 4 5 6 7 8 |
uses System.Classes, System.Types, System.SysUtils, {$IF DEFINED(POSIX)} Posix.Stdlib, {$ENDIF POSIX} IniFiles; |
4. Next, you have to specify server packages, server module path, and target settings path.
1 2 3 4 |
const SERVER_PACKAGES = 'Server.Packages'; TARGET_MODULE_PATH = '/etc/ems/module.so'; TARGET_SETTINGS_PATH = '/etc/ems/emsserver.ini'; |
5. Now, you have to define ResStream, IniFile, and LCommand variables.
1 2 3 4 5 6 |
var ResStream: TResourceStream; IniFile: TMemIniFile; {$IF DEFINED(POSIX)} LCommand: String; {$ENDIF} |
6. Finally, you have to add these lines:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
try // Add your RAD Server resource module .so file via Project|Resources and Images...|Add... // Be sure to set Identifier to Module and Type should be set to RCDATA ResStream := TResourceStream.Create(HInstance, 'Module', RT_RCDATA); try ResStream.Position := 0; ResStream.SaveToFile(TARGET_MODULE_PATH); finally ResStream.Free; end; IniFile := TMemIniFile.Create(TARGET_SETTINGS_PATH); IniFile.EraseSection(SERVER_PACKAGES); IniFile.WriteString(SERVER_PACKAGES,TARGET_MODULE_PATH,ExtractFileName(TARGET_MODULE_PATH)); IniFile.UpdateFile; IniFile.Free; {$IF DEFINED(POSIX)} LCommand := 'service apache2 restart'; _system(PAnsiChar(AnsiString(LCommand))); {$ENDIF POSIX} except on E: Exception do Writeln(E.ClassName, ': ', E.Message); end; |
How does the finished Delphi .Dproj file look like?
You can view the finished Delphi .Dproj file right here.
Source Code:
You can find the source code on GitHub.
Docker Deployment with InterBase Database
The pa-radserver-ib Docker image contains the functionalities of InterBase, which is the RAD Server database. You can configure pa-radserver-ib Dockerfile to accept a RAD Server license SLIP file. It will enable you to create a fully licensed Docker container.
Configure the Project File:
1. Create a file, called RADServerDockerDeploy.dpr.
2. Next, you need to specify the program.
1 |
program RADServerDockerDeploy; |
3. Then add these lines:
1 2 3 |
{$APPTYPE CONSOLE} {$R *.res} |
4. Then you have to use different units and libraries, like System.SysUtils and Posix.Stdlib.
1 2 3 4 5 6 7 8 |
uses System.Classes, System.Types, System.SysUtils, {$IF DEFINED(POSIX)} Posix.Stdlib, {$ENDIF POSIX} IniFiles; |
5. Now, you have to define server packages, target module path and target settings path.
1 2 3 4 |
const SERVER_PACKAGES = 'Server.Packages'; TARGET_MODULE_PATH = '/etc/ems/module.so'; TARGET_SETTINGS_PATH = '/etc/ems/emsserver.ini'; |
6. Next, you can specify ResStream, IniFile, and LCommand variables.
1 2 3 4 5 6 |
var ResStream: TResourceStream; IniFile: TMemIniFile; {$IF DEFINED(POSIX)} LCommand: String; {$ENDIF} |
7. Finally, you have to insert this code (between the “program
” and “end.
” lines)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
begin try // Add your RAD Server resource module .so file via Project|Resources and Images...|Add... // Be sure to set Identifier to Module and Type should be set to RCDATA ResStream := TResourceStream.Create(HInstance, 'Module', RT_RCDATA); try ResStream.Position := 0; ResStream.SaveToFile(TARGET_MODULE_PATH); finally ResStream.Free; end; IniFile := TMemIniFile.Create(TARGET_SETTINGS_PATH); IniFile.EraseSection(SERVER_PACKAGES); IniFile.WriteString(SERVER_PACKAGES,TARGET_MODULE_PATH,ExtractFileName(TARGET_MODULE_PATH)); IniFile.UpdateFile; IniFile.Free; {$IF DEFINED(POSIX)} LCommand := 'service apache2 restart'; _system(PAnsiChar(AnsiString(LCommand))); {$ENDIF POSIX} except on E: Exception do Writeln(E.ClassName, ': ', E.Message); end; end. |
How does the finished Delphi .Dproj file look like?
You can see the finished Delphi .Dproj file on GitHub.
Source Code:
You can find the source code right here.
Docker Deployment Via PAServer
The PAserver Docker image contains PAServer and BoradwayD. PAServer enables you to deploy console and GUI based applications easily. On the other hand, the BroadwayD server allows you to view the GUI applications through a web browser.
Configure the Docker File
1. First, you have to create a file, called Dockerfile.
2. Then add this code:
1 2 3 |
FROM ubuntu:bionic ARG password=embtdocker |
3. Now, you can set PA Server password.
1 |
ENV PA_SERVER_PASSWORD=$password |
4. Then add paserver.tar.gz file.
1 |
ADD https://altd.embarcadero.com/releases/studio/21.0/1/PAServer/LinuxPAServer21.0.tar.gz ./paserver.tar.gz |
5. Finally, add these lines:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
COPY paserver_docker.sh ./paserver_docker.sh RUN tar xvzf paserver.tar.gz RUN mv PAServer-21.0/* . RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -yy install xorg libgl1-mesa-dev libosmesa-dev libgtk-3-bin build-essential libcurl3 libcurl-openssl1.0-dev RUN chmod +x paserver_docker.sh EXPOSE 64211 EXPOSE 8082 CMD ./paserver_docker.sh |
Source Code:
You can get the source code at GitHub.
Should I use Docker for deployment?
Docker allows you to deploy the applications quickly and efficiently. It enables you to easily pack and run any app as a lightweight and portable container, which can run virtually anywhere. So, you should definitely consider using it.
Interested to deploy your server? Rapidly build and deploy services-based applications with the Rad Server’s IDE Software.
Design. Code. Compile. Deploy.
Start Free Trial Upgrade Today
Free Delphi Community Edition Free C++Builder Community Edition