From 93b40f8d73701fe360995eba44f5a40c5586d72f Mon Sep 17 00:00:00 2001 From: Gerald Pinder Date: Sun, 18 Feb 2024 11:24:37 -0500 Subject: [PATCH] feat: Allow user to use source images (#69) --- src/module_recipe.rs | 4 ++++ templates/Containerfile | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/module_recipe.rs b/src/module_recipe.rs index 61ed444..af1ef10 100644 --- a/src/module_recipe.rs +++ b/src/module_recipe.rs @@ -245,6 +245,10 @@ pub struct Module<'a> { #[serde(rename = "from-file", skip_serializing_if = "Option::is_none")] pub from_file: Option>, + #[builder(default, setter(into, strip_option))] + #[serde(skip_serializing_if = "Option::is_none")] + pub source: Option>, + #[serde(flatten)] #[builder(default, setter(into))] pub config: IndexMap, diff --git a/templates/Containerfile b/templates/Containerfile index de88f45..13c683c 100644 --- a/templates/Containerfile +++ b/templates/Containerfile @@ -75,7 +75,11 @@ RUN \ --mount=type=tmpfs,target=/tmp \ --mount=type=tmpfs,target=/var \ --mount=type=bind,from=stage-config,src=/config,dst=/tmp/config,rw \ + {%- if let Some(source) = module.source %} + --mount=type=bind,from={{ source }},src=/modules,dst=/tmp/modules,rw \ + {%- else %} --mount=type=bind,from=stage-modules,src=/modules,dst=/tmp/modules,rw \ + {%- endif %} --mount=type=bind,from=stage-exports,src=/exports.sh,dst=/tmp/exports.sh \ chmod +x /tmp/modules/{{ type }}/{{ type }}.sh \ && source /tmp/exports.sh && /tmp/modules/{{ type }}/{{ type }}.sh '{{ self::print_module_context(module) }}'