particle-os-cli/templates/Containerfile.tera
2023-12-30 16:32:57 +00:00

62 lines
2.4 KiB
Text

FROM {{ base_image }}:{{ image_version }}
LABEL org.opencontainers.image.title="{{ name }}"
LABEL org.opencontainers.image.version="{{ image_version }}"
LABEL org.opencontainers.image.description="{{ description }}"
LABEL io.artifacthub.package.readme-url=https://raw.githubusercontent.com/ublue-os/startingpoint/main/README.md
LABEL io.artifacthub.package.logo-url=https://avatars.githubusercontent.com/u/120078124?s=200&v=4
ARG RECIPE={{ recipe }}
{%- if running_gitlab_actions() %}
ARG IMAGE_REGISTRY=ghcr.io/ublue-os
COPY cosign.pub /usr/share/ublue-os/cosign.pub
{%- endif %}
# Copy the bling from ublue-os/bling into tmp, to be installed later by the bling module
# Feel free to remove these lines if you want to speed up image builds and don't want any bling
COPY --from=ghcr.io/ublue-os/bling:latest /rpms /tmp/bling/rpms
COPY --from=ghcr.io/ublue-os/bling:latest /files /tmp/bling/files
COPY --from=docker.io/mikefarah/yq /usr/bin/yq /usr/bin/yq
COPY --from=gcr.io/projectsigstore/cosign /ko-app/cosign /usr/bin/cosign
COPY config /tmp/config/
# Copy modules
# The default modules are inside ublue-os/bling
COPY --from=ghcr.io/ublue-os/bling:latest /modules /tmp/modules/
# Custom modules overwrite defaults
COPY modules /tmp/modules/
RUN echo "#!/usr/bin/env bash" >> /tmp/exports.sh
RUN echo 'get_yaml_array() { readarray "$1" < <(echo "$3" | yq -I=0 "$2"); }; export -f get_yaml_array' >> /tmp/exports.sh
RUN chmod +x /tmp/exports.sh
ARG CONFIG_DIRECTORY="/tmp/config"
ARG IMAGE_NAME="{{ name }}"
ARG BASE_IMAGE="{{ base_image }}"
{%- macro run_modules(module) %}
{%- if module.type %}
{%- if module.type == "containerfile" %}
{%- for c in module.containerfiles %}
{{ print_containerfile(containerfile = c ) }}
{%- endfor %}
{%- else %}
RUN chmod +x /tmp/modules/{{ module.type }}/{{ module.type }}.sh
RUN source /tmp/exports.sh && OS_VERSION="$(grep -Po '(?<=VERSION_ID=)\d+' /usr/lib/os-release)" /tmp/modules/{{ module.type }}/{{ module.type }}.sh '{{ print_module_context(module = module) }}'
{%- endif %}
{%- elif module["from-file"] %}
{%- set extra_module = get_module_from_file(file = module["from-file"]) %}
{%- for m in extra_module.modules %}
{{ self::run_modules(module = m) }}
{%- endfor %}
{%- endif %}
{%- endmacro run_modules %}
{%- for module in modules %}
{{ self::run_modules(module = module) }}
{%- endfor %}
RUN rm -rf /tmp/* /var/* && ostree container commit