Skip to content

Commit

Permalink
Changes rock base to bare
Browse files Browse the repository at this point in the history
Switching to a bare-based image will reduce the overall image size
and reduces attack surface area.

Adding the ``CGO_ENABLED=0`` will result in the go binary being
statically linked, which means it won't need the ``/lib`` and ``/lib64``
folders to run. This allows us to switch the base image to bare, greatly
reducing the image size.

Adds an extra sanity check during the integration test, making sure that
there is no error reported in Pebble while starting the service.
  • Loading branch information
claudiubelu committed Oct 28, 2024
1 parent 6618a5d commit f30b986
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
3 changes: 2 additions & 1 deletion rockcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ description: |
license: Apache-2.0
version: 0.0.1

base: [email protected]
base: bare
build-base: [email protected]
run-user: _daemon_

Expand Down Expand Up @@ -48,6 +48,7 @@ parts:
build-environment:
- GOOS: linux
- GOARCH: $CRAFT_ARCH_BUILD_FOR
- CGO_ENABLED: 0
go-generate:
- ./cmd
organize:
Expand Down
17 changes: 17 additions & 0 deletions tests/integration/test_mutating_pebble_webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,23 @@ def webhook_instance(module_instance: harness.Instance):
module_instance, "mutating-pebble-webhook", "pebble-webhook"
)

# Sanity check: make sure there isn't an error in Pebble that it couldn't start the service.
process = module_instance.exec(
[
"k8s",
"kubectl",
"logs",
"-n",
"pebble-webhook",
"deployment.apps/mutating-pebble-webhook",
],
check=True,
capture_output=True,
text=True,
)

assert '(Start service "mutating-pebble-webhook") failed' not in process.stdout

yield module_instance


Expand Down

0 comments on commit f30b986

Please sign in to comment.