Skip to content

Commit 3ce27f8

Browse files
Reduce disk space used when building busybox
1 parent 604647f commit 3ce27f8

File tree

1 file changed

+22
-20
lines changed

1 file changed

+22
-20
lines changed

Dockerfile

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -126,43 +126,45 @@ RUN tar -C /root/ -j -x -v -f /tmp/busybox-1.36.1.tar.bz2
126126
FROM platform AS busybox-arm64
127127
COPY --from=busybox-source /root/busybox-1.36.1 /root/busybox-1.36.1
128128
WORKDIR /root/busybox-1.36.1
129-
RUN mkdir build
129+
RUN mkdir /root/busybox/
130130

131131
RUN make \
132-
O=/root/busybox-1.36.1/build \
132+
O=/root/busybox/ \
133133
CROSS_COMPILE=aarch64-linux-gnu- \
134134
CFLAGS="-march=armv8-a" \
135135
defconfig
136136

137-
RUN echo "CONFIG_STATIC=y" >> /root/busybox-1.36.1/build/.config
138-
RUN sed -i "s/CONFIG_TC=y/CONFIG_TC=n/g" /root/busybox-1.36.1/build/.config
137+
RUN echo "CONFIG_STATIC=y" >> /root/busybox/.config
138+
RUN sed -i "s/CONFIG_TC=y/CONFIG_TC=n/g" /root/busybox/.config
139139

140140
RUN make \
141-
O=/root/busybox-1.36.1/build \
141+
O=/root/busybox/ \
142142
CROSS_COMPILE=aarch64-linux-gnu- \
143143
CFLAGS="-march=armv8-a" \
144144
-j8 \
145-
install
145+
install && \
146+
rm -rf /root/busybox-1.36.1
146147

147148
################################################################################
148149
# BUSYBOX-x64 #
149150
################################################################################
150151
FROM platform AS busybox-x64
151152
COPY --from=busybox-source /root/busybox-1.36.1 /root/busybox-1.36.1
152153
WORKDIR /root/busybox-1.36.1
153-
RUN mkdir build
154+
RUN mkdir /root/busybox/
154155

155156
RUN make \
156-
O=/root/busybox-1.36.1/build \
157+
O=/root/busybox/ \
157158
defconfig
158159

159-
RUN echo "CONFIG_STATIC=y" >> /root/busybox-1.36.1/build/.config
160-
RUN sed -i "s/CONFIG_TC=y/CONFIG_TC=n/g" /root/busybox-1.36.1/build/.config
160+
RUN echo "CONFIG_STATIC=y" >> /root/busybox/.config
161+
RUN sed -i "s/CONFIG_TC=y/CONFIG_TC=n/g" /root/busybox/.config
161162

162163
RUN make \
163-
O=/root/busybox-1.36.1/build \
164+
O=/root/busybox/ \
164165
-j8 \
165-
install
166+
install && \
167+
rm -rf /root/busybox-1.36.1
166168

167169
################################################################################
168170
# INITRD-BASE #
@@ -192,10 +194,10 @@ COPY assets/initrd/entropy.c /root/entropy.c
192194
# INITRD-ARM64 #
193195
################################################################################
194196
FROM initrd-base AS initrd-arm64
195-
COPY --from=busybox-arm64 /root/busybox-1.36.1/build/_install/bin /root/initramfs/bin/
196-
COPY --from=busybox-arm64 /root/busybox-1.36.1/build/_install/sbin /root/initramfs/sbin/
197-
COPY --from=busybox-arm64 /root/busybox-1.36.1/build/_install/usr /root/initramfs/usr/
198-
COPY --from=busybox-arm64 /root/busybox-1.36.1/build/_install/linuxrc /root/initramfs/linuxrc
197+
COPY --from=busybox-arm64 /root/busybox/_install/bin /root/initramfs/bin/
198+
COPY --from=busybox-arm64 /root/busybox/_install/sbin /root/initramfs/sbin/
199+
COPY --from=busybox-arm64 /root/busybox/_install/usr /root/initramfs/usr/
200+
COPY --from=busybox-arm64 /root/busybox/_install/linuxrc /root/initramfs/linuxrc
199201
RUN aarch64-linux-gnu-gcc \
200202
-march=armv8-a \
201203
-static \
@@ -322,10 +324,10 @@ RUN find . | cpio -o --format=newc -R root:root > /root/initramfs-arm64be.img
322324
# INITRD-x64 #
323325
################################################################################
324326
FROM initrd-base AS initrd-x64
325-
COPY --from=busybox-x64 /root/busybox-1.36.1/build/_install/bin /root/initramfs/bin/
326-
COPY --from=busybox-x64 /root/busybox-1.36.1/build/_install/sbin /root/initramfs/sbin/
327-
COPY --from=busybox-x64 /root/busybox-1.36.1/build/_install/usr /root/initramfs/usr/
328-
COPY --from=busybox-x64 /root/busybox-1.36.1/build/_install/linuxrc /root/initramfs/linuxrc
327+
COPY --from=busybox-x64 /root/busybox/_install/bin /root/initramfs/bin/
328+
COPY --from=busybox-x64 /root/busybox/_install/sbin /root/initramfs/sbin/
329+
COPY --from=busybox-x64 /root/busybox/_install/usr /root/initramfs/usr/
330+
COPY --from=busybox-x64 /root/busybox/_install/linuxrc /root/initramfs/linuxrc
329331
RUN gcc \
330332
-static \
331333
-o /root/initramfs/sbin/entropy \

0 commit comments

Comments
 (0)