把 SAP UI5 應用部署到 SAP Kyma

鏈接:https://developers.sap.com/tutorials/cp-kyma-frontend-ui5-mssql.html

本地文件:C:\Code\referenceCode\SAP Kyma教程例子\frontend-ui5-mssql

dockerfile 的內容:

# build environment
FROM node:current-slim as build
WORKDIR /app
COPY package.json ./
RUN npm install
COPY . .
RUN npm run-script build

# production environment
FROM nginx:alpine
COPY --from=build /app/dist /usr/share/nginx/html

WORKDIR /app

The WORKDIR instruction sets the working directory for any RUN, CMD, ENTRYPOINT, COPY and ADD instructions that follow it in the Dockerfile. If the WORKDIR doesn’t exist, it will be created even if it’s not used in any subsequent Dockerfile instruction.

將接下來的 RUN, CMD, ENTRYPOINT, COPY 和 ADD 指令設置工作目錄。

可以重複使用:

WORKDIR /a
WORKDIR b
WORKDIR c
RUN pwd

The output of the final pwd command in this Dockerfile would be /a/b/c.

COPY package.json ./

The COPY instruction copies new files or directories from <src> and adds them to the filesystem of the container at the path <dest>.

COPY sourcr target, 注意,target 指的是容器文件系統內的路徑。

target 可以是相對路徑或者絕對路徑。

相對路徑的例子:COPY test.txt relativeDir/

在執行時,實際上是:WORKDIR/relativeDir/

絕對路徑的例子:COPY test.txt /absoluteDir/

首先執行 npm install:

本地命令行啓動 SAP UI5:

npm run-script start

之後 localhost:8080 即可訪問:

構建 docker 鏡像:

docker build -t i042416/fe-ui5-mssql -f docker/Dockerfile .

發現在 windows 上打包有點問題:

current-slim: Pulling from library/node
no matching manifest for windows/amd64 10.0.19042 in the manifest list entries


docker desktop 裏,將容器類型切換成 linux container,重試。

切換之後就可以成功構建了:

然後將該鏡像上傳到 docker hub:

docker push i042416/fe-ui5-mssql

上傳成功:


在 SAP Kyma dev namespace 上部署一個 APIRule,其作用是,將應用暴露給 internet 訪問。

deployment 成功:


部署 configmap.yaml, 指定 SAP UI5 消費後臺服務的 url:


上傳一個 deployment,鏡像使用我之前 docker build 生成的鏡像:


部署成功:


點擊 api rule,即可得到 SAP UI5 公網訪問的 url 了:

https://fe-ui5-mssql.c-46d70f2.kyma.shoot.live.k8s-hana.ondemand.com/

更多Jerry的原創文章,盡在:"汪子熙":


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章