03_image.ymlΒΆ

---
- name: πŸ“‚ Create runner image build context directory
  ansible.builtin.file: # nocheck: stack-host-consumer (include is IS_STACK_HOST-gated)
    path: "{{ RUNNER_INSTALL_DIR }}/build"
    state: directory
    owner: "{{ RUNNER_USER }}"
    group: "{{ RUNNER_USER }}"
    mode: "0755"

- name: πŸ“„ Copy Dockerfile to build context
  ansible.builtin.copy: # nocheck: stack-host-consumer (include is IS_STACK_HOST-gated)
    src: Dockerfile
    dest: "{{ RUNNER_INSTALL_DIR }}/build/Dockerfile"
    mode: "0644"

- name: πŸ“„ Copy entrypoint to build context
  ansible.builtin.copy: # nocheck: stack-host-consumer (include is IS_STACK_HOST-gated)
    src: shell/entrypoint.sh
    dest: "{{ RUNNER_INSTALL_DIR }}/build/entrypoint.sh"
    mode: "0755"

- name: πŸ“¦ Build runner container image
  ansible.builtin.command: # nocheck: stack-host-consumer (include is IS_STACK_HOST-gated)
    argv:
      - container
      - build
      - -t
      - "{{ RUNNER_IMAGE_REF }}"
      - --build-arg
      - "RUNNER_BASE_IMAGE={{ RUNNER_BASE_IMAGE }}"
      - --build-arg
      - "RUNNER_UID={{ RUNNER_UID }}"
      - --build-arg
      - "RUNNER_GID={{ RUNNER_GID }}"
      - "{{ RUNNER_INSTALL_DIR }}/build"
  changed_when: true

- name: πŸ“€ Push runner image to swarm registry
  ansible.builtin.command:
    argv:
      - container
      - push
      - "{{ RUNNER_IMAGE_REF }}"
  changed_when: true
  when: SWARM_REGISTRY_PREFIX | length > 0