Google Cloud Platform is Google's cloud computing and hosting platform. The Compute Engine is a part of the Google Cloud Platform that runs virtual machines (VM) on Google's high performance, scalable infrastructure. 

As an open source platform to easily build enterprise web apps for cloud and mobile, Joget is a good complement for the Google Cloud Platform. 

Google Cloud Platform เป็นคลาวด์คอมพิวติ้งและแพลตฟอร์มการโฮสต์ Compute Engine เป็นส่วนหนึ่งของแพลตฟอร์ม Google Cloud ที่ใช้งานเครื่องเสมือน (VM) บนโครงสร้างพื้นฐานที่ปรับขนาดได้และประสิทธิภาพสูงของ Google

ในฐานะที่เป็นแพลตฟอร์มโอเพ่นซอร์สเพื่อสร้างเว็บแอปองค์กรสำหรับคลาวด์และอุปกรณ์พกพาได้ง่าย Joget เป็นส่วนประกอบที่ดีสำหรับแพลตฟอร์ม Google Cloud


  

This article describes the steps required to deploy Joget on a Linux VM using the Compute Engine. You can also use other OS platforms (e.g. Windows, macOS, etc) by adapting the commands accordingly.

บทความนี้อธิบายขั้นตอนที่จำเป็นในการปรับใช้ Joget บน Linux VM โดยใช้ Compute Engine คุณสามารถใช้แพลตฟอร์มระบบปฏิบัติการอื่น ๆ (เช่น Windows, macOS และอื่น ๆ ) โดยปรับคำสั่งให้สอดคล้อง

Google Cloud Platform now has an always-free tier that allows you to host servers without cost.
However, do note that the free tier is limited, and it is recommended to choose an appropriate machine type for your requirements.

ขณะนี้แพลตฟอร์ม Google Cloud มี always-free tier ให้คุณสามารถโฮสต์เซิร์ฟเวอร์โดยไม่มีค่าใช้จ่าย
อย่างไรก็ตามโปรดทราบว่าระดับว่างฟรีมี จำกัด และขอแนะนำให้เลือก machine type ที่เหมาะสมกับความต้องการของคุณ


Step 1: Signup for Google Cloud Platform

ขั้นตอนที่ 1: สมัครใช้งานแพลตฟอร์ม Google Cloud


Signup for the Google Cloud Platform at https://console.cloud.google.com/freetrial

ลงทะเบียนสำหรับแพลตฟอร์ม Google Cloud ที่ https://console.cloud.google.com/freetrial


Step 2: Install the Cloud SDK

ขั้นตอนที่ 2: ติดตั้ง Cloud SDK


Install the Cloud SDK on your PC following the instructions in https://cloud.google.com/sdk/docs/quickstarts

ติดตั้ง Cloud SDK บนพีซีของคุณทำตามคำแนะนำใน https://cloud.google.com/sdk/docs/quickstarts

In the Quickstart, you must complete the section "Before you begin" and "Initialize the SDK". After which, you may see the following messages.

ใน Quickstart คุณต้องทำตามหัวข้อ "ก่อนเริ่มต้น" และ "เตรียมใช้งาน SDK" หลังจากนั้นคุณอาจเห็นข้อความต่อไปนี้

Not setting default zone/region (this feature makes it easier to use [gcloud compute] by setting an appropriate default value for the --zone and --region flag).

See https://cloud.google.com/compute/docs/gcloud-compute section on how to set default compute region and zone manually. If you would like [gcloud init] to be able to do this for you the next time you run it, make sure the Compute Engine API is enabled for your project on the https://console.developers.google.com/apis page.

You must also enable "Google Compute Engine API" at https://console.developers.google.com/apis for the project (created automatically for you if you have none) in order to continue with the next step.

คุณต้องเปิดใช้งาน "Google Compute Engine API" ที่ https://console.developers.google.com/apis สำหรับโครงการ (สร้างขึ้นโดยอัตโนมัติสำหรับคุณหากคุณไม่มี) เพื่อดำเนินการต่อในขั้นตอนถัดไป


Step 3: Create a new Linux VM

ขั้นตอนที่ 3: สร้าง Linux VM ใหม่


Once the Cloud SDK is installed and verified to be working, create a new Linux VM using the following commands:

เมื่อติดตั้งและตรวจสอบ Cloud SDK ของ Cloud แล้วให้สร้าง Linux VM ใหม่โดยใช้คำสั่งต่อไปนี้:

