Skip to content
This repository has been archived by the owner on Jul 16, 2024. It is now read-only.

Commit

Permalink
Build slim etcd-manager image without etcd binaries
Browse files Browse the repository at this point in the history
  • Loading branch information
hakman committed Jan 13, 2023
1 parent 01ac768 commit 86a6a93
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 4 deletions.
18 changes: 16 additions & 2 deletions etcd-manager/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,20 @@ push-etcd-manager-manifest:
DOCKER_CLI_EXPERIMENTAL=enabled docker manifest push --purge \
$(IMAGE_BASE)etcd-manager:$(STABLE_DOCKER_TAG)

.PHONY: push-etcd-manager-slim
push-etcd-manager-slim:
${BAZEL} run ${BAZEL_FLAGS} --platforms=@io_bazel_rules_go//go/toolchain:linux_amd64 //images:push-etcd-manager-slim
${BAZEL} run ${BAZEL_FLAGS} --platforms=@io_bazel_rules_go//go/toolchain:linux_arm64 //images:push-etcd-manager-slim

.PHONY: push-etcd-manager-slim-manifest
push-etcd-manager-slim-manifest:
DOCKER_CLI_EXPERIMENTAL=enabled docker manifest create \
$(IMAGE_BASE)etcd-manager:$(STABLE_DOCKER_TAG)-slim \
$(IMAGE_BASE)etcd-manager:$(STABLE_DOCKER_TAG)-slim-amd64 \
$(IMAGE_BASE)etcd-manager:$(STABLE_DOCKER_TAG)-slim-arm64
DOCKER_CLI_EXPERIMENTAL=enabled docker manifest push --purge \
$(IMAGE_BASE)etcd-manager:$(STABLE_DOCKER_TAG)-slim

.PHONY: push-etcd-dump
push-etcd-dump:
${BAZEL} run ${BAZEL_FLAGS} --platforms=@io_bazel_rules_go//go/toolchain:linux_amd64 //images:push-etcd-dump
Expand Down Expand Up @@ -86,11 +100,11 @@ push-etcd-backup-manifest:
$(IMAGE_BASE)etcd-backup:$(STABLE_DOCKER_TAG)

.PHONY: push-images
push-images: push-etcd-manager push-etcd-dump push-etcd-backup
push-images: push-etcd-manager push-etcd-manager-slim push-etcd-dump push-etcd-backup
echo "pushed images"

.PHONY: push-manifests
push-manifests: push-etcd-manager-manifest push-etcd-dump-manifest push-etcd-backup-manifest
push-manifests: push-etcd-manager-manifest push-etcd-manager-slim-manifest push-etcd-dump-manifest push-etcd-backup-manifest
echo "pushed manifests"

.PHONY: push
Expand Down
8 changes: 7 additions & 1 deletion etcd-manager/cloudbuild-master.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ steps:
args: ['version']

- name: gcr.io/cloud-builders/bazel
args: ['build', '//cmd/...', '//images:etcd-manager', '//images:etcd-backup', '//images:etcd-dump']
args: ['build', '//cmd/...', '//images:etcd-manager', '//images:etcd-manager-slim', '//images:etcd-backup', '//images:etcd-dump']
# To build with GCS cache
#args: ['build', '--google_default_credentials', '--spawn_strategy=remote', '--genrule_strategy=remote', '--strategy=Javac=remote', '--strategy=Closure=remote', '--remote_http_cache=https://storage.googleapis.com/cache-bucket', '//cmd/...']

Expand All @@ -16,6 +16,12 @@ steps:
- 'DOCKER_REGISTRY=${_DOCKER_REGISTRY}'
- 'DOCKER_IMAGE_PREFIX=${_DOCKER_IMAGE_PREFIX}'
- 'DOCKER_TAG=${COMMIT_SHA}'
- name: gcr.io/cloud-builders/bazel
args: ['run', '//images:push-etcd-manager-slim']
env:
- 'DOCKER_REGISTRY=${_DOCKER_REGISTRY}'
- 'DOCKER_IMAGE_PREFIX=${_DOCKER_IMAGE_PREFIX}'
- 'DOCKER_TAG=${COMMIT_SHA}'
- name: gcr.io/cloud-builders/bazel
args: ['run', '//images:push-etcd-dump']
env:
Expand Down
2 changes: 1 addition & 1 deletion etcd-manager/cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ steps:

- name: gcr.io/cloud-marketplace-containers/google/bazel:3.5.0
entrypoint: bazel
args: ['build', '//cmd/...', '//images:etcd-manager', '//images:etcd-backup', '//images:etcd-dump']
args: ['build', '//cmd/...', '//images:etcd-manager', '//images:etcd-manager-slim', '//images:etcd-backup', '//images:etcd-dump']
# To build with GCS cache
#args: ['build', '--google_default_credentials', '--spawn_strategy=remote', '--genrule_strategy=remote', '--strategy=Javac=remote', '--strategy=Closure=remote', '--remote_http_cache=https://storage.googleapis.com/cache-bucket', '//cmd/...']

Expand Down
33 changes: 33 additions & 0 deletions etcd-manager/images/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,27 @@ container_image(
],
)

container_image(
name = "etcd-manager-slim",
architecture = select({
"@io_bazel_rules_go//go/platform:amd64": "amd64",
"@io_bazel_rules_go//go/platform:arm64": "arm64",
}),
base = select({
"@io_bazel_rules_go//go/platform:amd64": "//images/base:base_image_amd64",
"@io_bazel_rules_go//go/platform:arm64": "//images/base:base_image_arm64",
}),
entrypoint = ["/etcd-manager"],
env = select({
"@io_bazel_rules_go//go/platform:amd64": {},
"@io_bazel_rules_go//go/platform:arm64": {"ETCD_UNSUPPORTED_ARCH": "arm64"},
}),
files = [
"//cmd/etcd-manager",
"//cmd/etcd-manager-ctl",
],
)

container_push(
name = "push-etcd-manager",
format = "Docker",
Expand All @@ -117,6 +138,18 @@ container_push(
}),
)

container_push(
name = "push-etcd-manager-slim",
format = "Docker",
image = ":etcd-manager-slim",
registry = "{STABLE_DOCKER_REGISTRY}",
repository = "{STABLE_DOCKER_IMAGE_PREFIX}etcd-manager",
tag = select({
"@io_bazel_rules_go//go/platform:amd64": "{STABLE_DOCKER_TAG}-slim-amd64",
"@io_bazel_rules_go//go/platform:arm64": "{STABLE_DOCKER_TAG}-slim-arm64",
}),
)

container_image(
name = "etcd-dump",
architecture = select({
Expand Down

0 comments on commit 86a6a93

Please sign in to comment.