fix builds getting stuck. update core dockerfile

This commit is contained in:
mbecker20
2023-01-04 23:26:12 +00:00
parent ac3d17ce82
commit 85c5b146d4
4 changed files with 21 additions and 7 deletions

View File

@@ -8,10 +8,14 @@ COPY ./lib/helpers ./lib/helpers
COPY ./lib/db_client ./lib/db_client
COPY ./lib/periphery_client ./lib/periphery_client
COPY ./lib/axum_oauth2 ./lib/axum_oauth2
RUN cd core && cargo build --release
FROM gcr.io/distroless/cc
COPY ./frontend/build /frontend
COPY --from=builder /builder/core/target/release/core /
EXPOSE 9000

View File

@@ -268,18 +268,23 @@ impl State {
update.id = self.add_update(update.clone()).await?;
let build_logs = self
let build_logs = match self
.periphery
.build(&server, &build)
.await
.context("failed at call to periphery to build")?;
.context("failed at call to periphery to build")
{
Ok(logs) => logs,
Err(e) => Some(vec![Log::error("build", format!("{e:#?}"))]),
};
match build_logs {
Some(logs) => {
update.logs.extend(logs);
update.success = all_logs_success(&update.logs);
if update.success {
self.db
let _ = self
.db
.builds
.update_one::<Build>(
build_id,
@@ -288,7 +293,7 @@ impl State {
.context("failed at converting version to bson")?
}),
)
.await?;
.await;
}
}
None => {

View File

@@ -106,5 +106,6 @@ impl Version {
pub struct DockerBuildArgs {
pub build_path: String,
pub dockerfile_path: Option<String>,
#[serde(default)]
pub build_args: Vec<EnvironmentVar>,
}

View File

@@ -40,9 +40,13 @@ async fn build_image(
if is_busy {
return Err(anyhow!("{PERIPHERY_BUILDER_BUSY}"));
}
let docker_token = get_docker_token(&build.docker_account, &config)?;
let logs = docker::build(&build, config.repo_dir.clone(), docker_token).await?;
let res = async {
let docker_token = get_docker_token(&build.docker_account, &config)?;
let logs = docker::build(&build, config.repo_dir.clone(), docker_token).await?;
anyhow::Ok(logs)
}
.await;
let mut lock = busy.lock().await;
*lock = false;
Ok(Json(logs))
res.map(|logs| Json(logs))
}