export INSTANCE_NAME=joget7
export IMAGE_ID=ubuntu-1804-bionic-v20200129a
export IMAGE_PROJECT=gce-uefi-images
export MACHINE_TYPE=n1-standard-1
export JOGET_VERSION=7.0.0
export MYSQL_VERSION=5.7
export MYSQL_PASSWORD=root

echo "== Create VM instance $INSTANCE_NAME for $IMAGE_ID on $MACHINE_TYPE =="
gcloud compute instances create $INSTANCE_NAME --image $IMAGE_ID --image-project $IMAGE_PROJECT --machine-type=$MACHINE_TYPE
set INSTANCE_NAME=joget7
set IMAGE_ID=ubuntu-1804-bionic-v20200129a
set IMAGE_PROJECT=gce-uefi-images
set MACHINE_TYPE=n1-standard-1
set JOGET_VERSION=7.0.0
set MYSQL_VERSION=5.7
set MYSQL_PASSWORD=root
 
echo "== Create VM instance %INSTANCE_NAME% for %IMAGE_ID% on %MACHINE_TYPE% =="
gcloud compute instances create %INSTANCE_NAME% --image %IMAGE_ID% --image-project %IMAGE_PROJECT% --machine-type=%MACHINE_TYPE%


If you are using a low-memory machine type (e.g. f1-micro), then you will need to add swap space:

หากคุณใช้ประเภทเครื่องหน่วยความจำต่ำ (เช่น f1-micro) คุณจะต้องเพิ่มพื้นที่สว็อป:

echo "== Add swap file (required for low memory machine types eg f1-micro) =="
gcloud compute ssh $INSTANCE_NAME -- "\
sudo fallocate -l 1G /swapfile;\
sudo chmod 600 /swapfile;\
sudo mkswap /swapfile;\
sudo swapon /swapfile;\
sudo swapon -s"
echo "== Add swap file (required for low memory machine types eg f1-micro) =="
gcloud compute ssh %INSTANCE_NAME% --command="sudo fallocate -l 1G /swapfile; sudo chmod 600 /swapfile; sudo mkswap /swapfile; sudo swapon /swapfile; sudo swapon -s;"


Step 4: Deploy Joget in the VM

ขั้นตอนที่ 4: ปรับใช้ Joget ใน VM


Run the following commands to download and install Joget Enterprise Edition:

รันคำสั่งต่อไปนี้เพื่อดาวน์โหลดและติดตั้ง Joget Enterprise Edition:

echo "== Deploy Joget =="
gcloud compute ssh $INSTANCE_NAME -- "\
    echo === Install Java ===;\
    sudo apt-get update;\
    sudo apt-get install -y openjdk-8-jdk-headless;\
    echo === Install MySQL ===;\
    sudo debconf-set-selections <<< \"mysql-server-$MYSQL_VERSION mysql-server/root_password password $MYSQL_PASSWORD\";\
    sudo debconf-set-selections <<< \"mysql-server-$MYSQL_VERSION mysql-server/root_password_again password $MYSQL_PASSWORD\";\
    sudo apt-get -y install mysql-server-$MYSQL_VERSION;\
    sudo -E apt-get -q -y install mysql-server;\
    echo === Download Joget $JOGET_VERSION ===;\
    cd ~;\
    wget https://dev.joget.org/downloads/enterprise/joget-enterprise-linux-$JOGET_VERSION.tar.gz;\
    echo === Extract Bundle ===;\
    tar xvfz joget-enterprise-linux-$JOGET_VERSION.tar.gz;\
    cd joget-enterprise-linux-$JOGET_VERSION;\
    echo === Setup Datasource ===;\
    apache-ant-1.7.1/bin/ant setup -Dprofile.name=default -Ddb.name=jwdb -Ddb.host=localhost -Ddb.port=3306 -Ddb.user=root -Ddb.password=$MYSQL_PASSWORD;\
    echo === Reduce JAVA VM Memory Allocation ===;\ 
    sed -i -e 's/768/256/g' tomcat8.sh;\
    echo === Clean Bundle ===;\
    cd ..;\
    rm -r joget-enterprise-linux-$JOGET_VERSION.tar.gz;\
    echo === Start Joget $JOGET_VERSION ===;\
    cd joget-enterprise-linux-$JOGET_VERSION;\
    ./tomcat8.sh start"
