Cloud Foundry is an open source platform as a service (PaaS) for developers to deploy and scale applications without manually configuring and managing servers. The promise of “write once, run anywhere” means developers can build their apps on a programming language or framework of their choice, and be able to deploy it to any underlying cloud environment.

For example, developers could code a Java-based Spring Framework application, and “push” the application to a Cloud Foundry space. That space could be running in an on-premises OpenStack cloud, or a public cloud like Amazon AWS, Google Cloud Platform, IBM Bluemix or Microsoft Azure. The idea is that it hides away infrastructure details and services such as databases, so developers do not need to worry about managing the underlying environment.

The Cloud Foundry platform is available from either the Cloud Foundry Foundation as open source software, or as a commercial product or service from multiple providers. Pivotal Cloud Foundry (PCF) is a commercial offering from Pivotal, which is now part of VMware.

As an open source low code platform to visually build enterprise web apps for coders and non-coders, Joget DX is a good complement for Cloud Foundry.

Cloud Foundryเป็นแพลตฟอร์มโอเพ่นซอร์สในฐานะบริการ (PaaS) สำหรับนักพัฒนาเพื่อปรับใช้และปรับขนาดแอปพลิเคชันโดยไม่ต้องกำหนดค่าและจัดการเซิร์ฟเวอร์ด้วยตนเอง คำมั่นสัญญาของ“ เขียนครั้งเดียวทำงานได้ทุกที่” หมายถึงนักพัฒนาสามารถสร้างแอพของพวกเขาในภาษาการเขียนโปรแกรมหรือกรอบงานที่เลือกไว้และสามารถปรับใช้กับสภาพแวดล้อมคลาวด์พื้นฐานได้

ตัวอย่างเช่นนักพัฒนาสามารถเขียนรหัสแอปพลิเคชัน Spring Framework ที่ใช้ Java และ "ผลักดัน" แอปพลิเคชันไปยังพื้นที่ Cloud Foundry พื้นที่นั้นอาจทำงานในระบบ OpenStack ในสถานที่หรือระบบคลาวด์สาธารณะเช่น Amazon AWS, แพลตฟอร์ม Google Cloud, IBM Bluemix หรือ Microsoft Azure แนวคิดก็คือมันซ่อนรายละเอียดและบริการโครงสร้างพื้นฐานเช่นฐานข้อมูลไว้ดังนั้นนักพัฒนาจึงไม่จำเป็นต้องกังวลเกี่ยวกับการจัดการสภาพแวดล้อมพื้นฐาน

แพลตฟอร์ม Cloud Foundry มีให้บริการจาก Cloud Foundry Foundation เป็นซอฟต์แวร์โอเพ่นซอร์สหรือเป็นผลิตภัณฑ์เชิงพาณิชย์หรือบริการจากผู้ให้บริการหลายราย Pivotal Cloud Foundry (PCF) เป็นข้อเสนอเชิงพาณิชย์จาก Pivotal which is now part of VMware

ในฐานะที่เป็นแพลตฟอร์ม low code platform เพื่อสร้างแอปพลิเคชันเว็บสำหรับองค์กรสำหรับผู้เข้ารหัสและผู้ไม่ใช้โค้ด Joget DX เป็นส่วนประกอบที่ดีสำหรับ Cloud Foundry

Deploy Joget DX on Pivotal Cloud Foundry

ปรับใช้ Joget DX บน Pivotal Cloud Foundry

In this example, we will deploy Joget DX on PCF Dev from Pivotal. PCF Dev is a lightweight, easy to install distribution of Cloud Foundry designed to run on a developer machine, making it easier to locally develop, test and explore Cloud Foundry.

ในตัวอย่างนี้เราจะปรับใช้ Joget DX บน PCF Dev จาก Pivotal PCF Dev มีน้ำหนักเบาและง่ายต่อการติดตั้งการกระจายของ Cloud Foundry ที่ออกแบบมาเพื่อใช้กับเครื่องนักพัฒนาทำให้ง่ายต่อการพัฒนาในท้องถิ่นทดสอบและสำรวจ Cloud Foundry

 

Step 1: Install PCF Dev

