From: Thanh Ha Date: Fri, 14 Aug 2020 14:23:29 +0000 (-0400) Subject: Add support for a Docker builder X-Git-Tag: v0.8.0~3 X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F91%2F65091%2F6;p=releng%2Fcommon-packer.git Add support for a Docker builder Adding a Docker builder will allow us to more easily test build images locally in a container before pushing a patch to production to build the VMs themselves. While not guarenteed to be exactly the same it's a close enough approximation that many issues can be caught before patches are pushed. Additionally this allows projects to also use the same packer templates to build container based builder nodes if there's any projects using Docker for their Jenkins jobs. Issue: RELENG-1052 Change-Id: If89801cea16046900e7e880265ad859a96595fa1 Signed-off-by: Thanh Ha --- diff --git a/releasenotes/notes/docker-support-c04bf0df10c15c00.yaml b/releasenotes/notes/docker-support-c04bf0df10c15c00.yaml new file mode 100644 index 0000000..71e15ff --- /dev/null +++ b/releasenotes/notes/docker-support-c04bf0df10c15c00.yaml @@ -0,0 +1,40 @@ +--- +features: + - | + Docker image builds are now supported by the packer templates. +upgrade: + - | + Requires first upgrading global-jjb to version v0.57.0 to pull in support + for selecting a packer-builder in the packer-merge jobs, otherwise existing + project packer-merge job builds *may* fail without the global-jjb updates + if builds are run on a Jenkins node that does not support Docker. + - | + Projects using AWS must ensure that the packer-merge jobs are updated to + set *packer-builder* to aws. + + Example: + + .. code-block:: yaml + :emphasize-lines: 19 + + - project: + name: packer-builder-jobs + jobs: + - gerrit-packer-merge + + project: releng/builder + project-name: builder + branch: master + archive-artifacts: "**/*.log" + + build-node: centos7-builder-2c-1g + build-timeout: 90 + cron: "00 H 1 * *" + + platforms: + - centos-7 + - centos-8 + + packer-builder: aws + templates: builder + update-cloud-image: true diff --git a/templates/builder.json b/templates/builder.json index f4ca2f9..0fa217d 100644 --- a/templates/builder.json +++ b/templates/builder.json @@ -10,6 +10,7 @@ "vm_volume_size": "20", "vm_image_disk_format": "", "distro": null, + "docker_source_image": null, "flavor": "v2-highcpu-1", "ssh_user": null, "ssh_proxy_host": "" @@ -33,6 +34,13 @@ "use_blockstorage_volume": "{{user `vm_use_block_storage`}}", "volume_size": "{{user `vm_volume_size`}}", "image_disk_format": "{{user `vm_image_disk_format`}}" + }, + { + "name": "docker", + "type": "docker", + "image": "{{ user `docker_source_image` }}", + "commit": true, + "changes": ["ENTRYPOINT [\"\"]", "CMD [\"\"]"] } ], "provisioners": [ diff --git a/templates/docker.json b/templates/docker.json index 2254dd2..c4699b0 100644 --- a/templates/docker.json +++ b/templates/docker.json @@ -10,6 +10,7 @@ "vm_volume_size": "20", "vm_image_disk_format": "", "distro": null, + "docker_source_image": null, "flavor": "v2-highcpu-1", "ssh_user": null, "ssh_proxy_host": "" @@ -33,6 +34,13 @@ "use_blockstorage_volume": "{{user `vm_use_block_storage`}}", "volume_size": "{{user `vm_volume_size`}}", "image_disk_format": "{{user `vm_image_disk_format`}}" + }, + { + "name": "docker", + "type": "docker", + "image": "{{ user `docker_source_image` }}", + "commit": true, + "changes": ["ENTRYPOINT [\"\"]", "CMD [\"\"]"] } ], "provisioners": [ diff --git a/vars/centos-7.json b/vars/centos-7.json index efdd3b5..cec0955 100644 --- a/vars/centos-7.json +++ b/vars/centos-7.json @@ -3,6 +3,7 @@ "source_ami_filter_owner": "679593333241", "base_image": "LF - CentOS 7.2003 (2020-04-22)", "distro": "CentOS 7", + "docker_source_image": "centos:7", "ssh_user": "centos", "cloud_user_data": "common-packer/provision/rh-user_data.sh" } diff --git a/vars/centos-8.json b/vars/centos-8.json index bd82e9d..1042cb2 100644 --- a/vars/centos-8.json +++ b/vars/centos-8.json @@ -3,6 +3,7 @@ "source_ami_filter_owner": "679593333241", "base_image": "CentOS 8.2 (x86_64) [2020-06-11]", "distro": "CentOS 8", + "docker_source_image": "centos:8", "ssh_user": "centos", "cloud_user_data": "common-packer/provision/rh-user_data.sh" } diff --git a/vars/ubuntu-16.04.json b/vars/ubuntu-16.04.json index 0c25018..0a4bc8e 100644 --- a/vars/ubuntu-16.04.json +++ b/vars/ubuntu-16.04.json @@ -3,6 +3,7 @@ "source_ami_filter_owner": "099720109477", "base_image": "LF - Ubuntu 16.04 LTS (2019-12-11)", "distro": "Ubuntu 16.04", + "docker_source_image": "ubuntu:16.04", "ssh_user": "ubuntu", "cloud_user_data": "common-packer/provision/ubuntu-user_data.sh" } diff --git a/vars/ubuntu-18.04.json b/vars/ubuntu-18.04.json index 19f03a5..6b5450d 100644 --- a/vars/ubuntu-18.04.json +++ b/vars/ubuntu-18.04.json @@ -3,6 +3,7 @@ "source_ami_filter_owner": "099720109477", "base_image": "LF - Ubuntu 18.04 LTS (2020-07-29)", "distro": "Ubuntu 18.04", + "docker_source_image": "ubuntu:18.04", "ssh_user": "ubuntu", "cloud_user_data": "common-packer/provision/ubuntu-user_data.sh" }