Skip to content

Commit

Permalink
Use ci profile in interop containers (divviup#3084)
Browse files Browse the repository at this point in the history
  • Loading branch information
divergentdave authored May 3, 2024
1 parent cbde9d2 commit c13d457
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ jobs:
with:
files: docker-bake.hcl
workdir: .
targets: interop_binaries_small
targets: interop_binaries_ci

rustsec_advisories:
runs-on: ubuntu-latest
Expand Down
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,7 @@ incremental = false

[profile.small]
# We define a profile intended to minimize the eventual binary size, while still allowing for
# relatively fast compilation. It is intended for use in size-constrained testing scenarios, e.g.
# building a binary artifact that ends up embedded in another binary.
# relatively fast compilation. It is intended for use in size-constrained testing scenarios.
inherits = "dev"
opt-level = "z" # Optimize for size.
debug = false # Do not generate debug info.
Expand Down
51 changes: 47 additions & 4 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ group "interop_binaries_small" {
]
}

group "interop_binaries_ci" {
targets = [
"janus_interop_client_ci",
"janus_interop_aggregator_ci",
"janus_interop_collector_ci",
]
}

target "janus_aggregator" {
args = {
GIT_REVISION = "${GIT_REVISION}"
Expand Down Expand Up @@ -280,10 +288,6 @@ target "janus_interop_collector_release" {
]
}

# These targets should match the `docker build` commands run in the
# janus_interop_binaries build script. They are run separately in CI for
# caching purposes.

target "janus_interop_client_small" {
args = {
PROFILE = "small"
Expand Down Expand Up @@ -322,3 +326,42 @@ target "janus_interop_collector_small" {
]
dockerfile = "Dockerfile.interop"
}

target "janus_interop_client_ci" {
args = {
PROFILE = "ci"
BINARY = "janus_interop_client"
}
cache-from = [
"type=gha,scope=main-interop-ci",
"type=gha,scope=${GITHUB_BASE_REF}-interop-ci",
"type=gha,scope=${GITHUB_REF_NAME}-interop-ci",
]
dockerfile = "Dockerfile.interop"
}

target "janus_interop_aggregator_ci" {
args = {
PROFILE = "ci"
}
cache-from = [
"type=gha,scope=main-interop-ci",
"type=gha,scope=${GITHUB_BASE_REF}-interop-ci",
"type=gha,scope=${GITHUB_REF_NAME}-interop-ci",
]
cache-to = ["type=gha,scope=${GITHUB_REF_NAME}-interop-ci,mode=max,ignore-error=true"]
dockerfile = "Dockerfile.interop_aggregator"
}

target "janus_interop_collector_ci" {
args = {
PROFILE = "ci"
BINARY = "janus_interop_collector"
}
cache-from = [
"type=gha,scope=main-interop-ci",
"type=gha,scope=${GITHUB_BASE_REF}-interop-ci",
"type=gha,scope=${GITHUB_REF_NAME}-interop-ci",
]
dockerfile = "Dockerfile.interop"
}
14 changes: 7 additions & 7 deletions xtask/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ fn build_container_images() -> Result<ContainerImages> {
.args([
"buildx",
"bake",
"interop_binaries_small",
"interop_binaries_ci",
"--load",
"--metadata-file",
])
Expand All @@ -103,18 +103,18 @@ fn build_container_images() -> Result<ContainerImages> {
let metadata: HashMap<String, DockerBakeTargetMetadata> = serde_json::from_reader(file)?;

let client = metadata
.get("janus_interop_client_small")
.context("missing metadata for janus_interop_client_small")?
.get("janus_interop_client_ci")
.context("missing metadata for janus_interop_client_ci")?
.digest
.clone();
let aggregator = metadata
.get("janus_interop_aggregator_small")
.context("missing metadata for janus_interop_aggregator_small")?
.get("janus_interop_aggregator_ci")
.context("missing metadata for janus_interop_aggregator_ci")?
.digest
.clone();
let collector = metadata
.get("janus_interop_collector_small")
.context("missing metadata for janus_interop_collector_small")?
.get("janus_interop_collector_ci")
.context("missing metadata for janus_interop_collector_ci")?
.digest
.clone();

Expand Down

0 comments on commit c13d457

Please sign in to comment.