Skip to content

Commit

Permalink
To reduce the overall size of the build, perform cleanup after each m…
Browse files Browse the repository at this point in the history
…odule.
  • Loading branch information
jlesage committed Jun 28, 2024
1 parent ad3652b commit c9366e8
Show file tree
Hide file tree
Showing 13 changed files with 228 additions and 43 deletions.
12 changes: 6 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,9 @@ ARG TARGETPLATFORM
COPY --from=xx / /
COPY src/pulseaudio /build-pulseaudio
RUN /build-pulseaudio/build.sh
RUN xx-verify --static /tmp/pulseaudio/pulseaudio
RUN xx-verify --static /tmp/pulseaudio-install/usr/bin/pulseaudio
COPY --from=upx /usr/bin/upx /usr/bin/upx
RUN upx /tmp/pulseaudio/pulseaudio
RUN upx /tmp/pulseaudio-install/usr/bin/pulseaudio

# Build the audio recorder.
FROM --platform=$BUILDPLATFORM alpine:3.20 AS audiorecorder
Expand Down Expand Up @@ -181,9 +181,9 @@ ARG TARGETPLATFORM
COPY --from=xx / /
COPY src/htpasswd /tmp/build-htpasswd
RUN /tmp/build-htpasswd/build.sh
RUN xx-verify --static /tmp/httpd/support/htpasswd
RUN xx-verify --static /tmp/httpd-install/usr/bin/htpasswd
COPY --from=upx /usr/bin/upx /usr/bin/upx
RUN upx /tmp/httpd/support/htpasswd
RUN upx /tmp/httpd-install/usr/bin/htpasswd

# Build noVNC.
FROM --platform=$BUILDPLATFORM alpine:3.20 AS noVNC
Expand Down Expand Up @@ -291,10 +291,10 @@ COPY --link --from=fontconfig /tmp/fontconfig-install/opt /opt
COPY --link --from=xdpyprobe /tmp/xdpyprobe/xdpyprobe /opt/base/bin/
COPY --link --from=yad /tmp/yad-install/usr/bin/yad /opt/base/bin/
COPY --link --from=nginx /tmp/nginx-install /opt/base/
COPY --link --from=pulseaudio /tmp/pulseaudio/pulseaudio /opt/base/bin/pulseaudio
COPY --link --from=pulseaudio /tmp/pulseaudio-install/usr/bin/pulseaudio /opt/base/bin/pulseaudio
COPY --link --from=audiorecorder /tmp/build-audiorecorder/audiorecorder /opt/base/bin/audiorecorder
COPY --link --from=webauth /tmp/build-webauth/webauth /opt/base/bin/webauth
COPY --link --from=htpasswd /tmp/httpd/support/htpasswd /opt/base/bin/htpasswd
COPY --link --from=htpasswd /tmp/httpd-install/usr/bin/htpasswd /opt/base/bin/htpasswd
COPY --link --from=dhparam /tmp/dhparam.pem /defaults/
COPY --link --from=noVNC /opt/noVNC /opt/noVNC

