Skip to content

Commit

Permalink
fix: docker release node script
Browse files Browse the repository at this point in the history
  • Loading branch information
uniquemo committed May 21, 2020
1 parent 94c2e85 commit 4e7b8ec
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
20 changes: 13 additions & 7 deletions deploy/docker.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,21 @@ const shell = require('shelljs')
const packageFile = require('../package.json')

const { name, version } = packageFile
const imageName = `${name}:${version}`
const containerName = `container-${imageName}`

// 生成docker image
shell.exec(`docker image build -t ${name}:${version} .`)
shell.exec(`docker image build -t ${imageName} .`)

// 获取原来的8080端口的进程pid,如果存在,kill掉该进程
const child = shell.exec('lsof -i:8080 -t', { silent: true })
const pid = Number(child.stdout.split('\n')[0])
if (pid) {
shell.exec(`kill -9 ${pid}`)
}
// const child = shell.exec('lsof -i:8080 -t', { silent: true })
// const pid = Number(child.stdout.split('\n')[0])
// if (pid) {
// shell.exec(`kill -9 ${pid}`)
// }

shell.exec(`docker container stop ${containerName}`)
shell.exec(`docker container rm ${containerName}`)

// 运行docker container
shell.exec(`docker container run -d -p 8080:80 ${name}:${version}`)
shell.exec(`docker container run -d --name ${containerName} -p 8080:80 ${imageName}`)
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-netease-music",
"version": "1.1.1",
"version": "1.1.2",
"description": "基于React、TypeScript的高仿网易云mac客户端播放器",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 4e7b8ec

Please sign in to comment.