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

Reduce VTPM container size #4324

Merged
merged 1 commit into from
Oct 10, 2024
Merged

Conversation

rucoder
Copy link
Contributor

@rucoder rucoder commented Oct 8, 2024

  • strip SO libraries
  • do not copy *.a and *.la static libraries
  • fix ENV syntax to match the latest Dockerfile spec

The size of resulting rootfs image is reduced by 2 555 904 bytes (1%)

@@ -19,6 +19,7 @@ RUN ./autogen.sh --prefix=/usr --with-tpm2
RUN make -j$(nproc)
RUN make -j$(nproc) install
RUN cp /usr/lib/libtpms.so.* /out/usr/lib/
RUN strip /out/usr/lib/libtpms.so.*
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
RUN strip /out/usr/lib/libtpms.so.*
RUN strip --strip-unneeded /out/usr/lib/libtpms.so.*

as of https://www.linuxfromscratch.org/lfs/view/development/chapter08/stripping.html

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@christoph-zededa this is a default behavior but I'll commit it to be on a safe side

- strip SO libraries
- do not copy *.a and *.la static libraries
- fix ENV syntax to match the latest Dockerfile spec

Signed-off-by: Mikhail Malyshev <mike.malyshev@gmail.com>
@shjala
Copy link
Member

shjala commented Oct 8, 2024

LGTM, even though it should not affect anything, but let me run aziot tests and make sure everything remains functional.

@shjala
Copy link
Member

shjala commented Oct 8, 2024

Tested the following :

  • Legacy Aziot (with PTPM)
  • vTPM based Aziot
  • vTPM state preservation

all green.

@rucoder
Copy link
Contributor Author

rucoder commented Oct 8, 2024

Tested the following :

* [x]  Legacy Aziot (with PTPM)

* [x]  vTPM based Aziot

* [x]  vTPM state preservation

all green.

@shjala could you approve the PR then?

@OhmSpectator
Copy link
Member

We can do

RUN strip --strip-unneeded /out/usr/bin/vtpm

here:

RUN GO111MODULE=on CGO_ENABLED=0 go build -ldflags "-s -w -X=main.Version=${GOPKGVERSION}" \

as well I guess?

@@ -47,6 +50,7 @@ RUN ./bootstrap && \
make -j$(nproc)
RUN cp lib/.libs/libcommon.so* /out/usr/lib/
RUN cp tools/.libs/tpm2 /out/usr/bin/
RUN strip --strip-unneeded /out/usr/lib/*.so*
Copy link
Member

Choose a reason for hiding this comment

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

Could we strip the tmp2 bin as well here?

Suggested change
RUN strip --strip-unneeded /out/usr/lib/*.so*
RUN strip --strip-unneeded /out/usr/lib/*.so*
RUN strip --strip-unneeded /out/usr/bin/tpm2

@eriknordmark eriknordmark merged commit 4e67b25 into lf-edge:master Oct 10, 2024
47 of 60 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants