-
Notifications
You must be signed in to change notification settings - Fork 0
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 #4 from dksifoua/feature/3-add-task-runner-to-java…
…-image Add Task Runner to Java
- Loading branch information
Showing
4 changed files
with
89 additions
and
71 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
FROM --platform=$BUILDPLATFORM ubuntu:24.10 | ||
LABEL authors="Dimitri Sifoua" | ||
LABEL description="Java Build Agent with GraalVM Support" | ||
LABEL maintainer="Dimitri Sifoua <[email protected]>" | ||
|
||
ARG TARGETPLATFORM | ||
|
||
ENV UID=10001 | ||
ENV GID=10001 | ||
ENV USERNAME=dksifoua | ||
ENV HOME=/home/$USERNAME | ||
|
||
ENV GRAALVM_HOME=/opt/graalvm-jdk-21 | ||
ENV JAVA_HOME=$GRAALVM_HOME | ||
ENV PATH=$GRAALVM_HOME/bin:$PATH | ||
|
||
RUN groupadd -g $GID $USERNAME \ | ||
&& useradd -m -g $GID -u $UID -s /bin/bash $USERNAME \ | ||
&& apt-get update \ | ||
&& apt-get install -y curl \ | ||
&& rm -rf /var/lib/apt/lists \ | ||
&& chmod u-s /usr/bin/chfn /usr/bin/gpasswd /usr/bin/su /usr/bin/passwd /usr/bin/chsh /usr/bin/newgrp /usr/bin/mount /usr/bin/umount \ | ||
&& chmod g-s /usr/bin/chage /usr/sbin/pam_extrausers_chkpwd /usr/sbin/unix_chkpwd /usr/bin/expiry \ | ||
&& curl --location https://taskfile.dev/install.sh | bash -s -- -d | ||
|
||
RUN case $TARGETPLATFORM in \ | ||
"linux/amd64") \ | ||
GRAALVM_FILE="graalvm-jdk-21_linux-x64_bin.tar.gz"; \ | ||
GRAALVM_URL="https://download.oracle.com/graalvm/21/latest/$GRAALVM_FILE"; \ | ||
;; \ | ||
"linux/arm64") \ | ||
GRAALVM_FILE="graalvm-jdk-21_linux-aarch64_bin.tar.gz"; \ | ||
GRAALVM_URL="https://download.oracle.com/graalvm/21/latest/$GRAALVM_FILE"; \ | ||
;; \ | ||
*) \ | ||
echo "Unsupported platform: $BUILDPLATFORM"; exit 1; \ | ||
;; \ | ||
esac \ | ||
&& mkdir -p $GRAALVM_HOME \ | ||
&& curl -L $GRAALVM_URL -o $GRAALVM_HOME/$GRAALVM_FILE \ | ||
&& tar -xvzf $GRAALVM_HOME/$GRAALVM_FILE --strip-components=1 -C $GRAALVM_HOME \ | ||
&& rm $GRAALVM_HOME/$GRAALVM_FILE | ||
|
||
USER $UID:$GID | ||
|
||
HEALTHCHECK \ | ||
--interval=30s \ | ||
--timeout=10s \ | ||
--start-period=5s \ | ||
--retries=3 \ | ||
CMD curl --fail http://localhost/ || exit 1 | ||
# CMD java --version && task --version || exit 1 | ||
|
||
WORKDIR $HOME | ||
|
||
CMD ["/bin/bash"] |
This file was deleted.
Oops, something went wrong.
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,33 +1,28 @@ | ||
version: 3 | ||
|
||
env: | ||
DOCKER_CONTENT_TRUST: 0 | ||
|
||
vars: | ||
JAVA_VERSION: 21.0.4-graal | ||
DOCKER_BUILDKIT: 1 | ||
DOCKER_DEFAULT_PLATFORM: linux/amd64,linux/arm64 | ||
|
||
tasks: | ||
build: | ||
desc: Build Java image | ||
cmd: | | ||
docker build \ | ||
--build-arg JAVA_VERSION={{ .JAVA_VERSION }} \ | ||
--tag java:{{ .JAVA_VERSION }}-alpine \ | ||
--file java/Dockerfile \ | ||
. | ||
docker buildx build \ | ||
--tag dksifoua/java:21-graalvm \ | ||
--file java/21.Dockerfile \ | ||
. {{ .CLI_ARGS }} | ||
silent: true | ||
|
||
push: | ||
desc: Push java image to docker hub | ||
cmds: | ||
- docker tag java:{{ .JAVA_VERSION }}-alpine dksifoua/java:{{ .JAVA_VERSION }}-alpine | ||
- docker push dksifoua/java:{{ .JAVA_VERSION }}-alpine | ||
cmd: docker push dksifoua/java:21-graalvm | ||
|
||
scan: | ||
desc: Scan built image for vulnerabilities | ||
cmd: trivy image java:{{ .JAVA_VERSION }}-alpine | ||
cmd: trivy image dksifoua/java:21-graalvm | ||
|
||
verify: | ||
desc: Check docker image best practices has been followed | ||
cmd: dockle --exit-code 1 --exit-level info java:{{ .JAVA_VERSION }}-alpine | ||
cmd: dockle --exit-code 1 --exit-level info dksifoua/java:21-graalvm | ||
silent: true |