ขั้นตอนที่ 1: ติดตั้ง PCF Dev

Install PCF Dev according to the instructions in the Pivotal Documentation.

Once installed, you may download the vm image from here and start PCF Dev using the command

ติดตั้ง PCF Dev ตามคำแนะนำใน Pivotal Documentation.

เมื่อติดตั้งแล้วคุณสามารถดาวน์โหลดอิมเมจ vm จาก here และเริ่ม PCF Dev โดยใช้คำสั่ง

cf dev start -f ~/pcfdev-v1.2.0-linux.tgz -s mysql

and you should see the output:

และคุณควรเห็นผลลัพธ์:

Downloading Resources...
Progress: |====================>| 100.0%
Setting State...
Creating the VM...
Starting the VM...
Fetching VM Address...
Waiting for the VM...
Deploying the BOSH Director...
Deploying PAS...
  Done (22m38s)
Deploying Apps-Manager...
  Done (3m12s)
Deploying Mysql...
  Done (2m12s)
 
         ██████╗  ██████╗███████╗██████╗ ███████╗██╗   ██╗
         ██╔══██╗██╔════╝██╔════╝██╔══██╗██╔════╝██║   ██║
         ██████╔╝██║     █████╗  ██║  ██║█████╗  ██║   ██║
         ██╔═══╝ ██║     ██╔══╝  ██║  ██║██╔══╝  ╚██╗ ██╔╝
         ██║     ╚██████╗██║     ██████╔╝███████╗ ╚████╔╝
         ╚═╝      ╚═════╝╚═╝     ╚═════╝ ╚══════╝  ╚═══╝
                     is now running!
 
        To begin using PCF Dev, please run:
            cf login -a https://api.dev.cfdev.sh --skip-ssl-validation
 
        Admin user => Email: admin / Password: admin
        Regular user => Email: user / Password: pass
 
        To access Apps Manager, navigate here: https://apps.dev.cfdev.sh
 
        To deploy a particular service, please run:
            cf dev deploy-service <service-name> [Available services: mysql,redis,rabbitmq,scs]

Follow the instructions provided at the end of to connect to PCF Dev, by logging in using the admin user and choosing the pcfdev-org organization:

ทำตามคำแนะนำที่มีให้ในตอนท้ายของการเชื่อมต่อกับ PCF Dev โดยเข้าสู่ระบบโดยใช้ผู้ใช้ผู้ดูแลระบบและเลือกองค์กร pcfdev-org:

cf login -a https://api.dev.cfdev.sh --skip-ssl-validation

You should have output like the following:

คุณควรมีเอาต์พุตดังนี้:

API endpoint: https://api.dev.cfdev.sh

Your CF API version (2.125.0) is no longer supported. Upgrade to a newer version of the API (minimum version 2.128.0). Please refer to https://github.com/cloudfoundry/cli/wiki/Versioning-Policy#cf-cli-minimum-supported-version

Email: admin

Password:
Authenticating...
OK

Select an org:
1. cfdev-org
2. system

Org (enter to skip): 1
Targeted org cfdev-org

Targeted space cfdev-space



API endpoint:   https://api.dev.cfdev.sh (API version: 3.76.0)
User:           admin
Org:            cfdev-org
Space:          cfdev-space


Step 2: Create MySQL Database Service

ขั้นตอนที่ 2: สร้างบริการฐานข้อมูล MySQL

In Cloud Foundry, all external dependencies such as databases, file systems and so on are considered services. Cloud Foundry allows administrators to provide a marketplace of services, from which users can provision reserved resources on-demand.

Here, we will create a MySQL Database Service.

In the command line, search the marketplace for MySQL plans available.

ใน Cloud Foundry การอ้างอิงภายนอกทั้งหมดเช่นฐานข้อมูลระบบไฟล์และอื่น ๆ ถือเป็นบริการ Cloud Foundry อนุญาตให้ผู้ดูแลระบบจัดหาตลาดบริการซึ่งผู้ใช้สามารถจัดหาทรัพยากรที่สงวนไว้ตามความต้องการ

ที่นี่เราจะสร้างบริการฐานข้อมูล MySQL

