-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(clusters): add pegboard pool (#1153)
<!-- Please make sure there is an issue that this PR is correlated to. --> ## Changes <!-- If there are frontend changes, please include screenshots. -->
- Loading branch information
1 parent
b4a1d16
commit bffa76f
Showing
60 changed files
with
1,240 additions
and
278 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
locals { | ||
container_runner_src_dir = "${path.module}/../../../lib/container-runner" | ||
|
||
container_runner_src_files = flatten([ | ||
["${local.container_runner_src_dir}/Cargo.toml", "${local.container_runner_src_dir}/Cargo.lock"], | ||
[for f in fileset("${local.container_runner_src_dir}/src/", "**/*"): "${local.container_runner_src_dir}/src/${f}"], | ||
]) | ||
container_runner_src_hash = md5(join("", [ | ||
for f in local.container_runner_src_files: filemd5(f) | ||
])) | ||
container_runner_dst_binary_path = "/tmp/container-runner-${local.container_runner_src_hash}" | ||
} | ||
|
||
resource "null_resource" "container_runner_build" { | ||
triggers = { | ||
container_runner_src_hash = local.container_runner_src_hash | ||
container_runner_dst_binary_path = local.container_runner_dst_binary_path | ||
} | ||
|
||
provisioner "local-exec" { | ||
command = <<-EOT | ||
#!/bin/bash | ||
set -euf | ||
# Variables | ||
IMAGE_NAME="container-runner:${local.container_runner_src_hash}" | ||
CONTAINER_NAME="temp-container-runner-${local.container_runner_src_hash}" | ||
BINARY_PATH_IN_CONTAINER="/app/target/x86_64-unknown-linux-musl/release/container-runner" | ||
DST_BINARY_PATH="${local.container_runner_dst_binary_path}" | ||
# Build the Docker image | ||
docker build --platform linux/amd64 -t $IMAGE_NAME '${local.container_runner_src_dir}' | ||
# Create a temporary container | ||
docker create --name $CONTAINER_NAME $IMAGE_NAME | ||
# Copy the binary from the container to the host | ||
docker cp $CONTAINER_NAME:$BINARY_PATH_IN_CONTAINER $DST_BINARY_PATH | ||
# Remove the temporary container | ||
docker rm $CONTAINER_NAME | ||
EOT | ||
} | ||
} | ||
|
||
resource "aws_s3_object" "container_runner_binary_upload" { | ||
depends_on = [null_resource.container_runner_build] | ||
|
||
lifecycle { | ||
prevent_destroy = true | ||
} | ||
|
||
bucket = "${var.namespace}-bucket-infra-artifacts" | ||
key = "container-runner/${local.container_runner_src_hash}/container-runner" | ||
source = local.container_runner_dst_binary_path | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
locals { | ||
pegboard_manager_src_dir = "${path.module}/../../../lib/pegboard-manager" | ||
|
||
pegboard_manager_src_files = flatten([ | ||
["${local.pegboard_manager_src_dir}/Cargo.toml", "${local.pegboard_manager_src_dir}/Cargo.lock"], | ||
[for f in fileset("${local.pegboard_manager_src_dir}/src/", "**/*"): "${local.pegboard_manager_src_dir}/src/${f}"], | ||
]) | ||
pegboard_manager_src_hash = md5(join("", [ | ||
for f in local.pegboard_manager_src_files: filemd5(f) | ||
])) | ||
pegboard_manager_dst_binary_path = "/tmp/pegboard-manager-${local.pegboard_manager_src_hash}" | ||
} | ||
|
||
resource "null_resource" "pegboard_manager_build" { | ||
triggers = { | ||
pegboard_manager_src_hash = local.pegboard_manager_src_hash | ||
pegboard_manager_dst_binary_path = local.pegboard_manager_dst_binary_path | ||
} | ||
|
||
provisioner "local-exec" { | ||
command = <<-EOT | ||
#!/bin/bash | ||
set -euf | ||
# Variables | ||
IMAGE_NAME="pegboard-manager:${local.pegboard_manager_src_hash}" | ||
CONTAINER_NAME="temp-pegboard-manager-${local.pegboard_manager_src_hash}" | ||
BINARY_PATH_IN_CONTAINER="/app/target/x86_64-unknown-linux-musl/release/pegboard-manager" | ||
DST_BINARY_PATH="${local.pegboard_manager_dst_binary_path}" | ||
# Build the Docker image | ||
docker build --platform linux/amd64 -t $IMAGE_NAME '${local.pegboard_manager_src_dir}' | ||
# Create a temporary container | ||
docker create --name $CONTAINER_NAME $IMAGE_NAME | ||
# Copy the binary from the container to the host | ||
docker cp $CONTAINER_NAME:$BINARY_PATH_IN_CONTAINER $DST_BINARY_PATH | ||
# Remove the temporary container | ||
docker rm $CONTAINER_NAME | ||
EOT | ||
} | ||
} | ||
|
||
resource "aws_s3_object" "pegboard_manager_binary_upload" { | ||
depends_on = [null_resource.pegboard_manager_build] | ||
|
||
lifecycle { | ||
prevent_destroy = true | ||
} | ||
|
||
bucket = "${var.namespace}-bucket-infra-artifacts" | ||
key = "pegboard-manager/${local.pegboard_manager_src_hash}/pegboard-manager" | ||
source = local.pegboard_manager_dst_binary_path | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.