Expand Down
21 changes: 17 additions & 4 deletions src/audiorecorder/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ function log {
#
# Install required packages.
#
log "Installing required Alpine packages..."
apk --no-cache add \
HOST_PKGS="\
curl \
build-base \
abuild \
Expand All @@ -46,12 +45,18 @@ apk --no-cache add \
nasm \
pkgconfig \
glib-dev \
"

xx-apk --no-cache --no-scripts add \
TARGET_PKGS="\
g++ \
glib-dev \
glib-static \
libtool \
"

log "Installing required Alpine packages..."
apk --no-cache add $HOST_PKGS
xx-apk --no-cache --no-scripts add $TARGET_PKGS

#
# Build libsndfile
Expand Down Expand Up @@ -161,6 +166,14 @@ cp -v $(xx-info sysroot)usr/lib/pulseaudio/libpulsecommon-${PULSEAUDIO_VERSION}.
#
# Build Audiostreamer
#

log "Compiling Audiostreamer..."
make -C "$SCRIPT_DIR" -j$(nproc)

#
# Cleanup.
#
log "Performing cleanup..."
apk --no-cache del $HOST_PKGS
xx-apk --no-cache --no-scripts del $TARGET_PKGS
apk --no-cache add util-linux # Linux tools still needed and they might be removed if pulled by dependencies.
rm -rf /tmp/pulseaudio
20 changes: 17 additions & 3 deletions src/fontconfig/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,26 @@ function log {
#
# Install required packages.
#
log "Installing required Alpine packages..."
apk --no-cache add \
HOST_PKGS="\
curl \
build-base \
clang \
pkgconfig \
gperf \
python3 \
font-croscore \
"

xx-apk --no-cache --no-scripts add \
TARGET_PKGS="\
glib-dev \
g++ \
freetype-dev \
expat-dev \
"

log "Installing required Alpine packages..."
apk --no-cache add $HOST_PKGS
xx-apk --no-cache --no-scripts add $TARGET_PKGS

#
# Install Noto fonts.
Expand Down Expand Up @@ -96,3 +101,12 @@ make -C /tmp/fontconfig -j$(nproc)

log "Installing fontconfig..."
make DESTDIR=/tmp/fontconfig-install -C /tmp/fontconfig install

#
# Cleanup.
#
log "Performing cleanup..."
apk --no-cache del $HOST_PKGS
xx-apk --no-cache --no-scripts del $TARGET_PKGS
apk --no-cache add util-linux # Linux tools still needed and they might be removed if pulled by dependencies.
rm -rf /tmp/fontconfig
23 changes: 20 additions & 3 deletions src/hsetroot/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,26 @@ function log {
echo ">>> $*"
}

log "Installing required Alpine packages..."
apk --no-cache add \
#
# Install required packages.
#
HOST_PKGS="\
curl \
build-base \
clang \
xz \
"

xx-apk --no-cache --no-scripts add \
TARGET_PKGS="\
g++ \
libx11-dev \
libx11-static \
libxcb-static \
"

log "Installing required Alpine packages..."
apk --no-cache add $HOST_PKGS
xx-apk --no-cache --no-scripts add $TARGET_PKGS

#
# Build hsetroot.
Expand All @@ -47,3 +55,12 @@ xx-clang $CFLAGS "$SCRIPT_DIR"/hsetroot.c -o /tmp/hsetroot/hsetroot $LDFLAGS -Wl
log "Installing hsetroot..."
mkdir -p /tmp/hsetroot-install/usr/bin
cp -v /tmp/hsetroot/hsetroot /tmp/hsetroot-install/usr/bin/

#
# Cleanup.
#
log "Performing cleanup..."
apk --no-cache del $HOST_PKGS
xx-apk --no-cache --no-scripts del $TARGET_PKGS
apk --no-cache add util-linux # Linux tools still needed and they might be removed if pulled by dependencies.
rm -rf /tmp/hsetroot
26 changes: 22 additions & 4 deletions src/htpasswd/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,24 @@ function log {
#
# Install required packages.
#
log "Installing required Alpine packages..."
apk --no-cache add \
HOST_PKGS="\
curl \
build-base \
clang \
"

xx-apk --no-cache --no-scripts add \
TARGET_PKGS="\
g++ \
apr-dev \
apr-util-dev \
pcre2-dev \
expat-static \
util-linux-static \
"

log "Installing required Alpine packages..."
apk --no-cache add $HOST_PKGS
xx-apk --no-cache --no-scripts add $TARGET_PKGS

#
# Build httpd.
Expand All @@ -68,4 +73,17 @@ sed -i "s|-L/usr/lib|-L$(xx-info sysroot)usr/lib|" /tmp/httpd/build/config_vars.
sed -i "s|-R/usr/lib|-R$(xx-info sysroot)usr/lib|" /tmp/httpd/build/config_vars.mk

log "Compiling httpd..."
make V=0 -C /tmp/httpd/support -j$(nproc) htpasswd
make -C /tmp/httpd/support -j$(nproc) htpasswd

log "Installing httpd..."
mkdir -p /tmp/httpd-install/usr/bin
cp -v /tmp/httpd/support/htpasswd /tmp/httpd-install/usr/bin/

#
# Cleanup.
#
log "Performing cleanup..."
apk --no-cache del $HOST_PKGS
xx-apk --no-cache --no-scripts del $TARGET_PKGS
apk --no-cache add util-linux # Linux tools still needed and they might be removed if pulled by dependencies.
rm -rf /tmp/httpd
23 changes: 20 additions & 3 deletions src/nginx/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,28 @@ function log {
#
# Install required packages.
#
log "Installing required Alpine packages..."
apk --no-cache add \
HOST_PKGS="\
build-base \
curl \
clang \
"

xx-apk --no-cache --no-scripts add \
TARGET_PKGS="\
gcc \
musl-dev \
linux-headers \
openssl-dev \
openssl-libs-static \
pcre-dev \
"

log "Installing required Alpine packages..."
apk --no-cache add $HOST_PKGS
xx-apk --no-cache --no-scripts add $TARGET_PKGS

#
# Build nginx.
#

mkdir /tmp/nginx
log "Downloading Nginx..."
Expand Down Expand Up @@ -136,3 +145,11 @@ rm -r \
/tmp/nginx-install/var \
/tmp/nginx-install/config \

#
# Cleanup.
#
log "Performing cleanup..."
apk --no-cache del $HOST_PKGS
xx-apk --no-cache --no-scripts del $TARGET_PKGS
apk --no-cache add util-linux # Linux tools still needed and they might be removed if pulled by dependencies.
rm -rf /tmp/nginx
20 changes: 17 additions & 3 deletions src/openbox/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ function log {
#
# Install required packages.
#
log "Installing required Alpine packages..."
apk --no-cache add \
HOST_PKGS="\
curl \
build-base \
cmake \
Expand All @@ -49,8 +48,9 @@ apk --no-cache add \
pkgconfig \
patch \
glib-dev \
"

xx-apk --no-cache --no-scripts add \
TARGET_PKGS="\
g++ \
glib-dev \
glib-static \
Expand Down Expand Up @@ -81,6 +81,11 @@ xx-apk --no-cache --no-scripts add \
xz-dev \
xz-static \
libxext-static \
"

log "Installing required Alpine packages..."
apk --no-cache add $HOST_PKGS
xx-apk --no-cache --no-scripts add $TARGET_PKGS

# Copy the xx-clang wrapper. Openbox compilation uses libtool. During the link
# phase, libtool re-orders all arguments from LDFLAGS. Thus, libraries are no
Expand Down Expand Up @@ -239,3 +244,12 @@ make V=0 -C /tmp/openbox -j$(nproc)

log "Installing Openbox..."
make DESTDIR=/tmp/openbox-install -C /tmp/openbox install

#
# Cleanup.
#
log "Performing cleanup..."
apk --no-cache del $HOST_PKGS
xx-apk --no-cache --no-scripts del $TARGET_PKGS
apk --no-cache add util-linux # Linux tools still needed and they might be removed if pulled by dependencies.
rm -rf /tmp/openbox
24 changes: 21 additions & 3 deletions src/pulseaudio/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ function log {
#
# Install required packages.
#
log "Installing required Alpine packages..."
apk --no-cache add \
HOST_PKGS="\
curl \
build-base \
abuild \
Expand All @@ -44,14 +43,20 @@ apk --no-cache add \
m4 \
pkgconfig \
glib-dev \
"

xx-apk --no-cache --no-scripts add \
TARGET_PKGS="\
g++ \
glib-dev \
glib-static \
libtool \
libcap-dev \
libcap-static \
"

log "Installing required Alpine packages..."
apk --no-cache add $HOST_PKGS
xx-apk --no-cache --no-scripts add $TARGET_PKGS

#
# Build libsndfile
Expand Down Expand Up @@ -158,3 +163,16 @@ sed -i '/HAVE_NEON/d' /tmp/pulseaudio/build/config.h

log "Compiling PulseAudio..."
make -f "$SCRIPT_DIR"/Makefile -C /tmp/pulseaudio -j$(nproc)

log "Installing PulseAudio..."
mkdir -p /tmp/pulseaudio-install/usr/bin
cp -v /tmp/pulseaudio/pulseaudio /tmp/pulseaudio-install/usr/bin/

#
# Cleanup.
#
log "Performing cleanup..."
apk --no-cache del $HOST_PKGS
xx-apk --no-cache --no-scripts del $TARGET_PKGS
apk --no-cache add util-linux # Linux tools still needed and they might be removed if pulled by dependencies.
rm -rf /tmp/pulseaudio
19 changes: 16 additions & 3 deletions src/tigervnc/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ function log {
#
# Install required packages.
#
log "Installing required Alpine packages..."
apk --no-cache add \
HOST_PKGS="\
curl \
build-base \
abuild \
Expand All @@ -83,8 +82,9 @@ apk --no-cache add \
font-util-dev \
xtrans \
xz \
"

xx-apk --no-cache --no-scripts add \
TARGET_PKGS="\
g++ \
xcb-util-dev \
libx11-dev \
Expand Down Expand Up @@ -117,6 +117,11 @@ xx-apk --no-cache --no-scripts add \
libbsd-dev \
libbsd-static \
libidn2-static \
"

log "Installing required Alpine packages..."
apk --no-cache add $HOST_PKGS
xx-apk --no-cache --no-scripts add $TARGET_PKGS

# Copy the xx-clang wrapper. When compilation uses libtool, all arguments from
# LDFLAGS are re-ordered during the link phase by libtool. Thus, libraries are
Expand Down Expand Up @@ -450,3 +455,11 @@ make DESTDIR=/tmp/tigervnc-install -C /tmp/tigervnc/unix/xserver install
log "Installing TigerVNC vncpasswd tool..."
make DESTDIR=/tmp/tigervnc-install -C /tmp/tigervnc/unix/vncpasswd install

#
# Cleanup.
#
log "Performing cleanup..."
apk --no-cache del $HOST_PKGS
xx-apk --no-cache --no-scripts del $TARGET_PKGS
apk --no-cache add util-linux # Linux tools still needed and they might be removed if pulled by dependencies.
rm -rf /tmp/tigervnc
Loading

0 comments on commit c9366e8

Please sign in to comment.