#!/bin/bash

if ! command -v bash >/dev/null 2>&1; then
    echo "Bash not found. Exiting."
    exit 1
fi

{% block install_commands %}
source {{ builder.rendered_files_path }}/build-{{ service.name }}-functions.sh
{% endblock %}

{% block pre_build_commands %}
{% if service.build %}
login_to_registries
{% endif %}
{% endblock %}

{% block build_commands %}

{% if service.image and (not service.build) %}
verify_{{ service.name }}_image_exists
{% else %}
build_{{ service.name }}_image
{% endif %}

{% if service.build and not builder.file_exists(service.build.dockerfile) %}
push_{{ service.name }}_image_tags
{% endif %}
{% endblock %}

{% block post_build_commands %}
{% endblock %}
