Skip to content

Commit bd0155d

Browse files
author
Ben Hillis
committed
cleanup: more improvements to Dockerfile and add .vhd build script
1 parent 22f1b7e commit bd0155d

2 files changed

Lines changed: 49 additions & 20 deletions

File tree

‎Dockerfile‎

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -314,13 +314,16 @@ FROM mcr.microsoft.com/azurelinux/base/core:3.0 AS runtime
314314

315315
RUN echo "== Install Core/UI Runtime Dependencies ==" && \
316316
tdnf install -y \
317+
busybox \
317318
cairo \
318319
chrony \
319320
dbus \
320321
dbus-glib \
321322
dhcpcd \
322323
e2fsprogs \
323324
freefont \
325+
icu \
326+
kmod \
324327
libinput \
325328
libjpeg-turbo \
326329
libltdl \
@@ -340,35 +343,41 @@ RUN echo "== Install Core/UI Runtime Dependencies ==" && \
340343
procps-ng \
341344
rpm \
342345
sed \
346+
systemd-libs \
343347
tzdata \
344-
wayland-protocols-devel \
348+
util-linux \
345349
xcursor-themes \
346350
xorg-x11-server-Xwayland \
347-
xorg-x11-server-utils \
348-
xorg-x11-xtrans-devel
351+
xorg-x11-server-utils
352+
353+
# Install busybox utilities
354+
RUN /sbin/busybox --install -s
349355

350356
# Remove unnecessary packages and files to reduce image size
351357
ARG SYSTEMDISTRO_DEBUG_BUILD
352358
RUN if [ -z "$SYSTEMDISTRO_DEBUG_BUILD" ] ; then \
353359
echo "== Removing unnecessary packages ==" && \
354-
# Remove build tools not needed at runtime \
355-
rpm -e --nodeps gcc gcc-c++ perl && \
360+
# Remove build tools and packages not needed at runtime \
361+
rpm -e --nodeps \
362+
cracklib-dicts \
363+
gcc \
364+
gcc-c++ \
365+
libpkgconf \
366+
llvm \
367+
perl \
368+
pkgconf \
369+
pkgconf-m4 \
370+
pkgconf-pkg-config \
371+
python3 \
372+
python3-libs && \
356373
# Remove all perl subpackages \
357-
rpm -e --nodeps $(rpm -qa | grep ^perl-) && \
358-
# Remove Python (not needed at runtime) \
359-
rpm -e --nodeps python3 python3-libs && \
360-
# Remove LLVM (only used by virtio_gpu driver which WSLg doesn't use) \
361-
rpm -e --nodeps llvm && \
362-
# Remove all -devel packages (including those pulled by librsvg2) \
363-
rpm -e --nodeps $(rpm -qa | grep -E -- '-devel') && \
364-
# Remove pkgconf and related packages \
365-
rpm -e --nodeps pkgconf-pkg-config pkgconf pkgconf-m4 libpkgconf && \
366-
# Remove password dictionary (not needed in WSLg) \
367-
rpm -e --nodeps cracklib-dicts && \
368-
# Remove systemd-resolved (provides resolvconf, but we use dhcpcd's built-in resolv.conf management) \
369-
rpm -e --nodeps systemd-resolved && \
370-
# Remove orphaned packages (but keep icu which provides runtime libraries) \
371-
tdnf autoremove -y --exclude icu && \
374+
rpm -e --nodeps $(rpm -qa | grep -- '^perl-') && \
375+
# Remove all -devel packages \
376+
rpm -e --nodeps $(rpm -qa | grep -- '-devel') && \
377+
# Remove systemd components (except systemd-libs which is needed by weston) \
378+
rpm -e --nodeps $(rpm -qa | grep -- '^systemd-' | grep -v systemd-libs) && \
379+
# Remove orphaned packages \
380+
tdnf autoremove -y && \
372381
echo "== Removing unnecessary files ==" && \
373382
# Remove docs, man pages, locales, gtk-doc \
374383
rm -rf /usr/share/man /usr/share/info /usr/share/locale /usr/share/gtk-doc && \

‎build-and-export.sh‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
set -e
3+
4+
echo "=== Building Docker image ==="
5+
docker build -f Dockerfile -t system-distro-x64 . \
6+
--build-arg WSLG_VERSION=1.0.72-test \
7+
--build-arg WSLG_ARCH=x86_64
8+
9+
echo ""
10+
echo "=== Exporting Docker container to tar ==="
11+
docker export $(docker create system-distro-x64) > system_x64.tar
12+
13+
echo ""
14+
echo "=== Converting tar to VHD ==="
15+
# Run tar2ext4 directly from GitHub
16+
go run github.com/Microsoft/hcsshim/cmd/tar2ext4@latest -vhd -i system_x64.tar -o system_x64.vhd
17+
echo ""
18+
echo "=== Done! ==="
19+
echo "Output file: $(pwd)/system_x64.vhd"
20+
ls -lh system_x64.vhd

0 commit comments

Comments
 (0)