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
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
19 changes: 14 additions & 5 deletions pkg/vtpm/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

FROM lfedge/eve-dom0-ztools:b8eaeec19d373228a4a842374e5de0d50f050853 as dom0
FROM lfedge/eve-alpine:82df60e43ab9f8c935584b8c7b4d0a4b0271d608 as build
ENV BUILD_PKGS gcc g++ autoconf automake libtool make openssl-dev libtasn1-dev \
json-glib-dev gnutls bash expect gawk socat libseccomp-dev gmp-dev \
musl-utils autoconf-archive git json-c json-c-dev libcurl curl-dev \
patch go protobuf-dev
ENV PKGS libseccomp libcurl libstdc++ libprotobuf
ENV BUILD_PKGS="gcc g++ autoconf automake libtool make openssl-dev libtasn1-dev \
json-glib-dev gnutls bash expect gawk socat libseccomp-dev gmp-dev \
musl-utils autoconf-archive git json-c json-c-dev libcurl curl-dev \
patch go protobuf-dev"
ENV PKGS="libseccomp libcurl libstdc++ libprotobuf"
RUN eve-alpine-deploy.sh

# build libtpms, it is needed by swtpm
Expand All @@ -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 --strip-unneeded /out/usr/lib/libtpms.so.*

# build swtpm
WORKDIR /swtpm
Expand All @@ -27,6 +28,7 @@ RUN ./autogen.sh --prefix=/out/usr
RUN make -j$(nproc)
RUN make -j$(nproc) install
RUN cp /out/usr/lib/swtpm/* /out/usr/lib/
RUN strip --strip-unneeded /out/usr/lib/swtpm/*.so*

# build tpm2-tss, it is needed by tpm2-tools
WORKDIR /tpm2-tss
Expand All @@ -36,6 +38,7 @@ RUN ./bootstrap && \
make -j$(nproc) && \
make install
RUN cp /usr/local/lib/libtss2* /out/usr/lib/
RUN strip --strip-unneeded /out/usr/lib/libtss2*.so*

# build tpm2-tools, it is needed by ptpm
WORKDIR /tpm2-tools
Expand All @@ -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


# Build vtpm
WORKDIR /vtpm-build
Expand All @@ -67,6 +71,11 @@ COPY Makefile /ptpm-build/
COPY src/ /ptpm-build/src
COPY proto/ /ptpm-build/proto
RUN make -j$(nproc) && cp ptpm /out/usr/bin/
RUN strip --strip-unneeded /out/usr/bin/ptpm

# remove static libraries and libtool libraries
RUN find /out/usr/lib/ -name '*.la' -delete
RUN find /out/usr/lib/ -name '*.a' -delete

FROM scratch
COPY --from=build /out/ /
Expand Down
Loading