ในบรรทัดคำสั่งค้นหาตลาดสำหรับแผน MySQL ที่มีให้

cf marketplace -s p.mysql

Create a service instance with the db-small plan with the name jogetdb:

สร้างอินสแตนซ์ของบริการด้วยแผน db-small ด้วยชื่อ jogetdb:

cf create-service p.mysql db-small jogetdb

More detailed information can be found at https://tanzu.vmware.com/tutorials/getting-started/connect-a-database 

ข้อมูลรายละเอียดเพิ่มเติมสามารถดูได้ที่ https://tanzu.vmware.com/tutorials/getting-started/connect-a-database

 

Step 3: Create Local Volume Service

ขั้นตอนที่ 3: สร้าง Local Volume Service

In Cloud Foundry, a volume service provides a reliable, persistent file system. However in the latest CF Dev, it doesn't come with any volume service. Nevertheless, we should have that in production environment so Joget DX can read or write to it.

For example, create a service instance using the PCF Local Volume Service with the name jogetdata:

ใน Cloud Foundry บริการไดรฟ์ข้อมูลมีระบบไฟล์ที่เชื่อถือได้และคงอยู่ อย่างไรก็ตามใน CF Dev ล่าสุดมันไม่ได้มาพร้อมกับบริการระดับเสียงใด ๆ อย่างไรก็ตามเราควรมีในสภาพแวดล้อมการผลิตเพื่อให้ Joget DX สามารถอ่านหรือเขียนได้

ตัวอย่างเช่นสร้างอินสแตนซ์ของบริการโดยใช้ PCF Local Volume Service ด้วยชื่อ jogetdata:

cf create-service local-volume free-local-disk jogetdata

More detailed information can be found at https://docs.cloudfoundry.org/devguide/services/using-vol-services.html and  https://github.com/cloudfoundry/local-volume-release

ข้อมูลรายละเอียดเพิ่มเติมสามารถดูได้ที่ https://docs.cloudfoundry.org/devguide/services/using-vol-services.html และ https://github.com/cloudfoundry/local-volume-release

 

Step 4: Download and Deploy Joget DX WAR

ขั้นตอนที่ 4: ดาวน์โหลดและปรับใช้ Joget DX WAR

Download Joget DX from https://www.joget.org/download/ 

Install Joget DX https://dev.joget.org/community/display/DX7/Installation+Guide 

Look for the Joget DX WAR file jw.war in joget_installation_directory/apache-tomcat/webapps.

Push the WAR to the Cloud Foundry space with a memory allocation of 1G and application name joget:

ดาวน์โหลด Joget DX จาก https://www.joget.org/download/

ติดตั้ง Joget DX https://dev.joget.org/community/display/DX7/Installation+Guide

ค้นหาไฟล์ Joget DX WAR jw.war ใน joget_installation_directory / apache-tomcat / webapps

พุช WAR ไปยังพื้นที่ Cloud Foundry ด้วยการจัดสรรหน่วยความจำ 1G และชื่อแอปพลิเคชัน joget:

cf push joget -p joget-enterprise-linux-7.0.0/apache-tomcat-8.5.41/webapps/jw.war -m 1G --no-start -b https://github.com/cloudfoundry/java-buildpack.git

Note that we use the --no-start parameter to delay the start of the application, because we need to set a couple of environment variables before starting up.

โปรดทราบว่าเราใช้พารามิเตอร์ --no-start เพื่อชะลอการเริ่มต้นแอปพลิเคชันเนื่องจากเราจำเป็นต้องตั้งค่าตัวแปรสภาพแวดล้อมสองสามก่อนเริ่มต้น

 

Step 5: Configure and Start Joget DX

ขั้นตอนที่ 5: กำหนดค่าและเริ่ม Joget DX

Set the Apache Tomcat version to 8.5 and context path to /jw:

ถัดไปปิดการกำหนดค่าสปริงอัตโนมัติใหม่ นี่เป็นเพราะ Joget DX WAR ดำเนินการเริ่มต้นที่จำเป็นแล้วเมื่อเริ่มต้นและการกำหนดค่าอัตโนมัติจะรบกวน:

