Skip to content

Commit

Permalink
Toolchain container: Strip GCC binaries to reduce image size
Browse files Browse the repository at this point in the history
  • Loading branch information
lutoma committed Nov 13, 2023
1 parent 50fa55d commit a1036af
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ RUN make -j$(nproc) all
RUN make DESTDIR=/toolchain install
RUN cp i786-pc-xelix/newlib/libc/sys/xelix/crti.o i786-pc-xelix/newlib/libc/sys/xelix/crtn.o /toolchain/usr/i786-pc-xelix/lib/

# Strip debug info from binaries (Reduces image size substantially)
RUN strip --strip-unneeded /toolchain/usr/bin/i786-pc-xelix-* /toolchain/usr/i786-pc-xelix/bin/*
RUN find /toolchain/usr/libexec/gcc/i786-pc-xelix/13.1.0 -type f -exec strip --strip-unneeded {} \;

# Build a native/host copy of pacman so we can build and manage Xelix userland packages
FROM alpine:latest
WORKDIR /usr/src
Expand All @@ -129,6 +133,7 @@ WORKDIR /usr/src/pacman-v6.0.2
RUN meson setup -Dc_link_args='-lintl' --prefix /usr build
RUN ninja -C build
RUN DESTDIR=/pacman ninja -C build install
RUN strip /pacman/usr/bin/pacman

# Now build the actual image
FROM alpine:latest
Expand Down

0 comments on commit a1036af

Please sign in to comment.