Skip to content

Commit

Permalink
Clean up local yawollet image build (#409)
Browse files Browse the repository at this point in the history
* fix build-yawollet-image to use target platform

* Allow setting `PACKER_GITHUB_API_TOKEN`

When developing and performing many builds, one might be required to set a GitHub API token in packer
for resolving rate limits.

* Drop unsupported terraform config fields

* Drop unneeded terraform provider

* Simplify yawollet image build
  • Loading branch information
timebertt authored Sep 10, 2024
1 parent 3d4b76e commit 0d2cf21
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
10 changes: 7 additions & 3 deletions Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ validate-yawollet-image:
build-yawollet-image:
FROM +packer

ARG USEROS
ARG USERARCH
ARG TARGETOS
ARG TARGETARCH

ARG MACHINE_FLAVOR=c1.2
ARG VOLUME_TYPE=storage_premium_perf6
Expand All @@ -127,7 +127,7 @@ build-yawollet-image:

COPY +get-envoy/envoy out/envoy/envoy
COPY +get-envoy/envoylibs out/envoy/lib
COPY (+build/controller --CONTROLLER=yawollet --GOOS=$USEROS --GOARCH=$USERARCH) out/yawollet
COPY (+build/controller --CONTROLLER=yawollet --GOOS=$TARGETOS --GOARCH=$TARGETARCH) out/yawollet
COPY +set-version/VERSION .

COPY image image
Expand Down Expand Up @@ -337,6 +337,10 @@ golangci-lint:

packer:
FROM hashicorp/packer:$PACKER_VERSION

# set this env var to get higher GitHub API requests
ARG PACKER_GITHUB_API_TOKEN

RUN packer plugins install github.com/hashicorp/openstack
RUN apk add ansible
RUN apk add openssh-client
Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,8 @@ earthly +destroy-packer-environment \
Before running our `Earthly` targets, set the needed environment variables:

```shell
export OS_NETWORK_ID=<from your openstack environment>
export OS_FLOATING_NETWORK_ID=<from your openstack environment>
export OS_SECURITY_GROUP_ID=<from your openstack environment>
# set OS_NETWORK_ID, OS_FLOATING_NETWORK_ID, OS_SECURITY_GROUP_ID from terraform state
source <(jq -r '.outputs | del(.OS_SOURCE_IMAGE) | keys[] as $k | "export \($k)=\(.[$k].value)"' hack/packer-infrastructure/terraform.tfstate)
export OS_SOURCE_IMAGE=<from your openstack environment>
export IMAGE_VISIBILITY=<private or public>
```
Expand All @@ -103,7 +102,7 @@ earthly +validate-yawollet-image
```

```shell
earthly +build-yawollet-image \
earthly --platform=linux/amd64 +build-yawollet-image \
--OS_NETWORK_ID="$OS_NETWORK_ID" \
--OS_FLOATING_NETWORK_ID="$OS_FLOATING_NETWORK_ID" \
--OS_SECURITY_GROUP_ID="$OS_SECURITY_GROUP_ID" \
Expand Down
8 changes: 1 addition & 7 deletions hack/packer-infrastructure/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,7 @@ terraform {
source = "terraform-provider-openstack/openstack"
version = ">= 1.47"
}
template = {
source = "hashicorp/template"
version = "2.2.0"
}
}
}

provider "openstack" {
use_octavia = false
}
provider "openstack" {}

0 comments on commit 0d2cf21

Please sign in to comment.