Skip to content

Commit dd3bb82

Browse files
authored
Merge pull request #1578 from buildkite/fix/base_image
2 parents 2379776 + 7352abb commit dd3bb82

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

.buildkite/steps/packer.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,13 @@ packer_files_sha=$(find Makefile "packer/${os}" plugins/ -type f -print0 | xargs
2222
internal_files_sha=$(find go.mod go.sum internal/ -type f -print0 | xargs -0 sha256sum | awk '{print $1}' | sort | sha256sum | awk '{print $1}')
2323
stable_agent_sha=$(curl -Lfs "https://download.buildkite.com/agent/stable/latest/${agent_binary}.sha256")
2424
unstable_agent_sha=$(curl -Lfs "https://download.buildkite.com/agent/unstable/latest/${agent_binary}.sha256")
25-
packer_hash=$(echo "$packer_files_sha" "$internal_files_sha" "$arch" "$stable_agent_sha" "$unstable_agent_sha" "$variant" | sha256sum | awk '{print $1}')
25+
if [[ "${variant}" == "base" ]]; then
26+
# Base AMI doesn't use Go dependencies
27+
packer_hash=$(echo "$packer_files_sha" "$arch" "$stable_agent_sha" "$unstable_agent_sha" "$variant" | sha256sum | awk '{print $1}')
28+
else
29+
# Full AMI includes Go dependencies for fix-perms binary
30+
packer_hash=$(echo "$packer_files_sha" "$internal_files_sha" "$arch" "$stable_agent_sha" "$unstable_agent_sha" "$variant" | sha256sum | awk '{print $1}')
31+
fi
2632

2733
# Include variant in the hash so base and full images don’t clash
2834
echo "Packer image hash for ${os}/${arch} (${variant}) is ${packer_hash}"
@@ -46,7 +52,8 @@ if [[ -n "${PACKER_REBUILD:-}" ]] || ! aws s3 cp "s3://${BUILDKITE_AWS_STACK_BUC
4652
echo "Base AMI ID not found in metadata, checking S3 for latest base image..."
4753

4854
# Calculate hash for base image to find the S3 file
49-
base_packer_hash=$(echo "$packer_files_sha" "$internal_files_sha" "$arch" "$stable_agent_sha" "$unstable_agent_sha" "base" | sha256sum | awk '{print $1}')
55+
# Base AMI doesn't include Go dependencies, so exclude them from hash
56+
base_packer_hash=$(echo "$packer_files_sha" "$arch" "$stable_agent_sha" "$unstable_agent_sha" "base" | sha256sum | awk '{print $1}')
5057
base_packer_file="packer-${base_packer_hash}-${os}-${arch}-base.output"
5158

5259
# Try to download and extract AMI ID from the base image packer output

packer/linux/base.pkr.hcl

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,6 @@ build {
9191
source = "../../plugins"
9292
}
9393

94-
provisioner "file" {
95-
destination = "/tmp/build"
96-
source = "../../build"
97-
}
98-
9994
# Essential utilities & updates
10095
provisioner "shell" {
10196
script = "scripts/install-utils.sh"

0 commit comments

Comments
 (0)