cf set-env joget JBP_CONFIG_TOMCAT '[tomcat: { version: 8.5.+, context_path: "/jw" }]'

Next, disable the Spring auto reconfiguration. This is because the Joget DX WAR already performs the necessary initialization at startup, and the auto configuration will interfere with it:

ถัดไปปิดการกำหนดค่าสปริงอัตโนมัติใหม่ นี่เป็นเพราะ Joget DX WAR ดำเนินการเริ่มต้นที่จำเป็นแล้วเมื่อเริ่มต้นและการกำหนดค่าอัตโนมัติจะรบกวน:

cf set-env joget JBP_CONFIG_SPRING_AUTO_RECONFIGURATION '[enabled: false]'

Bind the volume service to mount the persistent filesystem to the Joget DX data directory:

ผูกเซอร์วิสวอลุ่มเพื่อต่อเชื่อมระบบไฟล์ถาวรกับไดเร็กทอรีข้อมูล Joget DX:

cf bind-service joget jogetdata -c '{"mount":"/home/vcap/wflow"}'

Bind the MySQL database service:

ผูกบริการฐานข้อมูล MySQL:

cf bind-service joget jogetdb

Verify that the services are bound to the Joget application:

ตรวจสอบว่าบริการถูกผูกไว้กับแอปพลิเคชัน Joget:

cf services

For example the output shows the services bound to the joget application:

ตัวอย่างเช่นผลลัพธ์แสดงบริการที่ผูกกับแอ็พพลิเคชัน joget:

name      service   plan       bound apps   last operation     broker                   upgrade available
jogetdb   p.mysql   db-small   joget        create succeeded   dedicated-mysql-broker

Start the Joget application:

เริ่มแอปพลิเคชัน Joget:

cf start joget

 

Step 6: Setup Joget Database

ขั้นตอนที่ 6: ตั้งค่าฐานข้อมูล Joget

Now that the Joget platform has been deployed in Cloud Foundry, the final step is to setup the database schema, based on https://docs.cloudfoundry.org/devguide/services/migrate-db.html#single-migration.

At this point, we can obtain the MySQL database service credentials by viewing the environment variables:

ตอนนี้แพลตฟอร์ม Joget ได้รับการปรับใช้ใน Cloud Foundry ขั้นตอนสุดท้ายคือการตั้งค่าสคีมาฐานข้อมูลตาม https://docs.cloudfoundry.org/devguide/services/migrate-db.html#single-migration

ณ จุดนี้เราสามารถรับข้อมูลรับรองบริการฐานข้อมูล MySQL ได้โดยการดูตัวแปรสภาพแวดล้อม:

cf env joget

In particular, note down the p-mysql service hostname, port, name, username and password.

โดยเฉพาะจดชื่อโฮสต์บริการพอร์ต p-mysql ชื่อผู้ใช้และรหัสผ่าน

Getting env variables for app joget in org cfdev-org / space cfdev-space as admin...
OK

System-Provided:
{
 "VCAP_SERVICES": {
  "p.mysql": [
   {
    "binding_name": null,
    "credentials": {
     "hostname": "q-n1s3y1.q-g173.bosh",
     "jdbcUrl": "jdbc:mysql://q-n1s3y1.q-g173.bosh:3306/service_instance_db?user=e35c7904b0c8402096ef491aa0a17151\u0026password=xgd4xt398r8hkct6\u0026useSSL=false",
     "name": "service_instance_db",
     "password": "xgd4xt398r8hkct6",
     "port": 3306,
     "uri": "mysql://e35c7904b0c8402096ef491aa0a17151:xgd4xt398r8hkct6@q-n1s3y1.q-g173.bosh:3306/service_instance_db?reconnect=true",
     "username": "e35c7904b0c8402096ef491aa0a17151"
    },
    "instance_name": "jogetdb",
    "label": "p.mysql",
    "name": "jogetdb",
    "plan": "db-small",
    "provider": null,
    "syslog_drain_url": null,
    "tags": [
     "mysql"
    ],
    "volume_mounts": []
   }
  ]
 }
}

