DELPHI盒子
!实时搜索: 盒子论坛 | 注册用户 | 修改信息 | 退出
检举帖 | 全文检索 | 关闭广告 | 捐赠
技术论坛
 用户名
 密  码
自动登陆(30天有效)
忘了密码
≡技术区≡
DELPHI技术
lazarus/fpc/Free Pascal
移动应用开发
Web应用开发
数据库专区
报表专区
网络通讯
开源项目
论坛精华贴
≡发布区≡
发布代码
发布控件
文档资料
经典工具
≡事务区≡
网站意见
盒子之家
招聘应聘
信息交换
论坛信息
最新加入: monica9612
今日帖子: 0
在线用户: 4
导航: 论坛 -> DELPHI技术 斑竹:liumazi,sephil  
作者:
男 emailx45 (emailx45) ▲▲▲▲△ -
普通会员
2019/12/7 10:54:57
标题:
Getting Started with Delphi and Linux Docker Support by Marco Cantu 浏览:1000
加入我的收藏
楼主: Getting Started with Delphi and Linux Docker Support
Marco Cantu
2/12/2019

Over the last few years, it has become more and more common to deploy server side solutions (and in fact any type of application) to lightweight containers rather than physical machines or virtual machines, as this allows more flexibility (also in terms of testing), a better way to rebuild the same execution environment, and more scalability. Along with the 10.3.3 release, Embarcadero has started officially supporting deployment of general Linux applications to Docker containers, specifically supporting the deployment to RAD Server.

In this blog post I’ll introduce Docker and Docker Hub and how you can easily get started deploying your Linux application to Docker. In a second blog post I’ll focus specifically on RAD Server deployment. We are also going to have a more detailed white paper on this topic available soon.

What is Docker
Docker is an OS-level virtualization environment that allows for the packaging and delivery of software as a bundle inside a container file. The container files are executed by the Docker Engine and multiple containers can run side by side on the same Linux installation. Inside each container is an OS-level virtualization environment. 

Containers are more lightweight than virtual machines because they are run by Docker Engine. Containers are created by building a set of instructions called a Dockerfile into a container image. Container images are then executed on the Docker Engine. Both the build step and run step can take a number of arguments that configures that specific build or run container image.

Additionally, existing container images can be used as starting points from within Dockerfiles which allows you to add new functionality on top of the functionality of the existing container image. There are many sources of information on containers and docker, and a good starting point is https://www.docker.com/.

What is Docker Hub?
Docker provides a service that allows developers and publishers to distribute Docker images to the public or their team. This service is known as Docker Hub and provides a way for users to use repositories where specific Docker Images are located. Docker repositories also allow for Docker Image versioning. Docker Hub contains official images such as the Ubuntu image that can be used as starting points for many users. 

RAD Studio Docker Containers
The RAD Studio Docker containers paserver, pa-radserver, and pa-radserver-ib are available directly from DockerHub and also as Dockerfiles (on GitHub) plus additional helper utilities. When pulling the containers from DockerHub using Docker the organization name has to be prefixed to the container name such as radstudio/paserver, radstudio/pa-radserver, and radstudio/pa-radserver-ib. For this blog post I’ll start focusing on the first one, radstudio/paserver, which does not include RAD Server.

Docker containers have a number of different parameters that you can pass to the Docker Engine when starting an instance. Additionally, custom build and run parameters can be defined when building and running a Docker image. A number of custom parameters have been included in the scripts we provide, including for example the password for PAServer.

Docker container instances can be run in the foreground where you can interact with an app that is running within the instance or they can be run detached in the background which behaves like a service. 

Docker container instances will not by default store any changes to the instance between runs (they are transient images). However, you can set up a persistent Volume within the Docker instance which will store changes between runs of the Docker container instance. A directory within the Docker instance can be mounted to the Volume and any changes made within that directory persist on the Volume between runs of the Docker instance.

How To Install Docker on Linux
The Docker system can be installed in a number of ways. One way to install Docker is to use the APT package manager that is included in the Ubuntu operating system. To install Docker using APT simply run the apt install command with elevated privileges either by using sudo or by using the super user account. 

----------
#if using sudo
sudo apt install docker.io 

#if using super user account
apt install docker.io
----------

The PAServer Docker image
The PAServer Docker image uses Ubuntu:Bionic as a base image and builds on it to include the PAServer tool and its functionalities. The PAServer tool is downloaded from the Embarcadero server. This image contains PAServer and all of its dependencies along with the GTK+ framework for using BroadwayD (a feature part of the FMXLinux library for building UIs on Linux, library that is freely included with the Delphi). BroadwayD can be used to display GTK+ applications on the web via HTML5 and websockets. Having these two tools available on the same Docker container allows for developers to deploy console and GUI based applications using the PAServer and view the GUI applications through a web browser via the BroadwayD server.

This image has a few parameters, including the

The PAServer password and can be set as build parameter or run parameter
Whether you want to run in foreground interactive mode (-it) or detached mode (-d)
The external PAServer port (that is the port of the host mapped to the PAServer port in the container) and the broadwayd port remapping
The default password for PAServer is set to ‘embtdocker’
This is an example of how you can download the image and start it with a few parameters:

----------
docker pull radstudio/paserver
docker run -it -e PA_SERVER_PASSWORD=securepass -p 64211:64211 -p 8082:8082 radstudio/paserver
----------

This is is a Linux console (via PuTTY) after the Docker image has been installed:

按此在新窗口浏览图片

At this point you can refer to the docker image by its host IP and the port address from the RAD Studio IDE, and deploy and run a Linux application via PAServer hosted by the docker image. Therefore the Delphi application will run under docker.

按此在新窗口浏览图片

The Dockerfile on GitHub
Instead of pulling an image from docker hub, you can create a custom one using the scripts we have built and are making available on GitHub. The PAServer Dockerfile includes the instructions which are used at build time by Docker to create the Docker image. The Dockerfile relies on a specific version of PAServer that is downloaded from Embarcadero and it is available at:

https://github.com/Embarcadero/paserver-docker

More Coming
In the next blog post, we’ll continue by focusing on RAD Server deployment via docker, which was the key reason for Embarcadero to support docker containers.
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
作者:
男 dlfsystem (dlfsystem) ★☆☆☆☆ -
盒子活跃会员
2019/12/7 12:49:19
1楼: 这个功能不错,得深入研究下。
----------------------------------------------
-
信息
登陆以后才能回复
Copyright © 2CCC.Com 盒子论坛 v3.0.1 版权所有 页面执行335.9375毫秒 RSS