From 8b2900d7f33d12c46ae8f3e9d792c7f1d23c1e1c Mon Sep 17 00:00:00 2001 From: Jef Roosens Date: Fri, 8 Apr 2022 13:22:29 +0200 Subject: [PATCH] Added option to specify base build image to use --- src/build/build.v | 18 +++++++++++------- src/build/cli.v | 1 + 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/build/build.v b/src/build/build.v index 4270e9d7..cf70894f 100644 --- a/src/build/build.v +++ b/src/build/build.v @@ -10,9 +10,7 @@ const container_build_dir = '/build' const build_image_repo = 'vieter-build' -const base_image = 'archlinux:latest' - -fn create_build_image() ?string { +fn create_build_image(base_image string) ?string { commands := [ // Update repos & install required packages 'pacman -Syu --needed --noconfirm base-devel git' @@ -29,14 +27,20 @@ fn create_build_image() ?string { cmds_str := base64.encode_str(commands.join('\n')) c := docker.NewContainer{ - image: build.base_image + image: base_image env: ['BUILD_SCRIPT=$cmds_str'] entrypoint: ['/bin/sh', '-c'] cmd: ['echo \$BUILD_SCRIPT | base64 -d | /bin/sh -e'] } - // First, we pull the latest archlinux image - docker.pull_image('archlinux', 'latest') ? + // This check is needed so the user can pass "archlinux" without passing a + // tag & make it still work + image_parts := base_image.split_nth(':', 2) + image_name := image_parts[0] + image_tag := if image_parts.len > 1 { image_parts[1] } else { 'latest' } + + // We pull the provided image + docker.pull_image(image_name, image_tag) ? id := docker.create_container(c) ? docker.start_container(id) ? @@ -78,7 +82,7 @@ fn build(conf Config) ? { } // First, we create a base image which has updated repos n stuff - image_id := create_build_image() ? + image_id := create_build_image(conf.base_image) ? for repo in filtered_repos { // TODO what to do with PKGBUILDs that build multiple packages? diff --git a/src/build/cli.v b/src/build/cli.v index c95d1caa..7cdcf834 100644 --- a/src/build/cli.v +++ b/src/build/cli.v @@ -7,6 +7,7 @@ pub struct Config { pub: api_key string address string + base_image string = 'archlinux:base-devel' } // cmd returns the cli submodule that handles the build process