This decouples the need for a published image for the bulid scripts and will now embed them into the binary instead. This will make it so that anyone that forks the CLI is able to make adjustments to the build scripts and use them immediately. This will be needed for testing #515
85 lines
2.6 KiB
Django/Jinja
85 lines
2.6 KiB
Django/Jinja
# This stage is responsible for holding onto
|
|
# your config without copying it directly into
|
|
# the final image
|
|
{%- if self::files_dir_exists() %}
|
|
FROM scratch AS stage-files
|
|
COPY ./files /files
|
|
{%- else if self::config_dir_exists() %}
|
|
FROM scratch AS stage-config
|
|
COPY ./config /config
|
|
{%- else %}
|
|
FROM scratch AS stage-files
|
|
WORKDIR /files
|
|
{% endif %}
|
|
|
|
{%~ if self::modules_exists() %}
|
|
# Copy modules
|
|
# The default modules are inside blue-build/modules
|
|
# Custom modules overwrite defaults
|
|
FROM scratch AS stage-modules
|
|
COPY ./modules /modules
|
|
{% endif %}
|
|
|
|
# Bins to install
|
|
# These are basic tools that are added to all images.
|
|
# Generally used for the build process. We use a multi
|
|
# stage process so that adding the bins into the image
|
|
# can be added to the ostree commits.
|
|
FROM scratch AS stage-bins
|
|
COPY --from={{ blue_build_utils::constants::COSIGN_IMAGE }} /ko-app/cosign /bins/cosign
|
|
{%- if recipe.should_install_bluebuild() %}
|
|
COPY --from={{ blue_build_utils::constants::BLUE_BUILD_IMAGE_REF }}:{{ recipe.get_bluebuild_version() }} \
|
|
/out/bluebuild /bins/bluebuild
|
|
{%- endif %}
|
|
|
|
# Keys for pre-verified images
|
|
# Used to copy the keys into the final image
|
|
# and perform an ostree commit.
|
|
#
|
|
# Currently only holds the current image's
|
|
# public key.
|
|
FROM scratch AS stage-keys
|
|
{%- if self::has_cosign_file() %}
|
|
COPY cosign.pub /keys/{{ recipe.name|replace('/', "_") }}.pub
|
|
{% endif %}
|
|
|
|
{%- include "modules/akmods/akmods.j2" %}
|
|
|
|
{%~ if let Some(stages_ext) = recipe.stages_ext %}
|
|
{%- for stage in stages_ext.stages %}
|
|
{%- if let Some(stage) = stage.required_fields %}
|
|
# {{ stage.name|capitalize }} stage
|
|
FROM {{ stage.from }} AS {{ stage.name }}
|
|
|
|
{%- if self::should_color() %}
|
|
ARG FORCE_COLOR=1
|
|
ARG CLICOLOR_FORCE=1
|
|
ARG RUST_LOG_STYLE=always
|
|
{%- endif %}
|
|
|
|
{%- if stage.from != "scratch" %}
|
|
COPY --from={{ blue_build_utils::constants::NUSHELL_IMAGE }}:{{ get_nu_version() }} /nu/* /usr/libexec/bluebuild/nu/
|
|
|
|
# Add compatibility for modules
|
|
RUN --mount=type=bind,from=stage-bins,src=/bins/,dst=/tmp/bins/ \
|
|
--mount=type=bind,src={{ build_scripts_dir.display() }},dst=/tmp/scripts/ \
|
|
/tmp/scripts/setup.sh
|
|
|
|
{%- if self::config_dir_exists() %}
|
|
ARG CONFIG_DIRECTORY="/tmp/config"
|
|
{%- else %}
|
|
ARG CONFIG_DIRECTORY="/tmp/files"
|
|
{%- endif %}
|
|
ARG MODULE_DIRECTORY="/tmp/modules"
|
|
|
|
{%- if let Some(shell_args) = stage.shell %}
|
|
SHELL [{% for arg in shell_args %}"{{ arg }}"{% if !loop.last %}, {% endif %}{% endfor %}]
|
|
{%- else %}
|
|
SHELL ["bash", "-c"]
|
|
{%- endif %}
|
|
{%- endif %}
|
|
|
|
{% call modules::stage_modules_run(stage.modules_ext, os_version) %}
|
|
{%- endif %}
|
|
{%- endfor %}
|
|
{%- endif %}
|