Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graalvm to idpds #1823

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions common-gradle-scripts/copy.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,12 @@ tasks.register('copy_dist', Copy) {
from "$projectDir/../ballerina/target/bin/" + project.jar_name
into "$projectDir/$project.dist_name"
include "*.jar"
}

tasks.register('copy_dist_idp', Copy) {
group 'docker'
description 'Copy the distribution to docker context'
from "$projectDir/../ballerina/target/bin/" + project.jar_name
into "$projectDir/"
include "*.jar"
}
4 changes: 2 additions & 2 deletions common-gradle-scripts/docker.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ imageName = docker_image_name + ':' + image_version
if (project.hasProperty("docker_organization")) {
imageName = docker_organization+'/'+imageName
}
def platforms = 'linux/amd64,linux/arm64'
def platforms = 'linux/arm64'



Expand Down Expand Up @@ -68,7 +68,7 @@ tasks.register('docker_push', Exec) {
tasks.register('setup_arch', Exec) {
group 'docker'
description 'Setup QEMU for buildx'
commandLine 'docker', 'run', '--rm', '--privileged', 'multiarch/qemu-user-static', '--reset', '-p', 'yes'
commandLine 'docker', 'run', '--rm', '--privileged', 'tonistiigi/binfmt:latest', '--install', 'all'
}

tasks.register('setup_buildx', Exec) {
Expand Down
2 changes: 1 addition & 1 deletion idp/idp-domain-service/ballerina/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ dependencies = [
[[package]]
org = "ballerina"
name = "http"
version = "2.10.0"
version = "2.10.3"
dependencies = [
{org = "ballerina", name = "auth"},
{org = "ballerina", name = "cache"},
Expand Down
45 changes: 13 additions & 32 deletions idp/idp-domain-service/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,20 @@
#
#---------------------------------------------------------------

# # Stage 1: Build the native image
FROM ghcr.io/graalvm/native-image-community:17-ol8 as build

# # Copy the JAR file into the build stage
COPY idp_domain_service.jar .

# # Build the native image
RUN native-image -jar idp_domain_service.jar --no-fallback -H:Name="idp_domain_service" -H:+StaticExecutableWithDynamicLibC

FROM ubuntu:22.04

ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8'
# Update the package list and install build-essential
RUN apt-get update && apt-get install -y build-essential

# Upgrade Ubuntu Dependencies
RUN apt-get update \
&& apt-get upgrade -y

# install JDK Dependencies
RUN apt-get update \
Expand All @@ -33,33 +40,6 @@ RUN apt-get update \
&& locale-gen en_US.UTF-8 \
&& rm -rf /var/lib/apt/lists/*

ENV JAVA_VERSION jdk-17.0.8.1+1

RUN set -eux; \
ARCH="$(dpkg --print-architecture)"; \
case "${ARCH}" in \
amd64|i386:x86-64) \
ESUM='ab68857594792474a3049ede09ea1178e42df29803a6a41be771794f571b2d4e'; \
BINARY_URL='https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.8.1%2B1/OpenJDK17U-jre_x64_linux_hotspot_17.0.8.1_1.tar.gz'; \
;; \
aarch64|arm64) \
ESUM='0a1c5c9ee9d20832c87bd1e99a4c4a96947b59bb35c72683fe895d705f202737'; \
BINARY_URL='https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.8.1%2B1/OpenJDK17U-jre_aarch64_linux_hotspot_17.0.8.1_1.tar.gz'; \
;; \
*) \
echo "Unsupported arch: ${ARCH}"; \
exit 1; \
;; \
esac; \
curl -LfsSo /tmp/openjdk.tar.gz ${BINARY_URL}; \
echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \
mkdir -p /opt/java/openjdk; \
cd /opt/java/openjdk; \
tar -xf /tmp/openjdk.tar.gz --strip-components=1; \
rm -rf /tmp/openjdk.tar.gz;

ENV JAVA_HOME=/opt/java/openjdk \
PATH="/opt/java/openjdk/bin:$PATH"

ARG USER=wso2apk
ARG USER_ID=10001
Expand All @@ -71,6 +51,7 @@ RUN groupadd --system -g ${USER_GROUP_ID} ${USER_GROUP} \
&& useradd --system --create-home --home-dir ${USER_HOME} --no-log-init -g ${USER_GROUP_ID} -u ${USER_ID} ${USER}

ADD idp ${USER_HOME}/idp
COPY --from=build /app/idp_domain_service ${USER_HOME}/idp
COPY docker-entrypoint.sh ${USER_HOME}

RUN chown -R ${USER} ${USER_HOME}/idp \
Expand All @@ -81,4 +62,4 @@ RUN chown -R ${USER} ${USER_HOME}/idp \
EXPOSE 9443
USER ${USER_ID}
WORKDIR ${USER_HOME}
ENTRYPOINT ["sh", "/home/wso2apk/docker-entrypoint.sh"]
ENTRYPOINT ["sh", "/home/wso2apk/docker-entrypoint.sh"]
4 changes: 2 additions & 2 deletions idp/idp-domain-service/docker/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ apply from: "$projectDir/../../../common-gradle-scripts/docker.gradle"
apply from: "$rootDir/../../common-gradle-scripts/copy.gradle"


tasks.named('copy_dist').configure{
tasks.named('copy_dist_idp').configure{
finalizedBy docker_build
}

task build{
group 'build'
description 'Build docker image'
dependsOn 'copy_dist'
dependsOn 'copy_dist_idp'
dependsOn 'docker_build'
}

Expand Down
48 changes: 12 additions & 36 deletions idp/idp-domain-service/docker/idp/idp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,7 @@ PRGDIR=`dirname "$PRG"`

[ -z "$IDP_HOME" ] && IDP_HOME=`cd "$PRGDIR" ; pwd`

if [ -z "$JAVACMD" ] ; then
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
else
JAVACMD=java
fi
fi

if [ ! -x "$JAVACMD" ] ; then
echo "Error: JAVA_HOME is not defined correctly."
echo " IDP cannot execute $JAVACMD"
exit 1
fi

# if JAVA_HOME is not set we're not happy
if [ -z "$JAVA_HOME" ]; then
echo "You must set the JAVA_HOME variable before running Admin."
exit 1
fi
# ----- Process the input command ----------------------------------------------
args=""
for c in $*
Expand Down Expand Up @@ -78,7 +55,7 @@ done

# ----- Execute The Requested Command -----------------------------------------

echo JAVA_HOME environment variable is set to $JAVA_HOME
# echo JAVA_HOME environment variable is set to $JAVA_HOME
echo IDP_HOME environment variable is set to "$IDP_HOME"
export BAL_CONFIG_FILES=$IDP_HOME/conf/Config.toml
cd "$IDP_HOME"
Expand All @@ -91,16 +68,15 @@ fi
START_EXIT_STATUS=121
status=$START_EXIT_STATUS

if [ -z "$JVM_MEM_OPTS" ]; then
java_version=$("$JAVACMD" -version 2>&1 | awk -F '"' '/version/ {print $2}')
JVM_MEM_OPTS="-Xms256m -Xmx1024m"
fi
echo "Using Java memory options: $JVM_MEM_OPTS"

$JAVACMD \
$JVM_MEM_OPTS \
$JAVA_OPTS \
-classpath "$CLASSPATH" \
-Djava.io.tmpdir="$IDP_HOME/tmp" \
-jar idp_domain_service.jar $*
status=$?
# Define the path to the executable
EXECUTABLE="./idp_domain_service"

# Check if the executable exists
if [ -f "$EXECUTABLE" ]; then
# Run the executable with your desired options
$EXECUTABLE "$@"
else
echo "Error: Executable '$EXECUTABLE' not found."
exit 1
fi
Loading