server_box_monitor/docker_build.lk
2023-05-20 22:45:06 +08:00

32 lines
641 B
Plaintext
Executable File

#!/usr/bin/env lk
args := os.args
version_reg := `[0-9]+\.[0-9]+\.[0-9]+`
if #args != 3 {
errorf('need version: %s', args)
}
version := args.2
if !version:match(version_reg).0 {
errorf('invalid version format: %s', version)
}
cmd_parts := {
'docker buildx build',
'-t lollipopkit/srvbox_monitor:%s',
'-t lollipopkit/srvbox_monitor:latest',
'--platform=linux/arm64,linux/amd64',
'--build-arg APPVER=%s',
'.',
'--push',
}
cmd := fmt(' ':join(cmd_parts), version, version)
result, err := os.exec(cmd)
if err != nil {
errorf('%s:\n%s', err, result)
}
printf('%sSuccess%s', term.green, term.nocolor)