|NO.Z.00390|——————————|CloudNative|——|KuberNetes&CI/CD.V28|——|Jenkins.v08|自动构建NodeJs应用.v02|

一、创建node.js应用
### --- 在gitlab上新建一个项目

~~~     Dashboard——>Group:your group——>Kubernetes-guide——>New project
~~~     ——>Project name:nodejs-demo——>Create project——>END
二、下载node.js应用
### --- 下载NodeJS应用

[root@k8s-master01 NodeJS]# git clone https://github.com/selaworkshops/npm-demo-app.git
### --- 编写dockerfile

[root@k8s-master01 NodeJS]# cat Dockerfile 
FROM registry.cn-beijing.aliyuncs.com/citools/node:4.2.3

WORKDIR /app

COPY package.json /app/
#RUN npm install
COPY . /app

EXPOSE 3000

ENTRYPOINT ["npm", "start"]
### --- 查看NodeJS项目文件

[root@k8s-master01 nodejs-demo]# ls
Dockerfile  Images  index.html  package.json  primes.js  README.md  server.js  spec
三、将NodeJS项目包推送到gitlab上
### --- 将创建好的项目克隆到本地服务器

[root@k8s-master01 NodeJS]# git clone git@gitlab.test.com:kubernetes-guide/nodejs-demo.git
### --- 推送到远程仓库

[root@k8s-master01 nodejs-demo]# git add .
[root@k8s-master01 nodejs-demo]# git commit -am "first commit for jenkins build"
[root@k8s-master01 nodejs-demo]# git push origin master
 * [new branch]      master -> master
四、gitlab上查看项目包
五、在阿里云镜像仓库新建namespace:
### --- 在阿里云镜像仓库新建namespace:

~~~     nodejs-demo-yanqi——>在nodejs-demo-yanqi下创建镜像仓库:nodejs-demo

 
 
 
 
 
 
 
 
 

Walter Savage Landor:strove with none,for none was worth my strife.Nature I loved and, next to Nature, Art:I warm'd both hands before the fire of life.It sinks, and I am ready to depart
                                                                                                                                                   ——W.S.Landor

 

 

posted on 2022-04-01 13:44  yanqi_vip  阅读(29)  评论(0)    收藏  举报

导航