diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f6e75818b..469b13c48 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -357,6 +357,8 @@ jobs: strategy: matrix: arch: ["arm", "arm64", "386", "amd64"] + outputs: + name: docker.io/hashicorppreview/${{ env.repo }}:${{ env.minor-version }}-dev-${{ github.sha }} env: repo: ${{ github.event.repository.name }} version: ${{ needs.set-product-version.outputs.product-version }} @@ -394,6 +396,8 @@ jobs: with: artifact-name: "boundary_${{ needs.set-product-version.outputs.product-version }}_linux_amd64.zip" go-version: ${{ needs.product-metadata.outputs.go-version }} + docker-image-name: ${{ needs.build-docker.outputs.name }} + docker-image-file: "boundary_default_linux_amd64_${{ needs.set-product-version.outputs.product-version }}_${{ github.sha }}.docker.dev.tar" secrets: inherit bats: diff --git a/.github/workflows/enos-run.yml b/.github/workflows/enos-run.yml index 600ffe4c4..36aa3e822 100644 --- a/.github/workflows/enos-run.yml +++ b/.github/workflows/enos-run.yml @@ -12,6 +12,12 @@ on: go-version: required: true type: string + docker-image-name: + required: false + type: string + docker-image-file: + required: false + type: string env: PKG_NAME: boundary @@ -174,6 +180,17 @@ jobs: run: | unzip ${{steps.download.outputs.download-path}}/*.zip -d enos/support/boundary mv ${{steps.download.outputs.download-path}}/*.zip enos/support/boundary.zip + - name: Download Boundary Linux AMD64 docker image + if: matrix.filter == 'e2e_docker builder:crt' + uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2 + id: download-docker + with: + name: ${{ inputs.docker-image-file }} + path: ./enos/support/downloads + - name: Rename docker image file + if: matrix.filter == 'e2e_docker builder:crt' + run: | + mv ${{ steps.download-docker.outputs.download-path }}/*.tar enos/support/boundary_docker_image.tar - name: Set up Node.js uses: actions/setup-node@v3 if: matrix.filter == 'e2e_ui builder:crt' @@ -203,6 +220,8 @@ jobs: ENOS_VAR_crt_bundle_path: ./support/boundary.zip ENOS_VAR_tfc_api_token: ${{ secrets.TF_API_TOKEN }} ENOS_VAR_test_email: ${{ secrets.SERVICE_USER_EMAIL }} + ENOS_VAR_boundary_docker_image_name: ${{ inputs.docker-image-name }} + ENOS_VAR_boundary_docker_image_file: ./support/boundary_docker_image.tar run: | mkdir -p ./enos/terraform-plugin-cache export ENOS_VAR_enos_user=$GITHUB_ACTOR && \ @@ -221,6 +240,8 @@ jobs: ENOS_VAR_crt_bundle_path: ./support/boundary.zip ENOS_VAR_tfc_api_token: ${{ secrets.TF_API_TOKEN }} ENOS_VAR_test_email: ${{ secrets.SERVICE_USER_EMAIL }} + ENOS_VAR_boundary_docker_image_name: ${{ inputs.docker-image-name }} + ENOS_VAR_boundary_docker_image_file: ./support/boundary_docker_image.tar run: | mkdir -p ./enos/terraform-plugin-cache export ENOS_VAR_enos_user=$GITHUB_ACTOR && \ @@ -250,6 +271,8 @@ jobs: ENOS_VAR_crt_bundle_path: ./support/boundary.zip ENOS_VAR_tfc_api_token: ${{ secrets.TF_API_TOKEN }} ENOS_VAR_test_email: ${{ secrets.SERVICE_USER_EMAIL }} + ENOS_VAR_boundary_docker_image_name: ${{ inputs.docker-image-name }} + ENOS_VAR_boundary_docker_image_file: ./support/boundary_docker_image.tar run: | export ENOS_VAR_enos_user=$GITHUB_ACTOR && \ enos scenario run --timeout 60m0s --chdir ./enos ${{ matrix.filter }} @@ -264,6 +287,8 @@ jobs: ENOS_VAR_crt_bundle_path: ./support/boundary.zip ENOS_VAR_tfc_api_token: ${{ secrets.TF_API_TOKEN }} ENOS_VAR_test_email: ${{ secrets.SERVICE_USER_EMAIL }} + ENOS_VAR_boundary_docker_image_name: ${{ inputs.docker-image-name }} + ENOS_VAR_boundary_docker_image_file: ./support/boundary_docker_image.tar run: | export ENOS_VAR_enos_user=$GITHUB_ACTOR && \ enos scenario destroy --timeout 60m0s --chdir ./enos ${{ matrix.filter }} diff --git a/Makefile b/Makefile index ec30eefb8..608cf7193 100644 --- a/Makefile +++ b/Makefile @@ -325,7 +325,7 @@ REGISTRY_NAME?=docker.io/hashicorp IMAGE_NAME=boundary VERSION?=0.7.4 IMAGE_TAG=$(REGISTRY_NAME)/$(IMAGE_NAME):$(VERSION) -IMAGE_TAG_DEV=$(REGISTRY_NAME)/$(IMAGE_NAME):latest-$(shell git rev-parse --short HEAD) +IMAGE_TAG_DEV?=$(REGISTRY_NAME)/$(IMAGE_NAME):latest-$(shell git rev-parse --short HEAD) .PHONY: docker docker: docker-build diff --git a/enos/enos-modules.hcl b/enos/enos-modules.hcl index 913777ee3..99183838f 100644 --- a/enos/enos-modules.hcl +++ b/enos/enos-modules.hcl @@ -36,6 +36,14 @@ module "build_local" { build_target = var.local_build_target } +module "build_boundary_docker_crt" { + source = "./modules/build_boundary_docker_crt" +} + +module "build_boundary_docker_local" { + source = "./modules/build_boundary_docker_local" +} + module "generate_aws_host_tag_vars" { source = "./modules/generate_aws_host_tag_vars" } diff --git a/enos/enos-scenario-e2e-docker.hcl b/enos/enos-scenario-e2e-docker.hcl index fe121e36a..71e3fcb8d 100644 --- a/enos/enos-scenario-e2e-docker.hcl +++ b/enos/enos-scenario-e2e-docker.hcl @@ -12,9 +12,18 @@ scenario "e2e_docker" { provider.enos.default ] + matrix { + builder = ["local", "crt"] + } + locals { - aws_ssh_private_key_path = abspath(var.aws_ssh_private_key_path) - local_boundary_dir = abspath(var.local_boundary_dir) + aws_ssh_private_key_path = abspath(var.aws_ssh_private_key_path) + local_boundary_dir = abspath(var.local_boundary_dir) + boundary_docker_image_file = abspath(var.boundary_docker_image_file) + build_path = { + "local" = "/tmp", + "crt" = var.crt_bundle_path == null ? null : abspath(var.crt_bundle_path) + } tags = merge({ "Project Name" : var.project_name "Project" : "Enos", @@ -22,6 +31,14 @@ scenario "e2e_docker" { }, var.tags) } + step "build_boundary_docker_image" { + module = matrix.builder == "crt" ? module.build_boundary_docker_crt : module.build_boundary_docker_local + + variables { + path = matrix.builder == "crt" ? local.boundary_docker_image_file : "/tmp/boundary_docker_image.tar" + } + } + step "create_docker_network" { module = module.docker_network } @@ -31,6 +48,7 @@ scenario "e2e_docker" { step.create_docker_network ] variables { + image_name = "docker.mirror.hashicorp.services/library/postgres:latest" network_name = step.create_docker_network.network_name } module = module.docker_postgres @@ -40,10 +58,11 @@ scenario "e2e_docker" { module = module.docker_boundary depends_on = [ step.create_docker_network, - step.create_boundary_database + step.create_boundary_database, + step.build_boundary_docker_image ] variables { - image_name = var.boundary_docker_image + image_name = matrix.builder == "crt" ? var.boundary_docker_image_name : step.build_boundary_docker_image.image_name network_name = step.create_docker_network.network_name postgres_address = step.create_boundary_database.address } @@ -55,7 +74,7 @@ scenario "e2e_docker" { step.create_docker_network ] variables { - image_name = "docker.io/hashicorp/vault:${var.vault_version}" + image_name = "docker.mirror.hashicorp.services/hashicorp/vault:${var.vault_version}" network_name = step.create_docker_network.network_name } } @@ -66,6 +85,7 @@ scenario "e2e_docker" { step.create_docker_network ] variables { + image_name = "docker.mirror.hashicorp.services/linuxserver/openssh-server" network_name = step.create_docker_network.network_name private_key_file_path = local.aws_ssh_private_key_path } diff --git a/enos/enos-variables.hcl b/enos/enos-variables.hcl index 91f7cde80..0ca1c3fc9 100644 --- a/enos/enos-variables.hcl +++ b/enos/enos-variables.hcl @@ -25,12 +25,18 @@ variable "enos_user" { } # Test configs -variable "boundary_docker_image" { - description = "Name of Docker Image to use" +variable "boundary_docker_image_name" { + description = "Name:Tag of Docker image to use" type = string default = "docker.io/hashicorp/boundary:latest" } +variable "boundary_docker_image_file" { + description = "Path to Boundary Docker image" + type = string + default = "" +} + variable "worker_instance_type" { description = "EC2 Instance type" type = string diff --git a/enos/modules/build_boundary_docker_crt/main.tf b/enos/modules/build_boundary_docker_crt/main.tf new file mode 100644 index 000000000..d079570ed --- /dev/null +++ b/enos/modules/build_boundary_docker_crt/main.tf @@ -0,0 +1,19 @@ +# Copyright (c) HashiCorp, Inc. +# SPDX-License-Identifier: MPL-2.0 + +terraform { + required_providers { + enos = { + source = "app.terraform.io/hashicorp-qti/enos" + } + } +} + +variable "path" { + description = "Path of boundary docker image file to load" + type = string +} + +resource "enos_local_exec" "load_docker_image" { + inline = ["docker load -i ${var.path}"] +} diff --git a/enos/modules/build_boundary_docker_local/build.sh b/enos/modules/build_boundary_docker_local/build.sh new file mode 100644 index 000000000..77e54c5cf --- /dev/null +++ b/enos/modules/build_boundary_docker_local/build.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash +# Copyright (c) HashiCorp, Inc. +# SPDX-License-Identifier: MPL-2.0 + +set -eux -o pipefail + +# Go to the root of the boundary repo +root_dir="$(git rev-parse --show-toplevel)" +pushd "${root_dir}" > /dev/null + +export IMAGE_TAG_DEV="${IMAGE_NAME}" +make docker-build-dev + +popd > /dev/null diff --git a/enos/modules/build_boundary_docker_local/main.tf b/enos/modules/build_boundary_docker_local/main.tf new file mode 100644 index 000000000..d5d3fa818 --- /dev/null +++ b/enos/modules/build_boundary_docker_local/main.tf @@ -0,0 +1,39 @@ +# Copyright (c) HashiCorp, Inc. +# SPDX-License-Identifier: MPL-2.0 + +terraform { + required_providers { + enos = { + source = "app.terraform.io/hashicorp-qti/enos" + } + } +} + +variable "path" { + description = "File Path of boundary docker image that will be created" + type = string + default = "/tmp/boundary_docker_image.tar" +} + +resource "enos_local_exec" "get_git_sha" { + inline = ["git rev-parse --short HEAD"] +} + +locals { + image_name = trimspace("docker.io/hashicorp/boundary-dev:latest-${enos_local_exec.get_git_sha.stdout}") +} + +resource "enos_local_exec" "build_docker_image" { + environment = { + "IMAGE_NAME" = local.image_name + } + scripts = ["${path.module}/build.sh"] +} + +output "artifact_path" { + value = var.path +} + +output "image_name" { + value = local.image_name +} diff --git a/enos/modules/docker_openssh_server/main.tf b/enos/modules/docker_openssh_server/main.tf index 3b201233e..b1b7b41dd 100644 --- a/enos/modules/docker_openssh_server/main.tf +++ b/enos/modules/docker_openssh_server/main.tf @@ -15,6 +15,11 @@ terraform { } } +variable "image_name" { + description = "Name of Docker Image" + type = string + default = "docker.mirror.hashicorp.services/linuxserver/openssh-server" +} variable "network_name" { description = "Name of Docker Network" type = string @@ -43,7 +48,7 @@ locals { } resource "docker_image" "openssh_server" { - name = "lscr.io/linuxserver/openssh-server" + name = var.image_name keep_locally = true } diff --git a/enos/modules/docker_postgres/main.tf b/enos/modules/docker_postgres/main.tf index ed2d31785..61ecbdb5c 100644 --- a/enos/modules/docker_postgres/main.tf +++ b/enos/modules/docker_postgres/main.tf @@ -10,6 +10,11 @@ terraform { } } +variable "image_name" { + description = "Name of Docker Image" + type = string + default = "docker.mirror.hashicorp.services/library/postgres:latest" +} variable "network_name" { description = "Name of Docker Network" type = string @@ -36,7 +41,7 @@ variable "database_name" { } resource "docker_image" "postgres" { - name = "postgres:latest" + name = var.image_name keep_locally = true }