Basic template based Dockerfile approach

This commit is contained in:
Steve Baker 2018-04-30 17:26:58 +12:00
parent 3aeb7cc78b
commit e865f69b4e
3 changed files with 27 additions and 11 deletions

View File

@ -1 +1,21 @@
---
- 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: Write Dockerfile to {{ context_dir.path }}
template:
src: Dockerfile.j2
dest: "{{ context_dir.path }}/Dockerfile"
- name: Modify image
docker_image:
name: "{{ modified_image }}{{ modified_append_tag }}"
path: "{{ context_dir.path }}"

2
templates/Dockerfile.j2 Normal file
View File

@ -0,0 +1,2 @@
FROM {{ source_image }}
LABEL modified_append_tag={{ modified_append_tag }}

View File

@ -2,19 +2,13 @@
# Mandatory fully qualified reference to the source image to be modified
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.
modified_append_tag: "-modified-{{lookup('pipe','date +%Y%m%d%H%M%S')}}"
# the source image. Defaults to the output of the command
# "date +-modified-%Y%m%d%H%M%S"
modified_append_tag:
# If set, the modified image will be tagged with this reference. If the purpose
# 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:
# Build-time variables for the image build. The role variables source_image and
# modified_append_tag will be merged with this dict.
modify_buildargs: {}
modified_image: {{ source_image }}