Skip to content

Commit 4fcc1f3

Browse files
authored
Merge pull request #1239 from buildkite/pdp-1831-packer-builds-on-windows-fail-bc-docker-requires-a-restart
2 parents f491078 + ae3f2ac commit 4fcc1f3

11 files changed

+275
-164
lines changed

.buildkite/pipeline.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ steps:
2626
name: ":go: fixperms build"
2727
agents:
2828
queue: "${BUILDKITE_AGENT_META_DATA_QUEUE}"
29-
depends_on:
30-
- "fixperms-tests"
3129
artifact_paths: "build/fix-perms-*"
3230
plugins:
3331
- docker-compose#v2.1.0:

Makefile

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,26 @@
33
VERSION = $(shell git describe --tags --candidates=1)
44
SHELL = /bin/bash -o pipefail
55

6-
PACKER_VERSION ?= 1.8.6
6+
PACKER_VERSION ?= 1.9.4
77
PACKER_LINUX_FILES = $(exec find packer/linux)
88
PACKER_WINDOWS_FILES = $(exec find packer/windows)
99

1010
AWS_REGION ?= us-east-1
1111

12-
ARM64_INSTANCE_TYPE = m6g.xlarge
13-
AMD64_INSTANCE_TYPE = c5.xlarge
12+
ARM64_INSTANCE_TYPE = m7g.xlarge
13+
AMD64_INSTANCE_TYPE = m7a.xlarge
14+
WIN64_INSTANCE_TYPE = m7i.xlarge
15+
16+
BUILDKITE_BUILD_NUMBER ?= none
17+
BUILDKITE_PIPELINE_DEFAULT_BRANCH ?= main
18+
19+
IS_RELEASED ?= false
20+
ifeq ($(BUILDKITE_BRANCH),$(BUILDKITE_PIPELINE_DEFAULT_BRANCH))
21+
IS_RELEASED = true
22+
endif
23+
ifeq ($(BUILDKITE_BRANCH),$(BUILDKITE_TAG))
24+
IS_RELEASED = true
25+
endif
1426

1527
all: packer build
1628

@@ -87,9 +99,13 @@ packer-linux-amd64.output: $(PACKER_LINUX_FILES)
8799
-v "$(PWD):/src" \
88100
--rm \
89101
-w /src/packer/linux \
90-
hashicorp/packer:$(PACKER_VERSION) build -timestamp-ui -var 'region=$(AWS_REGION)' \
91-
-var 'arch=x86_64' -var 'goarch=amd64' -var 'instance_type=$(AMD64_INSTANCE_TYPE)' \
92-
buildkite-ami.json | tee $@
102+
hashicorp/packer:full-$(PACKER_VERSION) build -timestamp-ui \
103+
-var 'region=$(AWS_REGION)' \
104+
-var 'arch=x86_64' \
105+
-var 'instance_type=$(AMD64_INSTANCE_TYPE)' \
106+
-var 'build_number=$(BUILDKITE_BUILD_NUMBER)' \
107+
-var 'is_released=$(IS_RELEASED)' \
108+
buildkite-ami.pkr.hcl | tee $@
93109

94110
build/linux-arm64-ami.txt: packer-linux-arm64.output env-AWS_REGION
95111
mkdir -p build
@@ -108,9 +124,13 @@ packer-linux-arm64.output: $(PACKER_LINUX_FILES)
108124
-v "$(PWD):/src" \
109125
--rm \
110126
-w /src/packer/linux \
111-
hashicorp/packer:$(PACKER_VERSION) build -timestamp-ui -var 'region=$(AWS_REGION)' \
112-
-var 'arch=arm64' -var 'goarch=arm64' -var 'instance_type=$(ARM64_INSTANCE_TYPE)' \
113-
buildkite-ami.json | tee $@
127+
hashicorp/packer:full-$(PACKER_VERSION) build -timestamp-ui \
128+
-var 'region=$(AWS_REGION)' \
129+
-var 'arch=arm64' \
130+
-var 'instance_type=$(ARM64_INSTANCE_TYPE)' \
131+
-var 'build_number=$(BUILDKITE_BUILD_NUMBER)' \
132+
-var 'is_released=$(IS_RELEASED)' \
133+
buildkite-ami.pkr.hcl | tee $@
114134

