Add comparison results and improve the workshop #4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Github Actions Pipeline | |
on: [push, pull_request] | |
jobs: | |
build: | |
name: Run Jwebserver | |
runs-on: ubuntu-20.04 # Docker changed its behavior on Ubuntu 22.04 | |
timeout-minutes: 30 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up GraalVM | |
uses: graalvm/setup-graalvm@v1 | |
with: | |
java-version: '23-ea' | |
distribution: 'graalvm' | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Run Spring Boot Web Server | |
run: | | |
# Build JAR (Debian Slim) | |
./build-jar.sh | |
container_id=$(docker run -d --rm -p8080:8080 webserver:debian-slim.jar) | |
sleep 5s | |
curl "http://localhost:8080" | |
docker stop $container_id | |
# | |
# Build Jlink custom runtime (Distroless Java Base) | |
./build-jlink.sh | |
container_id=$(docker run -d --rm -p8080:8080 webserver:distroless-java-base.jlink) | |
sleep 5s | |
curl "http://localhost:8080" | |
docker stop $container_id | |
# | |
# # Build dynamic image using Oracle Paketo Buildpack (Ubuntu Jammy Jellyfish) | |
# ./mvnw -Pnative spring-boot:build-image | |
# container_id=$(docker run --rm -p 8080:8080 docker.io/library/demo:0.0.1-SNAPSHOT) | |
# sleep 5s | |
# curl "http://localhost:8080" | |
# docker stop $container_id | |
# # | |
# Build dynamic image (Distroless Java Base) | |
./build-dynamic-image.sh | |
container_id=$(docker run -d --rm -p8080:8080 webserver:distroless-java-base.dynamic) | |
sleep 5s | |
curl "http://localhost:8080" | |
docker stop $container_id | |
# | |
# Build dynamic image, optimized for size (Distroless Java Base) | |
./build-dynamic-image-optimized.sh | |
container_id=$(docker run -d --rm -p8080:8080 webserver:distroless-java-base.dynamic-optimized) | |
sleep 5s | |
curl "http://localhost:8080" | |
docker stop $container_id | |
# | |
# Setup musl toolchain | |
./setup-musl.sh | |
export PATH="$PWD/musl-toolchain/bin:$PATH" | |
# | |
# Build mostly static image (Distroless Base) | |
./build-mostly-static-image.sh | |
container_id=$(docker run -d --rm -p8080:8080 webserver:distroless-base.mostly-static) | |
sleep 5s | |
curl "http://localhost:8080" | |
docker stop $container_id | |
# | |
# Build fully static image (Scratch) | |
./build-static-image.sh | |
container_id=$(docker run -d --rm -p8080:8080 webserver:scratch.static) | |
sleep 5s | |
curl "http://localhost:8080" | |
docker stop $container_id | |
# | |
# Download upx | |
./setup-upx.sh | |
# | |
# Build fully static compressed image (Scratch UPX) | |
./build-static-upx-image.sh | |
container_id=$(docker run -d --rm -p8080:8080 webserver:scratch.static-upx) | |
sleep 5s | |
curl "http://localhost:8080" | |
docker stop $container_id | |
# | |
# Compare file sizes | |
ls -lh runner* | |
docker images webserver | |
- name: Archive production artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: native-binaries-${{ matrix.os }} | |
path: | | |
runner* |