Skip to content

Docker

从 v1.0.0 (alpha/beta) 开始,Luban 多集群管理要求 Kubernetes >= 1.12 以上版本的集群使用。

Warning

若系统未安装docker, 请参考文档进行安装 https://docs.docker.com/get-docker/

拉取镜像

docker pull registry.cn-hangzhou.aliyuncs.com/dnsjia/luban:latest
docker pull registry.cn-hangzhou.aliyuncs.com/dnsjia/mysql:5.7

修改配置文件

配置文件示例

  1. 拷贝源码etc目录下的config_example.yaml配置文件命名为 config.yaml

  2. 若使用ldap方式登录,请在ldap.yml配置文件中定义ldap搜索域及管理员账号密码

# zap logger configuration
zap:
  level: 'info'
  format: 'console'
  director: 'logs'
  link-name: 'latest_log'
  show-line: true
  # LowercaseLevelEncoder:小写, LowercaseColorLevelEncoder:小写带颜色,CapitalLevelEncoder: 大写, CapitalColorLevelEncoder: 大写带颜色,
  encode-level: 'CapitalLevelEncoder'
  stacktrace-key: 'stacktrace'
  log-in-console: true

# mysql configuration
mysql:
  path: '192.168.1.10:3306'
  config: 'charset=utf8mb4&parseTime=True&loc=Local'
  db-name: 'luban'
  username: 'root'
  password: '123456'
  max-idle-conns: 10
  max-open-conns: 100
  conn-max-idle-time: 60
  conn-max-life-time: 600
  log-mode: false
  log-zap: ""

# casbin configuration
casbin:
  model-path: './etc/rbac_model.conf'

# system configuration
system:
  env: 'private'  # Change to "develop" to skip authentication for development mode,  change to "private" authentication
  addr: 8999
  rpc: 40737
  db-type: 'mysql'


redis:
  addr: '127.0.0.1:6379'
  db: 0
  username: ''
  password: ''

# cloudSync Task
crontab:
  aliyun: "*/5 * * * *"

# dingding qrcode
dingtalk:
  appid: ''
  secret: ''
  url: 'https://oapi.dingtalk.com'
  # 允许登录的邮箱后缀 test@luban.com [luban.com]
  allow-suffix: 'luban.com'
logger:
  dir: logs
  level: DEBUG
  # # rotate by time
  # keepHours: 4
  # rotate by size
  rotatenum: 3
  rotatesize: 256 # unit: MB

http:
  mode: release
  # whether print access log to DEBUG.log
  access: false
  listen: 0.0.0.0:8000

ldap:
  enable: true
  host: 172.16.10.134
  port: 389
  baseDn: "ou=infra,dc=xxxx,dc=com"
  # AD: manange@example.org
  bindUser: "cn=admin,dc=xxxx,dc=com"
  bindPass: "123456"
  # openldap: (&(uid=%s))
  # AD: (&(sAMAccountName=%s))
  #authFilter: "(&(uid=%s))"
  authFilter: "(&(objectClass=*)(cn=%s))"
  attributes:
    nickname: "cn"
    email: "mail"
    phone: "mobile"
    uid: "uidNumber"
  coverAttributes: false
  autoRegist: true
  tls: false
  startTLS: false

contactKeys:
  - label: "Dingtalk Robot Token"
    key: dingtalk_robot_token

notifyChannels:
  - email
  - dingtalk

如何修改资产同步周期

crontab:
  aliyun: "*/5 * * * *" # 阿里云资产同步周期

Danger

/opt/luban/mysql 为鲁班数据库目录,删除后将导致数据丢失

mkdir -p /opt/luban/mysql

启动MySQL

docker run  -itd --name luban-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 -v /opt/luban/mysql:/var/lib/mysql registry.cn-hangzhou.aliyuncs.com/dnsjia/mysql:5.7

启动后端

docker run -itd --name luban -p 8080:8080 -v /root/luban/etc:/data/luban/etc registry.cn-hangzhou.aliyuncs.com/dnsjia/luban:latest

Success

使用 docker logs luban 查看日志,若显示以下内容则表明安装成功

  • 默认账号密码: guji/a123456.
您正在使用config的默认值, 配置路径为etc/config.yaml
2022/05/06 - 05:32:55.139       INFO    C:/Users/Administrator/Documents/mycode/luban/common/init_table.go:58   register table success
config.file: etc/ldap.yml
[GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached.

[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
 - using env:   export GIN_MODE=release
 - using code:  gin.SetMode(gin.ReleaseMode)

...
...
[GIN-debug] Listening and serving HTTP on :8999
asynq: pid=14 2022/05/06 05:32:55.143133 INFO: Starting processing
asynq: pid=14 2022/05/06 05:32:55.143158 INFO: Send signal TSTP to stop processing new tasks
asynq: pid=14 2022/05/06 05:32:55.143163 INFO: Send signal TERM or INT to terminate the process
2022/05/06 - 05:32:55.143       INFO    C:/Users/Administrator/Documents/mycode/luban/services/job.go:56        SyncJobManager.start
2022/05/06 - 05:32:55.143       INFO    C:/Users/Administrator/Documents/mycode/luban/rpc/server/rpc.go:45      Rpc server: [:40737] available...
2022/05/06 05:32:55 registered an entry: "7ac811c2-b814-4927-afc8-41ce39027e49"
asynq: pid=14 2022/05/06 05:32:55.145914 INFO: Scheduler starting
asynq: pid=14 2022/05/06 05:32:55.145922 INFO: Scheduler timezone is set to UTC
asynq: pid=14 2022/05/06 05:32:55.145937 INFO: Send signal TERM or INT to stop the scheduler

恭喜你安装成功, 快来体验一下吧?

http://your_server_ip:8080

Back to top