From 0debdb7c1d524b2d887ed60220d2b15fe5939d95 Mon Sep 17 00:00:00 2001 From: "gao.zhiyuan" Date: Mon, 20 Jun 2022 10:24:49 +0800 Subject: [PATCH] =?UTF-8?q?docker=20=E6=96=87=E4=BB=B6=20=EF=BC=8C?= =?UTF-8?q?=E9=83=A8=E5=88=86=E6=92=AD=E6=94=BE=E5=99=A8=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- code/VideoAccess-VCMP/api/.vscode/launch.json | 88 +++++++++---------- code/VideoAccess-VCMP/api/Dockerfile | 22 +++-- .../api/app/lib/service/mqttVideoServer.js | 27 +++--- code/VideoAccess-VCMP/api/jenkinsfile | 19 ++++ code/VideoAccess-VCMP/web/Dockerfile | 20 ++++- .../components/videoPlayer/videoOperation.jsx | 2 +- .../src/components/videoPlayer/videoPlay.jsx | 5 +- .../equipmentWarehouse/containers/camera.jsx | 2 +- code/VideoAccess-VCMP/web/jenkinsfile | 19 ++++ 9 files changed, 134 insertions(+), 70 deletions(-) create mode 100644 code/VideoAccess-VCMP/api/jenkinsfile create mode 100644 code/VideoAccess-VCMP/web/jenkinsfile diff --git a/code/VideoAccess-VCMP/api/.vscode/launch.json b/code/VideoAccess-VCMP/api/.vscode/launch.json index d4341c7..bb4caed 100644 --- a/code/VideoAccess-VCMP/api/.vscode/launch.json +++ b/code/VideoAccess-VCMP/api/.vscode/launch.json @@ -1,46 +1,46 @@ { - // 使用 IntelliSense 了解相关属性。 - // 悬停以查看现有属性的描述。 - // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "type": "node", - "request": "launch", - "name": "启动API", - "program": "${workspaceRoot}/server.js", - "env": { - "NODE_ENV": "development" - }, - "args": [ - "-p 4000", - "-f http://localhost:4000", - "-g postgres://postgres:123@10.8.30.32:5432/video_access", - "--redisHost 127.0.0.1", - "--redisPort 6379", - "--axyApiUrl http://127.0.0.1:4100", - "--iotAuthApi http://127.0.0.1:4200", - "--iotVideoServerUrl http://221.230.55.27:8081", - "--godUrl https://restapi.amap.com/v3", - "--godKey 21c2d970e1646bb9a795900dd00093ce", - "--mqttVideoServer mqtt://127.0.0.1" - ] - }, - { - "type": "node", - "request": "launch", - "name": "run mocha", - "program": "${workspaceRoot}/node_modules/mocha/bin/_mocha", - "stopOnEntry": false, - "args": [ - "app/test/*.test.js", - "--no-timeouts" - ], - "cwd": "${workspaceRoot}", - "runtimeExecutable": null, - "env": { - "NODE_ENV": "development" - } - } - ] + // 使用 IntelliSense 了解相关属性。 + // 悬停以查看现有属性的描述。 + // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "node", + "request": "launch", + "name": "启动API", + "program": "${workspaceRoot}/server.js", + "env": { + "NODE_ENV": "development" + }, + "args": [ + "-p 4000", + "-f http://localhost:4000", + "-g postgres://postgres:123@10.8.30.32:5432/video_access", + "--redisHost 127.0.0.1", + "--redisPort 6379", + "--axyApiUrl http://127.0.0.1:4100", + "--iotAuthApi http://127.0.0.1:4200", + "--iotVideoServerUrl http://221.230.55.27:8081", + "--godUrl https://restapi.amap.com/v3", + "--godKey 21c2d970e1646bb9a795900dd00093ce", + "--mqttVideoServer tcp://tee2b1be.cn.emqx.cloud:12847" + ] + }, + { + "type": "node", + "request": "launch", + "name": "run mocha", + "program": "${workspaceRoot}/node_modules/mocha/bin/_mocha", + "stopOnEntry": false, + "args": [ + "app/test/*.test.js", + "--no-timeouts" + ], + "cwd": "${workspaceRoot}", + "runtimeExecutable": null, + "env": { + "NODE_ENV": "development" + } + } + ] } \ No newline at end of file diff --git a/code/VideoAccess-VCMP/api/Dockerfile b/code/VideoAccess-VCMP/api/Dockerfile index 316b93f..9e6abdd 100644 --- a/code/VideoAccess-VCMP/api/Dockerfile +++ b/code/VideoAccess-VCMP/api/Dockerfile @@ -1,7 +1,4 @@ - -FROM repository.anxinyun.cn/base-images/nodejs12:20.10.12.2 - -MAINTAINER liuxinyi "liu.xinyi@free-sun.com.cn" +FROM repository.anxinyun.cn/devops/node:12-dev as builder COPY . /var/app @@ -9,6 +6,19 @@ WORKDIR /var/app EXPOSE 8080 -CMD ["-g", "postgres://FashionAdmin:123456@iota-m1:5433/SmartRiver", "--qnak", "5XrM4wEB9YU6RQwT64sPzzE6cYFKZgssdP5Kj3uu", "--qnsk", "w6j2ixR_i-aelc6I7S3HotKIX-ukMzcKmDfH6-M5", "--qnbkt", "anxinyun-test", "--qndmn", "http://test.resources.anxinyun.cn"] +RUN npm config set registry=http://10.8.30.22:7000 +RUN echo "{\"time\":\"$BUILD_TIMESTAMP\",\"build\": \"$BUILD_NUMBER\",\"revision\": \"$SVN_REVISION_1\",\"URL\":\"$SVN_URL_1\"}" > version.json +RUN npm cache clean -f +RUN npm install --registry http://10.8.30.22:7000 +RUN npm run build +RUN rm -rf client/src +RUN rm -rf node_modules +RUN npm install --production --registry http://10.8.30.22:7000 + +FROM repository.anxinyun.cn/devops/node:12-dev + +WORKDIR /app + +COPY --from=builder /var/app . -ENTRYPOINT [ "node", "server.js" ] +CMD ["node", "server.js"] \ No newline at end of file diff --git a/code/VideoAccess-VCMP/api/app/lib/service/mqttVideoServer.js b/code/VideoAccess-VCMP/api/app/lib/service/mqttVideoServer.js index 6f72bc3..6e468e8 100644 --- a/code/VideoAccess-VCMP/api/app/lib/service/mqttVideoServer.js +++ b/code/VideoAccess-VCMP/api/app/lib/service/mqttVideoServer.js @@ -2,21 +2,22 @@ const mqtt = require('mqtt'); module.exports = async function factory (app, opts) { - // const client = mqtt.connect(opts.mqtt.mqttVideoServer); + console.info(`mqtt connecting ${opts.mqtt.mqttVideoServer}`); - // client.on('connect', function () { - // console.info(`mqtt connect success ${opts.mqtt.mqttVideoServer}`); - // }) - // client.on('error', function (e) { - // console.error(`mqtt connect failed ${opts.mqtt.mqttVideoServer}`); - // app.fs.logger.error('info', '[FS-AUTH-MQTT]', `mqtt connect failed ${opts.mqtt.mqttVideoServer}`); - // }) + const client = mqtt.connect(opts.mqtt.mqttVideoServer); - // client.subscribe('test', { qos: 2 });//订阅主题为test的消息 + client.on('connect', function () { + console.info(`mqtt connect success ${opts.mqtt.mqttVideoServer}`); + client.subscribe('test', { qos: 2 });//订阅主题为test的消息 + }) + client.on('error', function (e) { + console.error(`mqtt connect failed ${opts.mqtt.mqttVideoServer}`); + app.fs.logger.error('info', '[FS-AUTH-MQTT]', `mqtt connect failed ${opts.mqtt.mqttVideoServer}`); + }) - // client.on('message', function (top, message) { - // console.log(message.toString()); - // }); + client.on('message', function (top, message) { + console.log(message.toString()); + }); - // app.mqttVideoServer = client + app.mqttVideoServer = client } diff --git a/code/VideoAccess-VCMP/api/jenkinsfile b/code/VideoAccess-VCMP/api/jenkinsfile new file mode 100644 index 0000000..c246721 --- /dev/null +++ b/code/VideoAccess-VCMP/api/jenkinsfile @@ -0,0 +1,19 @@ +pipeline { + agent { + node{ + label 'jnlp-slave' + } + } + + stages { + stage('Testing vcmp ......') { + steps { + sh 'switch-auth.sh vcmp' + buildName "#${BUILD_NUMBER} ~/fs-cloud/${JOB_NAME}:${IMAGE_VERSION}" + buildDescription "registry.cn-hangzhou.aliyuncs.com/${CLOUD}/${JOB_NAME}:${IMAGE_VERSION}" + sh 'docker build -t registry.cn-hangzhou.aliyuncs.com/${CLOUD}/${JOB_NAME}:${IMAGE_VERSION} .' + sh 'docker push registry.cn-hangzhou.aliyuncs.com/${CLOUD}/${JOB_NAME}:${IMAGE_VERSION}' + } + } + } +} \ No newline at end of file diff --git a/code/VideoAccess-VCMP/web/Dockerfile b/code/VideoAccess-VCMP/web/Dockerfile index 02c9375..9e6abdd 100644 --- a/code/VideoAccess-VCMP/web/Dockerfile +++ b/code/VideoAccess-VCMP/web/Dockerfile @@ -1,5 +1,4 @@ - -FROM repository.anxinyun.cn/base-images/nodejs12:20.10.12.2 +FROM repository.anxinyun.cn/devops/node:12-dev as builder COPY . /var/app @@ -7,6 +6,19 @@ WORKDIR /var/app EXPOSE 8080 -CMD ["-u", "http://localhost:8088"] +RUN npm config set registry=http://10.8.30.22:7000 +RUN echo "{\"time\":\"$BUILD_TIMESTAMP\",\"build\": \"$BUILD_NUMBER\",\"revision\": \"$SVN_REVISION_1\",\"URL\":\"$SVN_URL_1\"}" > version.json +RUN npm cache clean -f +RUN npm install --registry http://10.8.30.22:7000 +RUN npm run build +RUN rm -rf client/src +RUN rm -rf node_modules +RUN npm install --production --registry http://10.8.30.22:7000 + +FROM repository.anxinyun.cn/devops/node:12-dev + +WORKDIR /app + +COPY --from=builder /var/app . -ENTRYPOINT [ "node", "server.js" ] \ No newline at end of file +CMD ["node", "server.js"] \ No newline at end of file diff --git a/code/VideoAccess-VCMP/web/client/src/components/videoPlayer/videoOperation.jsx b/code/VideoAccess-VCMP/web/client/src/components/videoPlayer/videoOperation.jsx index 83c185b..8bc9c03 100644 --- a/code/VideoAccess-VCMP/web/client/src/components/videoPlayer/videoOperation.jsx +++ b/code/VideoAccess-VCMP/web/client/src/components/videoPlayer/videoOperation.jsx @@ -71,7 +71,7 @@ const VideoOperation = ({ operation.map(p => { return diff --git a/code/VideoAccess-VCMP/web/client/src/components/videoPlayer/videoPlay.jsx b/code/VideoAccess-VCMP/web/client/src/components/videoPlayer/videoPlay.jsx index 5ddbec4..ece0236 100644 --- a/code/VideoAccess-VCMP/web/client/src/components/videoPlayer/videoPlay.jsx +++ b/code/VideoAccess-VCMP/web/client/src/components/videoPlayer/videoPlay.jsx @@ -7,7 +7,10 @@ import './videoPlay.less'; const VideoPlay = ({ height, width }) => { const [jessibuca, setjessibuca] = useState(null) - const [playUrl, setPlayUrl] = useState('http://flv.bdplay.nodemedia.cn/live/bbb.flv') + const [playUrl, setPlayUrl] = useState( + // 'http://flv.bdplay.nodemedia.cn/live/bbb.flv' + 'http://221.230.55.27:2020/hdl/34020000001110000077/34020000001310000001.flv' + ) const [isPlaying, setIsPlaying] = useState(false) const [operationState, setoperationState] = useState() const [voiceDisY, setVoiceDisY] = useState(0) diff --git a/code/VideoAccess-VCMP/web/client/src/sections/equipmentWarehouse/containers/camera.jsx b/code/VideoAccess-VCMP/web/client/src/sections/equipmentWarehouse/containers/camera.jsx index 523c90e..e1c13a8 100644 --- a/code/VideoAccess-VCMP/web/client/src/sections/equipmentWarehouse/containers/camera.jsx +++ b/code/VideoAccess-VCMP/web/client/src/sections/equipmentWarehouse/containers/camera.jsx @@ -721,7 +721,7 @@ const CameraHeader = (props) => { "" )} { - // + // } ); diff --git a/code/VideoAccess-VCMP/web/jenkinsfile b/code/VideoAccess-VCMP/web/jenkinsfile new file mode 100644 index 0000000..c246721 --- /dev/null +++ b/code/VideoAccess-VCMP/web/jenkinsfile @@ -0,0 +1,19 @@ +pipeline { + agent { + node{ + label 'jnlp-slave' + } + } + + stages { + stage('Testing vcmp ......') { + steps { + sh 'switch-auth.sh vcmp' + buildName "#${BUILD_NUMBER} ~/fs-cloud/${JOB_NAME}:${IMAGE_VERSION}" + buildDescription "registry.cn-hangzhou.aliyuncs.com/${CLOUD}/${JOB_NAME}:${IMAGE_VERSION}" + sh 'docker build -t registry.cn-hangzhou.aliyuncs.com/${CLOUD}/${JOB_NAME}:${IMAGE_VERSION} .' + sh 'docker push registry.cn-hangzhou.aliyuncs.com/${CLOUD}/${JOB_NAME}:${IMAGE_VERSION}' + } + } + } +} \ No newline at end of file