Skip to content

Commit

Permalink
Reduce VTPM container size
Browse files Browse the repository at this point in the history
- 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>
  • Loading branch information
rucoder committed Oct 8, 2024
1 parent e7bb230 commit 2d3d4c3
Showing 1 changed file with 14 additions and 5 deletions.
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 /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 /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 /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 /out/usr/lib/*.so*

# 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 /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

0 comments on commit 2d3d4c3

Please sign in to comment.