vieter/src/console/targets/build.v

35 lines
754 B
Coq
Raw Normal View History

module targets
import client
2022-06-22 09:18:47 +02:00
import vieter_v.docker
import os
import build
// build locally builds the target with the given id.
2022-11-01 21:10:45 +01:00
fn build(conf Config, target_id int) ! {
c := client.new(conf.address, conf.api_key)
2022-11-01 21:10:45 +01:00
target := c.get_target(target_id)!
build_arch := os.uname().machine
println('Creating base image...')
2022-11-01 21:10:45 +01:00
image_id := build.create_build_image(conf.base_image)!
println('Running build...')
2022-11-01 21:10:45 +01:00
res := build.build_target(conf.address, conf.api_key, image_id, target)!
println('Removing build image...')
2022-11-01 21:10:45 +01:00
mut dd := docker.new_conn()!
defer {
dd.close() or {}
}
2022-11-01 21:10:45 +01:00
dd.remove_image(image_id)!
println('Uploading logs to Vieter...')
c.add_build_log(target.id, res.start_time, res.end_time, build_arch, res.exit_code,
2022-11-01 21:10:45 +01:00
res.logs)!
}