Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build and push kbs-client binary #349

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/workflows/kbs-client-build-and-push.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Build and push kbs-client

on:
push:
branches:
- main

jobs:
build_and_push:
env:
RUSTC_VERSION: 1.76.0
runs-on: ubuntu-22.04
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @portersrc ! I don't remember the last time I built static executables on Ubuntu, so wondering if you need to install the static libc package. On my fedora 39 laptop I had to install glibc-static to test this static build.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think I checked this; great question; will check it now.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can confirm that gcc -static works on a simple test. Also 22.04 package list includes libc6-dev, and the (debian) file list for libc6-dev includes libc.a, etc. (So I think we're OK?)

The easier thing is to just verify that this workflow succeeds before merging, but I don't see this workflow getting kicked... Do you know how/why?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @portersrc !

Cool!

The workflow didn't get kicked because it is configure to run on push. One way to test it is to add the pull_request to the list of triggering events. Then you will need to skip the execution of Log in to ghcr.io and Push to ghcr.io steps based on the event type (because these steps will fail on pull_request).

See .github/workflows/kbs-e2e-az-tdx-vtpm.yaml as an example of workflow that run for two events and skip steps conditionally.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the pointers! I looked at the yaml file, but to test at least part of this PR, I did something cruder: I changed to on: pull_request and commented out the ghcr login and push. This at least checks that make cli-static-x86_64-linux completes on the runner. It built fine (GHA result here). I changed it back to on: push, as intended for this PR. But I guess we need it to merge in order to verify the oras step works (though I tested with a personal repo, and it looks OK).


steps:
- name: Check out code
uses: actions/checkout@v4
- name: Install rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.RUSTC_VERSION }}
override: true
profile: minimal
- name: Log in to ghcr.io
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build a statically linked kbs-client for x86_64 linux
working-directory: kbs
run: |
make cli-static-x86_64-linux
- name: Push to ghcr.io
working-directory: target/x86_64-unknown-linux-gnu/release
run: |
commit_sha=${{ github.sha }}
oras push \
portersrc marked this conversation as resolved.
Show resolved Hide resolved
ghcr.io/confidential-containers/staged-images/kbs-client:sample_only-x86_64-linux-gnu-${commit_sha},latest \
kbs-client
11 changes: 11 additions & 0 deletions kbs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,17 @@ passport-resource-kbs:
cli:
cargo build -p kbs-client --locked --release --no-default-features --features $(CLI_FEATURES)

.PHONY: cli-static-x86_64-linux
cli-static-x86_64-linux:
portersrc marked this conversation as resolved.
Show resolved Hide resolved
cargo build \
-p kbs-client \
--target=x86_64-unknown-linux-gnu \
--config "target.x86_64-unknown-linux-gnu.rustflags = '-C target-feature=+crt-static'" \
--locked \
--release \
--no-default-features \
--features sample_only

install-kbs:
install -D -m0755 ../target/release/kbs $(INSTALL_DESTDIR)

Expand Down
Loading