From d3e198d5c7d76342d032554f45539714034e4bae Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Fri, 12 Apr 2024 15:58:50 -0400 Subject: Avoid building docker images when no Dockerfile is present --- src/deliverable.c | 8 +++++--- src/main.c | 14 ++++++++++---- 2 files changed, 15 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/deliverable.c b/src/deliverable.c index 4c29fa4..0729ff8 100644 --- a/src/deliverable.c +++ b/src/deliverable.c @@ -752,9 +752,11 @@ int delivery_init(struct Delivery *ctx) { } } - if (docker_validate_compression_program(ctx->deploy.docker.image_compression)) { - SYSERROR("[deploy:docker].image_compression - invalid command / program is not installed: %s", ctx->deploy.docker.image_compression); - return -1; + if (ctx->deploy.docker.image_compression) { + if (docker_validate_compression_program(ctx->deploy.docker.image_compression)) { + SYSERROR("[deploy:docker].image_compression - invalid command / program is not installed: %s", ctx->deploy.docker.image_compression); + return -1; + } } return 0; } diff --git a/src/main.c b/src/main.c index 7c20ae7..9e35240 100644 --- a/src/main.c +++ b/src/main.c @@ -580,11 +580,17 @@ int main(int argc, char *argv[]) { msg(OMC_MSG_L1, "Rendering mission templates\n"); delivery_mission_render_files(&ctx); + char dockerfile[PATH_MAX] = {0}; + sprintf(dockerfile, "%s/%s", ctx.storage.build_docker_dir, "Dockerfile"); if (globals.enable_docker) { - msg(OMC_MSG_L1, "Building Docker image\n"); - if (delivery_docker(&ctx)) { - msg(OMC_MSG_L1 | OMC_MSG_ERROR, "Failed to build docker image!\n"); - COE_CHECK_ABORT(1, "Failed to build docker image"); + if (!access(dockerfile, F_OK)) { + msg(OMC_MSG_L1, "Building Docker image\n"); + if (delivery_docker(&ctx)) { + msg(OMC_MSG_L1 | OMC_MSG_ERROR, "Failed to build docker image!\n"); + COE_CHECK_ABORT(1, "Failed to build docker image"); + } + } else { + msg(OMC_MSG_L1 | OMC_MSG_WARN, "Docker image building is disabled. No Dockerfile found in %s\n", ctx.storage.build_docker_dir); } } else { msg(OMC_MSG_L1 | OMC_MSG_WARN, "Docker image building is disabled\n"); -- cgit