# Lab 1: First Microservice 本範例使用IBM開源程式碼將佈署於OpenShift Container Platform * 登入方法: https://hackmd.io/@mGh414xAR8-m-StRhI7Gww/ry8tnH9rP * 常見問題: https://hackmd.io/@j_cw20OeTZ-9cHj3CCAW6Q/HkvO7c8uP 1. PHP 前端應用程式: https://github.com/IBM/php-s2i-openshift 2. Java 後端患者資料應用程式: https://github.com/IBM/example-health-jee-openshift 3. MySQL 資料庫: 已預先於OpenShift建立,透過Cluster IP連線即可 --- ### 前置作業 - 帳號 - Github - 命令列工具 - git - mvn --- ### Step * 建立前端患者資料顯示頁面 Lab1-1 建立 PHP 前端應用程式 (2分) * 建立後端患者資料應用程式 Lab1-2 編譯 Java 應用程式 (1分) Lab1-3 上傳已編譯應用程式 (1分) Lab1-4 建立 Secret (1分) Lab1-5 在 OpenShift Web UI 建立 Java 應用程式 (2分) Lab1-6 前端應用程式與 Java API 整合 (1分) --- ### 建立前端患者資料顯示頁面 #### Lab1-1 建立 PHP 前端應用程式 (2分) * 透過Web UI建立PHP前端應用程式 Developer +Add From Catelog: PHP    * Builder Image Version: 7.2  * Git Repo URL: https://github.com/IBM/php-s2i-openshift Show Advanced Git Options Context Dir: src  * Name: php  * 產生公開路由  * 啟動成功  * 測試是否成功 (此時尚未建立JAVA後端患者資料應用程式故以PHP前端應用程式內的測試資料顯示)   ### 建立後端患者資料應用程式 #### Lab1-2 編譯 Java 應用程式 (1分) * git fork https://github.com/IBM/example-health-jee-openshift  * 複製到local端 ``` C:\Users\YOURUSER\Desktop\NCCU> git clone https://github.com/你的Github帳號/example-health-jee-openshift ``` * 切換到專案位置example-health-jee-opshift/example-health-api ``` C:\Users\YOURUSER\Desktop\NCCU> cd example-health-jee-openshift/example-health-api ``` * 編譯並打包java ``` C:\Users\YOURUSER\Desktop\NCCU\example-health-jee-openshift\example-health-api> mvn clean package ``` #### Lab1-3 上傳已編譯應用程式 (1分) * 把打包出來的war檔上傳到 https://github.com/你的Github帳號/example-health-jee-opshift/example-health-api/liberty    * 修改Dockerfile  * 修改target  * 改為liberty  * Commit Change  #### Lab1-4 建立 Secret (1分) * 建立資料庫帳密Secret  * Secret Name: db-secrets Key: env_mysql_url Value: jdbc:mysql://172.21.116.116:3306/sampledb * Key: env_mysql_user Value: admin * Key: env_mysql_pwd Value: admin    #### Lab1-5 在 OpenShift Web UI 建立 Java 應用程式 (2分) * 透過Web UI建立Java應用程式 Developer +Add From Dockerfile  * Git Repo URL: https://github.com/YOURGITACCOUNT/example-health-jee-openshift Show Advanced Git Options Context Dir: example-health-api  * Container Port: 9080  * Name: java-api  * 產生公開路由  * 把Secret注入到Deployment   * 啟動成功  * 測試Java API是否啟動成功 Java API 的URL/openapi/ui/   * 測試Java API是否連結MySQL成功 Java API 的URL/resources/v1/getInfo/patients    #### Lab1-6 前端應用程式與 Java API 整合 (1分) * 設定 Java API url Key: apiBaseUrl Value: Java API 的URL   * 存檔並重新建立  * 測試前端應用程式是否能從Java API取得資料 
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up