{
 "VCAP_APPLICATION": {
  "application_id": "f80eeb36-b149-4aed-a3dc-a0cca32c0e1f",
  "application_name": "joget",
  "application_uris": [
   "joget.dev.cfdev.sh"
  ],
  "application_version": "92375e68-74b1-41f6-9d11-5f196629fb4a",
  "cf_api": "https://api.dev.cfdev.sh",
  "limits": {
   "disk": 1024,
   "fds": 16384,
   "mem": 1024
  },
  "name": "joget",
  "space_id": "45d5b30a-6bb1-4ccb-99f1-e45912c40ef1",
  "space_name": "cfdev-space",
  "uris": [
   "joget.dev.cfdev.sh"
  ],
  "users": null,
  "version": "92375e68-74b1-41f6-9d11-5f196629fb4a"
 }
}

User-Provided:
JBP_CONFIG_SPRING_AUTO_RECONFIGURATION: [enabled: false]
JBP_CONFIG_TOMCAT: [tomcat: { version: 8.5.+, context_path: "/jw" }]


Access Joget DX at
http://joget.dev.cfdev.sh/jw/ and you will be presented with the database setup page.

Proceed to setup the database according to the instructions at https://dev.joget.org/community/display/DX7/Setting+Up+Database

เข้าถึง Joget DX ที่ http://joget.dev.cfdev.sh/jw/ และคุณจะพบหน้าการตั้งค่าฐานข้อมูล

ดำเนินการตั้งค่าฐานข้อมูลตามคำแนะนำที่ https://dev.joget.org/community/display/DX7/Setting+Up+Database

Once setup is complete, you will be brought to the Joget DX App Center.

เมื่อการติดตั้งเสร็จสมบูรณ์คุณจะถูกนำไปที่ Joget DX App Center.


 

Appendix A: Application Manifest File

ภาคผนวก A: ไฟล์ Manifest ของแอปพลิเคชัน

Optionally, an application manifest file can be used to specify environment variables and bind services.

manifest.yml:

เป็นทางเลือกไฟล์รายการแอปพลิเคชันสามารถใช้เพื่อระบุตัวแปรสภาพแวดล้อมและบริการผูก

manifest.yml:

---
applications:
- name: joget
 memory: 1G
 buildpack: https://github.com/cloudfoundry/java-buildpack.git
 path: /path_to/jw.war
 services:
   - jogetdb
   - jogetdata
 env:
   JBP_CONFIG_SPRING_AUTO_RECONFIGURATION: '[enabled: false]'
   JBP_CONFIG_TOMCAT: '{tomcat: {context_path: "/jw"}}'

However, there is a limitation that the current version of Cloud Foundry does not support  specifying parameters when binding parameters, so binding of the local volume service to the Joget data directory has to be done manually:

อย่างไรก็ตามมีข้อ จำกัด ที่เวอร์ชันปัจจุบันของ Cloud Foundry does not support  specifying parameters when binding parameters ดังนั้นการรวมบริการโลคัลวอลุ่มเข้ากับไดเร็กทอรีข้อมูล Joget จะต้องดำเนินการด้วยตนเอง:

cf bind-service joget jogetdata -c '{"mount":"/home/vcap/wflow"}'
cf restage joget

 

Appendix B: Useful Cloud Foundry Commands

ภาคผนวก B: คำสั่ง Cloud Foundry ที่มีประโยชน์

View application logs:

ดูบันทึกแอปพลิเคชัน:

cf logs joget


Restage the application after modifying service bindings or environment variables:

เรียกคืนแอปพลิเคชันหลังจากแก้ไขการผูกบริการหรือตัวแปรสภาพแวดล้อม:

cf restage joget


Stop PCF Dev VM:

หยุด PCF Dev VM:

cf dev stop


Delete the PCF Dev VM:

ลบ PCF Dev VM:

cf dev destroy


Uninstall the PCF Dev Plugin:

ถอนการติดตั้ง PCF Dev Plugin:

cf uninstall-plugin pcfdev

 

View PCF Dev App Manager:

ดู PCF Dev App Manager:

https://apps.dev.cfdev.sh