-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #295 from graalvm/tiny-containers-multi-stage
Tiny containers multi stage
- Loading branch information
Showing
25 changed files
with
247 additions
and
253 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ | |
|
||
set +e | ||
|
||
rm -rf x86_64-linux-musl-native zlib-* | ||
cd helloworld | ||
./clean.sh || true | ||
cd ../jwebserver | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,29 @@ | ||
|
||
# Build in a container with Oracle GraalVM Native Image and MUSL | ||
FROM container-registry.oracle.com/graalvm/native-image:23-muslib AS nativebuild | ||
WORKDIR /build | ||
# Install UPX | ||
ARG UPX_VERSION=4.2.2 | ||
ARG UPX_ARCHIVE=upx-${UPX_VERSION}-amd64_linux.tar.xz | ||
RUN microdnf -y install wget xz && \ | ||
wget -q https://github.com/upx/upx/releases/download/v${UPX_VERSION}/${UPX_ARCHIVE} && \ | ||
tar -xJf ${UPX_ARCHIVE} && \ | ||
rm -rf ${UPX_ARCHIVE} && \ | ||
mv upx-${UPX_VERSION}-amd64_linux/upx . && \ | ||
rm -rf upx-${UPX_VERSION}-amd64_linux | ||
|
||
# Compile the Hello class to Java bytecode | ||
COPY Hello.java Hello.java | ||
RUN javac Hello.java | ||
# Build a native executable with native-image | ||
RUN native-image -Os --static --libc=musl Hello -o hello | ||
RUN ls -lh hello | ||
|
||
# Compress the executable with UPX | ||
RUN ./upx --lzma --best -o hello.upx hello | ||
RUN ls -lh hello.upx | ||
|
||
# Copy the compressed executable into a scratch container | ||
FROM scratch | ||
COPY hello.upx / | ||
COPY --from=nativebuild /build/hello.upx /hello.upx | ||
ENTRYPOINT ["/hello.upx"] |
Oops, something went wrong.