echo "== Deploy Joget =="
gcloud compute ssh %INSTANCE_NAME% --command="echo === Install Java ===;sudo apt-get install -y openjdk-8-jdk-headless;    echo === Install MySQL ===;    sudo debconf-set-selections ^<^<^< \"mysql-server-%MYSQL_VERSION% mysql-server/root_password password %MYSQL_PASSWORD%\";    sudo debconf-set-selections ^<^<^< \"mysql-server-%MYSQL_VERSION% mysql-server/root_password_again password %MYSQL_PASSWORD%\";    sudo apt-get -y install mysql-server-%MYSQL_VERSION%;    sudo -E apt-get -q -y install mysql-server;    echo === Download Joget %JOGET_VERSION% ===;    cd ~;    wget https://dev.joget.org/downloads/enterprise/joget-enterprise-linux-%JOGET_VERSION%.tar.gz;    echo === Extract Bundle ===;    tar xvfz joget-enterprise-linux-%JOGET_VERSION%.tar.gz;    cd joget-enterprise-linux-%JOGET_VERSION%;    echo === Setup Datasource ===;    apache-ant-1.7.1/bin/ant setup -Dprofile.name=default -Ddb.name=jwdb -Ddb.host=localhost -Ddb.port=3306 -Ddb.user=root -Ddb.password=%MYSQL_PASSWORD%;    echo === Reduce JAVA VM Memory Allocation ===;    sed -i -e 's/768/256/g' tomcat8.sh;    echo === Clean Bundle ===;    cd ..;    rm -r joget-enterprise-linux-%JOGET_VERSION%.tar.gz;    echo === Start Joget %JOGET_VERSION% ===;    cd joget-enterprise-linux-%JOGET_VERSION%;    ./tomcat8.sh start"


Deployment may take several minutes (depending on the type of VM) so be patient.

Monitor the logs using:

การปรับใช้อาจใช้เวลาหลายนาที (ขึ้นอยู่กับประเภทของ VM) ดังนั้นโปรดอดทนรอ

ตรวจสอบบันทึกโดยใช้:

echo "== Tail Logs =="
gcloud compute ssh $INSTANCE_NAME -- "tail -f ~/joget-enterprise-linux-*/apache-tomcat-*/logs/catalina.out"
echo "== Tail Logs =="
gcloud compute ssh %INSTANCE_NAME% --command="tail -f ~/joget-enterprise-linux-*/apache-tomcat-*/logs/catalina.out"


The deployment is complete once you see the following in the logs:

การปรับใช้เสร็จสมบูรณ์เมื่อคุณเห็นสิ่งต่อไปนี้ในบันทึก:

12-Mar-2020 07:24:02.199 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in XXXXX ms 

Press CTRL-C to stop viewing the logs.

กด CTRL-C เพื่อหยุดดูบันทึก

Step 5: Add Firewall Rule for Default Apache Tomcat Port 8080

ขั้นตอนที่ 5: เพิ่มกฎไฟร์วอลล์สำหรับ Apache Tomcat Port 8080 ที่เป็นค่าเริ่มต้น


The default installation bundle runs on Apache Tomcat port 8080. Add a firewall rule to allow traffic to access the default Apache Tomcat port 8080:

บันเดิลการติดตั้งเริ่มต้นรันบนพอร์ต Apache Tomcat 8080 เพิ่มกฎไฟร์วอลล์เพื่ออนุญาตการรับส่งข้อมูลเพื่อเข้าถึงพอร์ต Apache Tomcat ดีฟอลต์ 8080:

echo "== Add firewall rule for port 8080 =="
gcloud compute firewall-rules create tomcat-8080 --description "Incoming http 8080 allowed." --allow tcp:8080 --format json 

More information available at https://cloud.google.com/compute/docs/networking#addingafirewall

ข้อมูลเพิ่มเติมสามารถดูได้ที่ https://cloud.google.com/compute/docs/networking#addingafirewall


Step 6: Access Joget installation

ขั้นตอนที่ 6: การติดตั้งการเข้าถึง Joget


Check the external IP of the VM instance by running the command:

ตรวจสอบ IP ภายนอกของอินสแตนซ์ VM โดยเรียกใช้คำสั่ง:

echo "== Display instance and external IP =="
gcloud compute instances list 


Browse to your Joget installation at http://VM_EXTERNAL_IP:8080/jw, and get started with Apps and the App Center.

เรียกดูการติดตั้ง Joget ของคุณที่ http: // VM_EXTERNAL_IP: 8080 / jw และเริ่มต้นใช้งานแอพและ App Center