summaryrefslogtreecommitdiffstats
path: root/roles/osbs-atomic-reactor/tasks/source_git.yml
blob: f5591e53b9cd1ce0df19d1c5e984857a97a064fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
---
- name: pull base image
  command: docker pull {{ atomic_reactor_git.base_registry }}/{{ atomic_reactor_git.base_image }}
  when: atomic_reactor_git.base_image is defined

- name: tag base image
  command: docker tag -f {{ atomic_reactor_git.base_registry }}/{{ atomic_reactor_git.base_image }} {{ atomic_reactor_git.base_image_retag }}
  when: atomic_reactor_git.base_image_retag is defined

- name: pull git repository with Dockerfile
  git:
    repo: "{{ atomic_reactor_git.git_url }}"
    dest: "{{ atomic_reactor_git.git_local_path }}"
    version: "{{ atomic_reactor_git.git_branch }}"
    accept_hostkey: yes
  register: dockerfile_git_repo
  changed_when: "dockerfile_git_repo.after|default('after') != dockerfile_git_repo.before|default('before')"

- name: check if atomic-reactor image is present
  command: docker inspect {{ atomic_reactor_tag }}
  register: image_present
  failed_when: image_present.rc != 0 and ('No such image' not in image_present.stderr)
  changed_when: image_present.rc != 0

- name: build atomic-reactor image
  command: docker build --no-cache=true --tag={{ atomic_reactor_tag }} {{ atomic_reactor_git.git_local_path }}/{{ atomic_reactor_git.git_subdir }}
  when: dockerfile_git_repo.changed or image_present.changed