115135
build/windows-amd64-ami.txt: packer-windows-amd64.output env-AWS_REGION
116136
mkdir -p build
@@ -129,8 +149,13 @@ packer-windows-amd64.output: $(PACKER_WINDOWS_FILES)
129149
-v "$(PWD):/src" \
130150
--rm \
131151
-w /src/packer/windows \
132-
hashicorp/packer:$(PACKER_VERSION) build -timestamp-ui -var 'region=$(AWS_REGION)' \
133-
buildkite-ami.json | tee $@
152+
hashicorp/packer:full-$(PACKER_VERSION) build -timestamp-ui \
153+
-var 'region=$(AWS_REGION)' \
154+
-var 'arch=x86_64' \
155+
-var 'instance_type=$(WIN64_INSTANCE_TYPE)' \
156+
-var 'build_number=$(BUILDKITE_BUILD_NUMBER)' \
157+
-var 'is_released=$(IS_RELEASED)' \
158+
buildkite-ami.pkr.hcl | tee $@
134159

135160
# -----------------------------------------
136161
# Cloudformation helpers

packer/linux/buildkite-ami.json

Lines changed: 0 additions & 64 deletions
This file was deleted.

packer/linux/buildkite-ami.pkr.hcl

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
packer {
2+
required_plugins {
3+
amazon = {
4+
source = "github.com/hashicorp/amazon"
5+
version = "~> 1"
6+
}
7+
}
8+
}
9+
10+
variable "arch" {
11+
type = string
12+
default = "x86_64"
13+
}
14+
15+
variable "instance_type" {
16+
type = string
17+
default = "m7a.xlarge"
18+
}
19+
20+
variable "region" {
21+
type = string
22+
default = "us-east-1"
23+
}
24+
25+
variable "build_number" {
26+
type = string
27+
default = "none"
28+
}
29+
30+
variable "is_released" {
31+
type = bool
32+
default = false
33+
}
34+
35+
data "amazon-ami" "al2023" {
36+
filters = {
37+
architecture = var.arch
38+
name = "al2023-ami-minimal-*"
39+
virtualization-type = "hvm"
40+
}
41+
most_recent = true
42+
owners = ["amazon"]
43+
region = var.region
44+
}
45+
46+
source "amazon-ebs" "elastic-ci-stack-ami" {
47+
ami_description = "Buildkite Elastic Stack (Amazon Linux 2023 w/ docker)"
48+
ami_groups = ["all"]
49+
ami_name = "buildkite-stack-linux-${var.arch}-${replace(timestamp(), ":", "-")}"
50+
instance_type = var.instance_type
51+
region = var.region
52+
source_ami = data.amazon-ami.al2023.id
53+
ssh_username = "ec2-user"
54+
55+
tags = {
56+
Name = "elastic-ci-stack-linux-${var.arch}"
57+
OSVersion = "Amazon Linux 2023"
58+
BuildNumber = var.build_number
59+
IsReleased = var.is_released
60+
SourceAMIID = data.amazon-ami.al2023.id
61+
SourceAMIName = data.amazon-ami.al2023.name
62+
}
63+
}
64+
65+
build {
66+
sources = ["source.amazon-ebs.elastic-ci-stack-ami"]
67+
68+
provisioner "file" {
69+
destination = "/tmp"
70+
source = "conf"
71+
}
72+
73+
provisioner "file" {
74+
destination = "/tmp/plugins"
75+
source = "../../plugins"
76+
}
77+
78+
provisioner "shell" {
79+
script = "scripts/install-utils.sh"
80+
}
81+
82+
provisioner "shell" {
83+
script = "scripts/install-cloudwatch-agent.sh"
84+
}
85+
86+
provisioner "shell" {
87+
script = "scripts/install-docker.sh"
88+
}
89+
90+
provisioner "shell" {
91+
script = "scripts/install-buildkite-agent.sh"
92+
}
93+
94+
provisioner "shell" {
95+
script = "scripts/install-buildkite-utils.sh"
96+
}
97+
98+
provisioner "shell" {
99+
inline = ["rm /home/ec2-user/.ssh/authorized_keys"]
100+
}
101+
}

packer/windows/buildkite-ami.json

Lines changed: 0 additions & 79 deletions
This file was deleted.

0 commit comments

Comments
 (0)