84 lines
2.6 KiB
Django/Jinja
84 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
|
|
{% 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_BULID_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" %}
|
|
|
|
{%- set files_dir_exists = self::files_dir_exists() %}
|
|
{%~ 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,from={{ build_scripts_image }},src=/scripts/,dst=/tmp/scripts/ \
|
|
/tmp/scripts/setup.sh
|
|
|
|
{%- if files_dir_exists %}
|
|
ARG CONFIG_DIRECTORY="/tmp/files"
|
|
{%- else %}
|
|
ARG CONFIG_DIRECTORY="/tmp/config"
|
|
{%- 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 %}
|