Skip to main content
Aspect Workflows runs Bazel directly on the host machine, not in a container, to avoid Docker-in-Docker complications. Runners therefore use a cloud machine image, not a container image. Aspect publishes open-source starter machine images, but you may need to build a custom image with Packer when:
  • You require tight control over security patches and versions of the OS and packages.
  • The starter images don’t include fixes for every vulnerability you track.
  • Your non-hermetic build or tests require specific system-level packages.

Step 1: Prepare the build machine

  1. Download Packer for your operating system. To have Bazel manage the Packer binary instead, see the starter images repository linked in step 5.
  2. Authenticate with your cloud provider (Amazon Web Services or Google Cloud Platform). Packer needs permission to create EC2 or Compute Engine instances.

Step 2: Choose a base image

AWS

  1. Access the AWS console.
  2. Access the EC2 Dashboard and select AMIs from the left sidebar.
Start with an Amazon-supplied image, for example Amazon Linux 2023 (al2023-ami). See Packer’s Getting Started with AWS for building AMIs.

GCP

  1. Access the GCP console.
  2. Navigate to Compute Engine > Images.
  3. Search for the image that suits your needs, for example debian-13 or ubuntu-2404-lts.
See Packer’s Google Compute Builder for building GCP images.

Step 3: Create a Packer script

Packer scripts use the HashiCorp Configuration Language (HCL), like Terraform, with the .pkr.hcl file extension.
  1. Add the Packer plugin for your cloud provider to your Packer script:
  2. Create a locals block for the values you reuse:
  1. Create a source block and a build block, following the Packer documentation.

Step 4: Dependencies

Minimal dependencies

Every custom machine image needs:

AWS AMI requirements

AWS AMIs also need:
amazon-ssm-agent comes pre-installed on Amazon Linux 2 and Amazon Linux 2023 base AMIs.

GCP image requirements

GCP images also need:

GitHub Actions requirements

Runners for GitHub Actions also need:

Step 5: Add dependencies for your build

Install the packages your build needs, such as Docker, with apt-get or yum depending on your Linux distribution:
The Aspect Workflows starter images repository has complete Packer files and a Bazel setup that runs a hermetic Packer binary.

Step 6: Test a new image

Test image changes on a separate canary runner group before they reach the runners your developers depend on. In your Workflows Terraform configuration:
  1. Add a data "aws_ami" or data "google_compute_image" block that selects the canary image.
  2. Add an entry to resource_types with image_id set to the canary image ID.
  3. Add a runner group under runners (for example in runners.bk.groups) that selects the new resource type.
  4. Run terraform apply.
  5. Point one or more jobs in your CI configuration at the canary runner group’s queue.
To test the new image fully, force a complete, non-incremental build by adding cache-busting environment variables for actions and repository rules to .bazelrc: