nexhome-web-devops-util
TypeScript icon, indicating that this package has built-in type declarations

0.1.12 • Public • Published

nexhome devops util

brief intro

这是 nexhome 用于 jenkins(CI/CD) and gitlab-ci 打包的工具库

install

yarn add nexhome-web-devops-util -D
# or 
npm i nexhome-web-devops-util -D

usage

tsconfig.json

{
  "include": ["./**/*.ts"],
  "compilerOptions": {
    "resolveJsonModule": true,
    "target": "es5",
    "module": "commonjs",
    "lib": [
      "DOM"
    ],
    "strict": true,
    "moduleResolution": "node",
    "esModuleInterop": true ,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true
  }
}

1. dev env

①. devops-dev.ts

  const config = {}
  runLocally(config)

②. package.json

{
  "scripts":{
    "build-for-dev": "yarn && npx ts-node  --dir ${scripts-path} devops-dev.ts || exit -1",
  }
}

③. set jenkins config

yarn build-for-dev

2. test env

①. devops-test.ts

import { bootstrap, BuildConfig } from 'nexhome-web-devops-util'
import {
  dockerAccountInfo,
  qiniuAccountInfo,
  dockerHubPrefix
} from './constants'
import pkg from '../package.json'

const run = async () => {
  const { name, version } = pkg
  const config: BuildConfig = {
    env: 'test',
    appName: name,
    version,
    buildCommand: 'yarn build',
    dockerfile: 'Dockerfile.test',
    dockerAccountInfo,
    qiniuAccountInfo,
    deployedPort: 8080,
    dockerHubPrefix,
    cicdType: 'jenkins' // or 'gitlab-ci'
  }

  bootstrap(config)
}

run()

②. package.json

{
  "scripts":{
    "build-for-test": "yarn && npx ts-node --dir ${scripts-path} devops-test.ts || exit -1",
  }
}

③. set jenkins config

yarn build-for-test

④. server shell script

# 1. login to docker service
docker login -u ${u} -p ${p} registry.cn-shanghai.aliyuncs.com || exit -1

# 2. stop previous service
docker-compose stop

# 3. set some vars to download latest docker-compose.yml
dockerComposeUrl='https://some-where.com/docker-compose.yml'

_hash=`date "+%s"`

curl $dockerComposeUrl?_hash=$_hash -o docker-compose.yml || exit -1

# 4. start service
docker-compose up -d --remove-orphans

# All done :)

All done 🙈

Readme

Keywords

Package Sidebar

Install

npm i nexhome-web-devops-util

Weekly Downloads

0

Version

0.1.12

License

MIT

Unpacked Size

47.7 kB

Total Files

5

Last publish

Collaborators

  • guygubaby