33 lines
946 B
YAML
33 lines
946 B
YAML
- import_tasks: precheck.yml
|
|
tags:
|
|
- always
|
|
|
|
- name: Set default modified_append_tag
|
|
set_fact:
|
|
modified_append_tag: "{{ lookup('pipe','date +-modified-%Y%m%d%H%M%S') }}"
|
|
when: modified_append_tag is undefined
|
|
|
|
- name: Copy Dockerfile to Dockerfile.modified
|
|
copy:
|
|
src: "{{ modify_dir_path }}/Dockerfile"
|
|
dest: "{{ modify_dir_path }}/Dockerfile.modified"
|
|
|
|
- name: Replace FROM directive
|
|
lineinfile:
|
|
path: "{{ modify_dir_path }}/Dockerfile.modified"
|
|
regexp: "^FROM "
|
|
line: "FROM {{ source_image }}"
|
|
|
|
- name: Add LABEL modified_append_tag={{ modified_append_tag }}
|
|
lineinfile:
|
|
path: "{{ modify_dir_path }}/Dockerfile.modified"
|
|
insertafter: "^FROM "
|
|
line: "LABEL modified_append_tag={{ modified_append_tag }}"
|
|
|
|
- name: Modify image
|
|
docker_image:
|
|
name: "{{ target_image | default(source_image) }}{{ modified_append_tag }}"
|
|
path: "{{ modify_dir_path }}"
|
|
dockerfile: Dockerfile.modified
|
|
|