Add support for a Docker builder 91/65091/6
authorThanh Ha <zxiiro@gmail.com>
Fri, 14 Aug 2020 14:23:29 +0000 (10:23 -0400)
committerThanh Ha <zxiiro@gmail.com>
Sun, 11 Apr 2021 01:34:13 +0000 (21:34 -0400)
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 <zxiiro@gmail.com>
releasenotes/notes/docker-support-c04bf0df10c15c00.yaml [new file with mode: 0644]
templates/builder.json
templates/docker.json
vars/centos-7.json
vars/centos-8.json
vars/ubuntu-16.04.json
vars/ubuntu-18.04.json

diff --git a/releasenotes/notes/docker-support-c04bf0df10c15c00.yaml b/releasenotes/notes/docker-support-c04bf0df10c15c00.yaml
new file mode 100644 (file)
index 0000000..71e15ff
--- /dev/null
@@ -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
index f4ca2f9..0fa217d 100644 (file)
@@ -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": ""
       "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": [
index 2254dd2..c4699b0 100644 (file)
@@ -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": ""
       "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": [
index efdd3b5..cec0955 100644 (file)
@@ -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"
 }
index bd82e9d..1042cb2 100644 (file)
@@ -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"
 }
index 0c25018..0a4bc8e 100644 (file)
@@ -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"
 }
index 19f03a5..6b5450d 100644 (file)
@@ -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"
 }