diff --git a/roles/custom/matrix-appservice-draupnir-for-all/tasks/setup_install.yml b/roles/custom/matrix-appservice-draupnir-for-all/tasks/setup_install.yml index ba01a0b81..95a5f1fa4 100644 --- a/roles/custom/matrix-appservice-draupnir-for-all/tasks/setup_install.yml +++ b/roles/custom/matrix-appservice-draupnir-for-all/tasks/setup_install.yml @@ -48,14 +48,16 @@ - name: Ensure Draupnir Docker image is built # Using docker_image_build with BuildKit for modern, efficient builds. - # docker_image_build automatically rebuilds when the Dockerfile or build context changes. - # The git_pull_results will show if the source was updated above. + # Rebuild when the git checkout advanced to a new commit; otherwise keep the build idempotent. + # Technically the idempotency of rebuilds is more that if a build has already been executed for that name:tag + # then we wont rebuild while in idempotent mode even if git moved. Thats what the force rebuild logic is for. community.docker.docker_image_build: name: "{{ matrix_appservice_draupnir_for_all_container_image }}" dockerfile: Dockerfile path: "{{ matrix_appservice_draupnir_for_all_container_src_files_path }}" pull: true - when: "matrix_appservice_draupnir_for_all_container_image_self_build | bool and matrix_appservice_draupnir_for_all_git_pull_results.changed" + rebuild: "{{ 'always' if matrix_appservice_draupnir_for_all_git_pull_results.changed | bool else 'never' }}" + when: "matrix_appservice_draupnir_for_all_container_image_self_build | bool" register: matrix_appservice_draupnir_for_all_container_image_build_result - name: Ensure matrix-appservice-draupnir-for-all appservice config installed diff --git a/roles/custom/matrix-bot-draupnir/tasks/setup_install.yml b/roles/custom/matrix-bot-draupnir/tasks/setup_install.yml index 8ddb58af5..5f173d3af 100644 --- a/roles/custom/matrix-bot-draupnir/tasks/setup_install.yml +++ b/roles/custom/matrix-bot-draupnir/tasks/setup_install.yml @@ -60,14 +60,16 @@ - name: Ensure Draupnir Docker image is built # Using docker_image_build with BuildKit for modern, efficient builds. - # docker_image_build automatically rebuilds when the Dockerfile or build context changes. - # The git_pull_results will show if the source was updated above. + # Rebuild when the git checkout advanced to a new commit; otherwise keep the build idempotent. + # Technically the idempotency of rebuilds is more that if a build has already been executed for that name:tag + # then we wont rebuild while in idempotent mode even if git moved. Thats what the force rebuild logic is for. community.docker.docker_image_build: name: "{{ matrix_bot_draupnir_container_image }}" dockerfile: Dockerfile path: "{{ matrix_bot_draupnir_container_src_files_path }}" pull: true - when: "matrix_bot_draupnir_container_image_self_build | bool and matrix_bot_draupnir_git_pull_results.changed" + rebuild: "{{ 'always' if matrix_bot_draupnir_git_pull_results.changed | bool else 'never' }}" + when: "matrix_bot_draupnir_container_image_self_build | bool" register: matrix_bot_draupnir_container_image_build_result - name: Ensure matrix-bot-draupnir config installed