diff --git a/.github/workflows/run-samples.yml b/.github/workflows/run-samples.yml index 4371cd6..31e04b2 100644 --- a/.github/workflows/run-samples.yml +++ b/.github/workflows/run-samples.yml @@ -275,6 +275,26 @@ jobs: echo "${YQ_SHA256} yq.exe" | sha256sum --check echo "$RUNNER_TEMP/bin" >> "$GITHUB_PATH" + - name: Install the buildx plugin + # Without buildx, the docker CLI of the Windows runner image builds with the legacy builder. With the + # containerd image store of Docker Engine 29, that builder skips downloading a base image layer whose + # content another image already unpacked, and `docker push` then fails with "content digest ...: not + # found": the emulator image holds the Debian layer of python:3.13-slim under another digest. BuildKit, + # which Docker Desktop and the Linux runner build with, downloads every layer of the image it stores. + # The release and its SHA-256 are pinned. + if: matrix.os == 'windows' + env: + BUILDX_VERSION: v0.38.2 + BUILDX_SHA256: 9a6aca9c84adda0391d1d98d8b74b49359cad1bcdadd196a0a5d7d5dc4cf15e0 + run: | + plugins="${DOCKER_CONFIG:-$HOME/.docker}/cli-plugins" + mkdir -p "$plugins" + cd "$plugins" + curl --silent --show-error --fail --location --retry 3 --output docker-buildx.exe \ + "https://github.com/docker/buildx/releases/download/${BUILDX_VERSION}/buildx-${BUILDX_VERSION}.windows-amd64.exe" + echo "${BUILDX_SHA256} docker-buildx.exe" | sha256sum --check + docker buildx version + - name: Put psql on the PATH # The PostgreSQL and App Configuration samples seed their databases with psql, which comes with the # PostgreSQL the Windows runner image installs off the PATH; the Linux runner image has it on the PATH diff --git a/README.md b/README.md index 67e7ae0..a5fd721 100644 --- a/README.md +++ b/README.md @@ -120,6 +120,11 @@ A name or an ID read from `az ... --output tsv` then carries an invisible `\r`, `set -o igncr` makes these shells drop carriage returns from `$(...)` and `read`, and `export SHELLOPTS` passes the option on to the scripts you start. `mapfile` keeps them even then, so the scripts that fill an array from the Azure CLI strip them with `tr -d '\r'`. +Build the sample images with BuildKit, the builder Docker Desktop uses by default. +A Windows `docker` CLI without the buildx plugin, for example one that drives a Docker Engine in WSL, falls back to the legacy builder. +With the containerd image store of Docker Engine 29, that builder does not download a base image layer whose content another image, such as the emulator's, already unpacked, and `04-push-docker-image.sh` then fails with `content digest sha256:...: not found`. +Install the [buildx plugin](https://github.com/docker/buildx#installing) and build the image again. + Tips: - To apply these settings in every new Git Bash window, add the three lines to `~/.bash_profile`, or to `~/.bashrc` if your `.bash_profile` sources it. diff --git a/terraform/README.md b/terraform/README.md index 4f4a7f0..44c0ac8 100644 --- a/terraform/README.md +++ b/terraform/README.md @@ -45,7 +45,7 @@ The Terraform configuration uses two providers: [azurerm](https://registry.terra | Variable | Value | | -------- | ----- | -| `metadata_host` | `localhost.localstack.cloud:4566`, from which azurerm discovers every endpoint | +| `metadata_host` | The host and port of the Resource Manager endpoint the Azure CLI targets (`azure.localhost.localstack.cloud:4566` with lstk), from which azurerm discovers every endpoint | | `resource_manager_endpoint` | `az cloud show --query endpoints.resourceManager`, for AzAPI, which has no metadata discovery | | `subscription_id`, `tenant_id`, `client_id`, `client_secret` | The emulator's placeholder credentials | | `gateway_api_enabled` | `false`, see [LocalStack emulator notes](#localstack-emulator-notes) | diff --git a/terraform/deploy.sh b/terraform/deploy.sh index e2e9e93..4e92f51 100755 --- a/terraform/deploy.sh +++ b/terraform/deploy.sh @@ -26,7 +26,6 @@ SSH_PUBLIC_KEY_FILE="${SSH_PUBLIC_KEY_FILE:-$HOME/.ssh/id_rsa.pub}" # The windows_admin_password variable reads it from the environment export TF_VAR_windows_admin_password="${WINDOWS_ADMIN_PASSWORD:-Trustno123456!}" EMULATOR_GUID="00000000-0000-0000-0000-000000000000" -EMULATOR_METADATA_HOST="localhost.localstack.cloud:4566" CURRENT_DIR="$(cd "$(dirname "$0")" && pwd)" # Check prerequisites @@ -44,6 +43,10 @@ cd "$CURRENT_DIR" || exit RESOURCE_MANAGER_ENDPOINT=$(az cloud show --query endpoints.resourceManager --output tsv --only-show-errors | tr -d '\r') if [[ $RESOURCE_MANAGER_ENDPOINT == *localhost* || $RESOURCE_MANAGER_ENDPOINT == *localstack* ]]; then IS_EMULATOR=1 + # azurerm discovers every endpoint from the metadata host: the host and port of this endpoint, because the emulator + # serves Azure only on its own Azure host (azure.localhost.localstack.cloud:4566 with lstk), not on localhost.localstack.cloud + EMULATOR_METADATA_HOST=${RESOURCE_MANAGER_ENDPOINT#*://} + EMULATOR_METADATA_HOST=${EMULATOR_METADATA_HOST%%/*} echo "The Azure CLI targets the LocalStack for Azure emulator at [$RESOURCE_MANAGER_ENDPOINT]" else IS_EMULATOR=0 diff --git a/terraform/providers.tf b/terraform/providers.tf index 23a94ea..6dd2399 100644 --- a/terraform/providers.tf +++ b/terraform/providers.tf @@ -17,8 +17,9 @@ terraform { # Dual-target configuration: every identity field defaults to null (Azure CLI auth # against real Azure). deploy.sh passes the LocalStack values when targeting the -# emulator: metadata_host=localhost.localstack.cloud:4566, all-zero GUIDs for -# subscription/tenant/client, and the placeholder client secret. +# emulator: metadata_host=azure.localhost.localstack.cloud:4566 (the host of the +# Azure CLI's Resource Manager endpoint), all-zero GUIDs for subscription/tenant/ +# client, and the placeholder client secret. provider "azurerm" { features { resource_group { diff --git a/tutorials/terraform/tags-labels-taints/deploy.sh b/tutorials/terraform/tags-labels-taints/deploy.sh index 6116b7e..546d234 100755 --- a/tutorials/terraform/tags-labels-taints/deploy.sh +++ b/tutorials/terraform/tags-labels-taints/deploy.sh @@ -23,7 +23,6 @@ GATEWAY_API_ENABLED=1 # the emulator has no global vault-name uniqueness so it keeps the short one. REAL_KEY_VAULT_NAME='local-kv-ciao-local' EMULATOR_KEY_VAULT_NAME='local-kv-test' -EMULATOR_METADATA_HOST='localhost.localstack.cloud:4566' EMULATOR_GUID='00000000-0000-0000-0000-000000000000' AKS_FEATURES=("ManagedGatewayAPIPreview") SSH_KEY_FILE="$HOME/.ssh/id_rsa.pub" @@ -38,6 +37,10 @@ RESOURCE_MANAGER_ENDPOINT=$(az cloud show --query endpoints.resourceManager --ou IS_EMULATOR=0 if [[ "$RESOURCE_MANAGER_ENDPOINT" == *localhost* || "$RESOURCE_MANAGER_ENDPOINT" == *localstack* ]]; then IS_EMULATOR=1 + # azurerm discovers every endpoint from the metadata host: the host and port of this endpoint, because the emulator + # serves Azure only on its own Azure host (azure.localhost.localstack.cloud:4566 with lstk), not on localhost.localstack.cloud + EMULATOR_METADATA_HOST=${RESOURCE_MANAGER_ENDPOINT#*://} + EMULATOR_METADATA_HOST=${EMULATOR_METADATA_HOST%%/*} echo "Detected LocalStack Azure emulator at [$RESOURCE_MANAGER_ENDPOINT]" else echo "Detected real Azure ([$RESOURCE_MANAGER_ENDPOINT])" diff --git a/tutorials/terraform/tags-labels-taints/providers.tf b/tutorials/terraform/tags-labels-taints/providers.tf index 23a94ea..6dd2399 100644 --- a/tutorials/terraform/tags-labels-taints/providers.tf +++ b/tutorials/terraform/tags-labels-taints/providers.tf @@ -17,8 +17,9 @@ terraform { # Dual-target configuration: every identity field defaults to null (Azure CLI auth # against real Azure). deploy.sh passes the LocalStack values when targeting the -# emulator: metadata_host=localhost.localstack.cloud:4566, all-zero GUIDs for -# subscription/tenant/client, and the placeholder client secret. +# emulator: metadata_host=azure.localhost.localstack.cloud:4566 (the host of the +# Azure CLI's Resource Manager endpoint), all-zero GUIDs for subscription/tenant/ +# client, and the placeholder client secret. provider "azurerm" { features { resource_group { diff --git a/tutorials/terraform/tags-labels-taints/variables.tf b/tutorials/terraform/tags-labels-taints/variables.tf index c27baa3..d3b354e 100644 --- a/tutorials/terraform/tags-labels-taints/variables.tf +++ b/tutorials/terraform/tags-labels-taints/variables.tf @@ -1,7 +1,7 @@ # --- Provider / target selection -------------------------------------------------- variable "metadata_host" { - description = "(Optional) Specifies the Azure metadata host. Set to localhost.localstack.cloud:4566 to target the LocalStack emulator; leave null for real Azure." + description = "(Optional) Specifies the Azure metadata host. Set to azure.localhost.localstack.cloud:4566 to target the LocalStack emulator; leave null for real Azure." type = string default = null }