diff --git a/native-image/micronaut-webserver/README.md b/native-image/micronaut-webserver/README.md index 0c32896..769c77f 100644 --- a/native-image/micronaut-webserver/README.md +++ b/native-image/micronaut-webserver/README.md @@ -53,7 +53,7 @@ In this workshop you will: ./build-jar-eclipse-temurin.sh ``` Once the script finishes, a container image _eclipse-temurin-jar_ should be available. - Check its size. It should be **472MB**. + Check its size. It should be **472MB**. ```bash docker images ``` @@ -549,7 +549,7 @@ A separate Maven profile exists for this step: #### For Local Building If you build a native image locally, it requires the `musl` toolchain with `zlib` installed on your machine. -We provide a script to download and configure the `musl` toolchain, and install `zlib` into the toolchain: +We provide a script to download and configure the `musl` toolchain: ```bash ./setup-musl.sh ``` diff --git a/native-image/micronaut-webserver/setup-musl.sh b/native-image/micronaut-webserver/setup-musl.sh index 2bea610..12d4ed1 100755 --- a/native-image/micronaut-webserver/setup-musl.sh +++ b/native-image/micronaut-webserver/setup-musl.sh @@ -1,36 +1,10 @@ #!/usr/bin/env bash set +e -# Specify an installation directory for musl: -export MUSL_HOME=$PWD/musl-toolchain +# Download the `musl` toolchain that includes the `zlib` library. +# Extract it, and add to the system path: -# Download musl sources: -curl -O https://musl.libc.org/releases/musl-1.2.5.tar.gz - -# Build musl from source -tar -xzvf musl-1.2.5.tar.gz -rm -rf musl-1.2.5.tar.gz -pushd musl-1.2.5 -./configure --prefix=$MUSL_HOME --static -# The next operation may require privileged access to system resources, so use sudo -sudo make -sudo make install -popd - -# Install a symlink for use by native-image -ln -s $MUSL_HOME/bin/musl-gcc $MUSL_HOME/bin/x86_64-linux-musl-gcc - -# Extend the system path and confirm that musl is available by printing its version -export PATH="$MUSL_HOME/bin:$PATH" -x86_64-linux-musl-gcc --version - -# Download zlib sources: -curl -O https://zlib.net/fossils/zlib-1.2.13.tar.gz - -# Build zlib with musl from source and install into the MUSL_HOME directory -tar -xzvf zlib-1.2.13.tar.gz -rm -rf zlib-1.2.13.tar.gz -pushd zlib-1.2.13 -CC=musl-gcc ./configure --prefix=$MUSL_HOME --static -make && make install -popd \ No newline at end of file +curl -SLO https://gds.oracle.com/download/bfs/archive/musl-toolchain-1.2.5-oracle-00001-linux-amd64.tar.gz +tar xzf musl-toolchain-1.2.5-oracle-00001-linux-amd64.tar.gz +export PATH="$(pwd)/musl-toolchain/bin:$PATH" +rm -rf musl-toolchain-1.2.5-oracle-00001-linux-amd64.tar.gz \ No newline at end of file diff --git a/native-image/spring-boot-webserver/README.md b/native-image/spring-boot-webserver/README.md index d9f966a..1bf5957 100644 --- a/native-image/spring-boot-webserver/README.md +++ b/native-image/spring-boot-webserver/README.md @@ -566,7 +566,7 @@ A separate Maven profile exists for this step: #### For Local Building If you build a native image locally, it requires the `musl` toolchain with `zlib` installed on your machine. -We provide a script to download and configure the `musl` toolchain, and install `zlib` into the toolchain: +We provide a script to download and configure the `musl` toolchain: ```bash ./setup-musl.sh ``` diff --git a/native-image/spring-boot-webserver/setup-musl.sh b/native-image/spring-boot-webserver/setup-musl.sh index 2bea610..f6f7fb4 100755 --- a/native-image/spring-boot-webserver/setup-musl.sh +++ b/native-image/spring-boot-webserver/setup-musl.sh @@ -1,36 +1,13 @@ #!/usr/bin/env bash set +e -# Specify an installation directory for musl: -export MUSL_HOME=$PWD/musl-toolchain - -# Download musl sources: -curl -O https://musl.libc.org/releases/musl-1.2.5.tar.gz - -# Build musl from source -tar -xzvf musl-1.2.5.tar.gz -rm -rf musl-1.2.5.tar.gz -pushd musl-1.2.5 -./configure --prefix=$MUSL_HOME --static -# The next operation may require privileged access to system resources, so use sudo -sudo make -sudo make install -popd - -# Install a symlink for use by native-image -ln -s $MUSL_HOME/bin/musl-gcc $MUSL_HOME/bin/x86_64-linux-musl-gcc - -# Extend the system path and confirm that musl is available by printing its version -export PATH="$MUSL_HOME/bin:$PATH" -x86_64-linux-musl-gcc --version +#!/usr/bin/env bash +set +e -# Download zlib sources: -curl -O https://zlib.net/fossils/zlib-1.2.13.tar.gz +# Download the `musl` toolchain that includes the `zlib` library. +# Extract it, and add to the system path: -# Build zlib with musl from source and install into the MUSL_HOME directory -tar -xzvf zlib-1.2.13.tar.gz -rm -rf zlib-1.2.13.tar.gz -pushd zlib-1.2.13 -CC=musl-gcc ./configure --prefix=$MUSL_HOME --static -make && make install -popd \ No newline at end of file +curl -SLO https://gds.oracle.com/download/bfs/archive/musl-toolchain-1.2.5-oracle-00001-linux-amd64.tar.gz +tar xzf musl-toolchain-1.2.5-oracle-00001-linux-amd64.tar.gz +export PATH="$(pwd)/musl-toolchain/bin:$PATH" +rm -rf musl-toolchain-1.2.5-oracle-00001-linux-amd64.tar.gz \ No newline at end of file