1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: Apache-2.0
5 # build-docker-image.yml - Build a Docker image from another playbook
7 # Typical usage looks like:
9 # ansible-playbook -i files/development-docker-images.yml \
10 # -e arvados_build_playbook=FILENAME.yml \
11 # [--limit=...] build-docker-image.yml
13 # `arvados_build_playbook` is the name of the playbook that turns a base image
14 # into a new image. The inventory defines container names, base images,
15 # and built image tags.
17 - name: Start container(s)
21 - name: Start container
22 delegate_to: localhost
23 community.docker.docker_container:
24 name: "{{ inventory_hostname }}"
25 state: "{{ arvados_docker_startstate|default('healthy') }}"
26 image: "{{ arvados_docker_from }}"
27 pull: "{{ arvados_docker_pull|default('missing') }}"
28 command: "{{ arvados_docker_command|default(['sleep', 'infinity']) }}"
31 ansible.builtin.import_playbook: "{{ arvados_build_playbook }}"
33 - name: Commit image(s)
36 - name: Commit container
37 delegate_to: localhost
43 - "--author={{ arvados_docker_author|default('Arvados Package Maintainers <packaging@arvados.org>') }}"
44 - '--change=CMD ["bash"]'
45 # `map` just adds the option flag to the start of each string.
46 argv_changes: "{{ arvados_docker_changes|default([])|map('replace', '', '--change=', 1)|list }}"
48 - "{{ inventory_hostname }}"
49 - "{{ arvados_docker_tag }}"
50 ansible.builtin.command:
51 argv: "{{ argv_start + argv_changes + argv_args }}"
53 - name: Clean up container
54 delegate_to: localhost
55 community.docker.docker_container:
56 name: "{{ inventory_hostname }}"
57 state: "{{ arvados_docker_endstate|default('absent') }}"