forked from vieter-v/vieter
Compare commits
No commits in common. "11bc382f47fbd6076044eaed9378edf42d970675" and "ea4c4fce1650543bcbf22e20d6ce01015120500f" have entirely different histories.
11bc382f47
...
ea4c4fce16
|
@ -11,9 +11,7 @@ pipeline:
|
||||||
- 'docker_password'
|
- 'docker_password'
|
||||||
settings:
|
settings:
|
||||||
repo: 'chewingbever/vieter'
|
repo: 'chewingbever/vieter'
|
||||||
tags:
|
tag: 'dev'
|
||||||
- 'dev'
|
|
||||||
- ${CI_COMMIT_SHA}
|
|
||||||
platforms: [ 'linux/arm64/v8', 'linux/amd64' ]
|
platforms: [ 'linux/arm64/v8', 'linux/amd64' ]
|
||||||
build_args_from_env:
|
build_args_from_env:
|
||||||
- 'CI_COMMIT_SHA'
|
- 'CI_COMMIT_SHA'
|
||||||
|
|
|
@ -15,7 +15,7 @@ repositories. After the image has been created, each repository returned by
|
||||||
previously created image as a base. Each container goes through the following steps:
|
previously created image as a base. Each container goes through the following steps:
|
||||||
|
|
||||||
1. The repository is cloned
|
1. The repository is cloned
|
||||||
2. `makepkg --nobuild` is ran to update the `pkgver` variable inside
|
2. `makepkg --nobuild --nodeps` is ran to update the `pkgver` variable inside
|
||||||
the `PKGBUILD` file
|
the `PKGBUILD` file
|
||||||
3. A HEAD request is sent to the Vieter server to check whether the specific
|
3. A HEAD request is sent to the Vieter server to check whether the specific
|
||||||
version of the package is already present. If it is, the container exits.
|
version of the package is already present. If it is, the container exits.
|
||||||
|
|
|
@ -91,7 +91,7 @@ pub fn build_repo(address string, api_key string, base_image_id string, repo &db
|
||||||
commands := [
|
commands := [
|
||||||
'git clone --single-branch --depth 1 --branch $repo.branch $repo.url repo',
|
'git clone --single-branch --depth 1 --branch $repo.branch $repo.url repo',
|
||||||
'cd repo',
|
'cd repo',
|
||||||
'makepkg --nobuild',
|
'makepkg --nobuild --nodeps',
|
||||||
'source PKGBUILD',
|
'source PKGBUILD',
|
||||||
// The build container checks whether the package is already
|
// The build container checks whether the package is already
|
||||||
// present on the server
|
// present on the server
|
||||||
|
@ -118,7 +118,11 @@ pub fn build_repo(address string, api_key string, base_image_id string, repo &db
|
||||||
mut data := docker.inspect_container(id) ?
|
mut data := docker.inspect_container(id) ?
|
||||||
|
|
||||||
// This loop waits until the container has stopped, so we can remove it after
|
// This loop waits until the container has stopped, so we can remove it after
|
||||||
for data.state.running {
|
for {
|
||||||
|
if !data.state.running {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
time.sleep(1 * time.second)
|
time.sleep(1 * time.second)
|
||||||
|
|
||||||
data = docker.inspect_container(id) ?
|
data = docker.inspect_container(id) ?
|
||||||
|
|
|
@ -67,6 +67,13 @@ pub mut:
|
||||||
end_time time.Time [skip]
|
end_time time.Time [skip]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn docker_timestamp_to_time(s string) ?time.Time {
|
||||||
|
parts := s.split('.')
|
||||||
|
clipped := parts[0] + '.' + parts[1][..3]
|
||||||
|
|
||||||
|
return time.parse_rfc3339(clipped)
|
||||||
|
}
|
||||||
|
|
||||||
// inspect_container returns the result of inspecting a container with a given
|
// inspect_container returns the result of inspecting a container with a given
|
||||||
// ID.
|
// ID.
|
||||||
pub fn inspect_container(id string) ?ContainerInspect {
|
pub fn inspect_container(id string) ?ContainerInspect {
|
||||||
|
@ -78,10 +85,10 @@ pub fn inspect_container(id string) ?ContainerInspect {
|
||||||
|
|
||||||
mut data := json.decode(ContainerInspect, res.text) ?
|
mut data := json.decode(ContainerInspect, res.text) ?
|
||||||
|
|
||||||
data.state.start_time = time.parse_rfc3339(data.state.start_time_str) ?
|
data.state.start_time = docker_timestamp_to_time(data.state.start_time_str) ?
|
||||||
|
|
||||||
if data.state.status == 'exited' {
|
if data.state.status == 'exited' {
|
||||||
data.state.end_time = time.parse_rfc3339(data.state.end_time_str) ?
|
data.state.end_time = docker_timestamp_to_time(data.state.end_time_str) ?
|
||||||
}
|
}
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
@ -94,8 +101,6 @@ pub fn remove_container(id string) ?bool {
|
||||||
return res.status_code == 204
|
return res.status_code == 204
|
||||||
}
|
}
|
||||||
|
|
||||||
// get_container_logs retrieves the logs for a Docker container, both stdout &
|
|
||||||
// stderr.
|
|
||||||
pub fn get_container_logs(id string) ?string {
|
pub fn get_container_logs(id string) ?string {
|
||||||
res := request('GET', urllib.parse('/v1.41/containers/$id/logs?stdout=true&stderr=true') ?) ?
|
res := request('GET', urllib.parse('/v1.41/containers/$id/logs?stdout=true&stderr=true') ?) ?
|
||||||
mut res_bytes := res.text.bytes()
|
mut res_bytes := res.text.bytes()
|
||||||
|
|
Loading…
Reference in New Issue