How To Deploy Your Apps From RAD Studio To Docker
By Md. Ehsanul Haque Kanan August 19, 2021
Docker helps you to simplify and automate the deployment process for your applications effectively. It enables you to package your software in a way that is predictable and consistent. That’s why it has become very popular among development teams around the globe. In this post, you will know the details of deploying your application from RAD Studio to Docker. Let’s dive in.
2. Next, you have to specify the program.
3. Then you have to use different units, like System.Classes, System.Types, and System.SysUtil.
4. Now, you have to specify server packages, server module path and target settings path.
5. Then you have to define ResStream, IniFile, and LCommand variables.
6. Finally, you have to use these lines:
или Зарегистрируйся
By Md. Ehsanul Haque Kanan August 19, 2021
Docker helps you to simplify and automate the deployment process for your applications effectively. It enables you to package your software in a way that is predictable and consistent. That’s why it has become very popular among development teams around the globe. In this post, you will know the details of deploying your application from RAD Studio to Docker. Let’s dive in.
What is Docker?
Docker is an open-source containerization platform for building, deploying, and managing applications. It enables you to package apps into containers, which simplifies the delivery significantly. It takes away repetitive tasks from the product development lifecycle to accelerate the process of building applications.Why should you use Docker?
- Streamlines the development lifecycle for fast and consistent delivery of your applications
- Supports responsive deployment and scaling
- Offers a lightweight, fast and cost-effective solution
How do I deploy an app from RAD Studio to a Docker container?
Deploying from RAD Studio to Docker is pretty simple. You just need to follow these processes: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. Next, you have to specify the program.
Код:
program RADServerDockerDeploy;
{$APPTYPE CONSOLE}
{$R *.res}
Код:
uses
System.Classes,
System.Types,
System.SysUtils,
{$IF DEFINED(POSIX)}
Posix.Stdlib,
{$ENDIF POSIX}
IniFiles;
Код:
сonst
SERVER_PACKAGES = 'Server.Packages';
TARGET_MODULE_PATH = '/etc/ems/module.so';
TARGET_SETTINGS_PATH = '/etc/ems/emsserver.ini';
Код:
var
ResStream: TResourceStream;
IniFile: TMemIniFile;
{$IF DEFINED(POSIX)}
LCommand: String;
{$ENDIF}
Код:
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.