Make a copy of Dockerfile and modify FROM
This commit is contained in:
parent
e865f69b4e
commit
e8cf96abc3
|
@ -1,21 +1,28 @@
|
|||
- name: Copy Dockerfile to Dockerfile.modified
|
||||
copy:
|
||||
src: "{{ modify_dir_path }}/Dockerfile"
|
||||
dest: "{{ modify_dir_path }}/Dockerfile.modified"
|
||||
|
||||
- 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 or modified_append_tag == None
|
||||
|
||||
- name: Create image build context directory
|
||||
tempfile:
|
||||
state: directory
|
||||
prefix: tripleo-modify-image
|
||||
register: context_dir
|
||||
- name: Replace FROM directive
|
||||
lineinfile:
|
||||
path: "{{ modify_dir_path }}/Dockerfile.modified"
|
||||
regexp: "^FROM "
|
||||
line: "FROM {{ source_image }}"
|
||||
|
||||
- name: Write Dockerfile to {{ context_dir.path }}
|
||||
template:
|
||||
src: Dockerfile.j2
|
||||
dest: "{{ context_dir.path }}/Dockerfile"
|
||||
- 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: "{{ modified_image }}{{ modified_append_tag }}"
|
||||
path: "{{ context_dir.path }}"
|
||||
path: "{{ modify_dir_path }}"
|
||||
dockerfile: Dockerfile.modified
|
||||
|
||||
|
|
|
@ -1,7 +1,12 @@
|
|||
|
||||
# Mandatory fully qualified reference to the source image to be modified
|
||||
# Mandatory fully qualified reference to the source image to be modified.
|
||||
# The supplied Dockerfile will be copied and modified to make the FROM
|
||||
# directive match this variable.
|
||||
source_image:
|
||||
|
||||
# Mandatory path to the directory containing the Dockerfile to modify the image
|
||||
modify_dir_path:
|
||||
|
||||
# String to be appended after the tag to indicate this is a modified version of
|
||||
# the source image. Defaults to the output of the command
|
||||
# "date +-modified-%Y%m%d%H%M%S"
|
||||
|
@ -11,4 +16,4 @@ modified_append_tag:
|
|||
# of the image is not changing, it may be enough to rely on modified_append_tag
|
||||
# to identify that this is a modified version of the source image.
|
||||
# modified_append_tag will still be appended to this reference.
|
||||
modified_image: {{ source_image }}
|
||||
modified_image: "{{ source_image }}"
|
||||
|
|
Loading…
Reference in New Issue