-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
456 additions
and
0 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
modules/org.eclipse.jkube.s2i/bash/artifacts/opt/jboss/container/java/s2i/maven-overrides
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,12 @@ | ||
# Overrides basic functionality by looking fore settings.xml in <source>/configuration | ||
function maven_init_var_MAVEN_SETTINGS_XML() { | ||
if [ -f "${MAVEN_SETTINGS_XML}" ]; then | ||
: | ||
elif [ -f "${S2I_SOURCE_DIR}/configuration/settings.xml" ]; then | ||
MAVEN_SETTINGS_XML="${S2I_SOURCE_DIR}/configuration/settings.xml" | ||
else | ||
MAVEN_SETTINGS_XML="${_MAVEN_S2I_SETTINGS_XML}" | ||
mkdir -p $(dirname "${MAVEN_SETTINGS_XML}") | ||
cp "${JBOSS_CONTAINER_MAVEN_DEFAULT_MODULE}/jboss-settings.xml" "${MAVEN_SETTINGS_XML}" | ||
fi | ||
} |
44 changes: 44 additions & 0 deletions
44
...les/org.eclipse.jkube.s2i/bash/artifacts/opt/jboss/container/java/s2i/maven-s2i-overrides
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,44 @@ | ||
|
||
source "${JBOSS_CONTAINER_UTIL_LOGGING_MODULE}/logging.sh" | ||
|
||
# inject our overridden maven_*() functions | ||
function maven_s2i_source_maven_overrides() { | ||
source "${JBOSS_CONTAINER_JAVA_S2I_MODULE}/maven-overrides" | ||
} | ||
|
||
# Accommodate fabric8 | ||
# TODO: is this needed for JKube? | ||
function maven_s2i_custom_binary_build() { | ||
if [ -f "${S2I_SOURCE_DIR}/Dockerfile" ]; then | ||
# This is a S2I binary build coming from fabric8-maven-plugin | ||
log_info "S2I binary build from fabric8-maven-plugin detected" | ||
if [ -d "${S2I_SOURCE_DIR}/maven" ]; then | ||
binary_dir="${S2I_SOURCE_DIR}/maven" | ||
elif [ -d "${S2I_SOURCE_DIR}/${S2I_SOURCE_DEPLOYMENTS_DIR}" ]; then | ||
binary_dir="${S2I_SOURCE_DIR}/${S2I_SOURCE_DEPLOYMENTS_DIR}" | ||
elif [ $(find "${S2I_SOURCE_DIR}" -maxdepth 1 -type d | grep -v -e "^${S2I_SOURCE_DIR}$" | wc -l) == 1 ]; then | ||
# Found a single directory, take this | ||
binary_dir=$(find "${S2I_SOURCE_DIR}" -maxdepth 1 -type d | grep -v -e "^${S2I_SOURCE_DIR}$") | ||
else | ||
log_error "No single directory found in ${S2I_SOURCE_DIR} but:\n $(ls -l ${S2I_SOURCE_DIR})" | ||
return 1 | ||
fi | ||
elif [ -d "${S2I_SOURCE_DIR}/${S2I_SOURCE_DEPLOYMENTS_DIR}" ]; then | ||
binary_dir="${S2I_SOURCE_DIR}/${S2I_SOURCE_DEPLOYMENTS_DIR}" | ||
else | ||
binary_dir="${S2I_SOURCE_DIR}" | ||
fi | ||
log_info "Copying binaries from ${binary_dir} to ${S2I_TARGET_DEPLOYMENTS_DIR} ..." | ||
|
||
( # OPENJDK-2850: use glob (dotglob to match hidden files) to stop rsync altering | ||
# timestamps of S2I_TARGET_DEPLOYMENTS_DIR. Don't alter parent shell's dotglob. | ||
shopt -s dotglob | ||
rsync --archive --out-format='%n' "${binary_dir}"/* "${S2I_TARGET_DEPLOYMENTS_DIR}" | ||
) | ||
} | ||
|
||
function maven_s2i_deploy_artifacts_override() { | ||
unset -f maven_s2i_deploy_artifacts_override | ||
eval maven_s2i_deploy_artifacts $* | ||
return $? | ||
} |
7 changes: 7 additions & 0 deletions
7
modules/org.eclipse.jkube.s2i/bash/artifacts/opt/jboss/container/java/s2i/s2i-core-hooks
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,7 @@ | ||
|
||
source "${JBOSS_CONTAINER_UTIL_LOGGING_MODULE}/logging.sh" | ||
|
||
# override core variables | ||
function s2i_core_env_init_hook() { | ||
S2I_TARGET_DATA_DIR="${S2I_TARGET_DATA_DIR:-${JAVA_DATA_DIR:-/deployments/data}}" | ||
} |
15 changes: 15 additions & 0 deletions
15
modules/org.eclipse.jkube.s2i/bash/artifacts/usr/local/s2i/assemble
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,15 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
source "${JBOSS_CONTAINER_UTIL_LOGGING_MODULE}/logging.sh" | ||
source "${JBOSS_CONTAINER_MAVEN_S2I_MODULE}/maven-s2i" | ||
|
||
# include our s2i_core_*() overrides/extensions | ||
source "${JBOSS_CONTAINER_JAVA_S2I_MODULE}/s2i-core-hooks" | ||
|
||
# inject our overridden maven_s2i_*() functions | ||
source "${JBOSS_CONTAINER_JAVA_S2I_MODULE}/maven-s2i-overrides" | ||
|
||
# invoke the build | ||
maven_s2i_build |
31 changes: 31 additions & 0 deletions
31
modules/org.eclipse.jkube.s2i/bash/artifacts/usr/local/s2i/run
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,31 @@ | ||
#!/bin/bash | ||
|
||
# Command line arguments given to this script | ||
args="$*" | ||
|
||
source "${JBOSS_CONTAINER_UTIL_LOGGING_MODULE}/logging.sh" | ||
source "${JBOSS_CONTAINER_S2I_CORE_MODULE}/s2i-core" | ||
# include our s2i_core_*() overrides/extensions | ||
source "${JBOSS_CONTAINER_JAVA_S2I_MODULE}/s2i-core-hooks" | ||
|
||
# Global S2I variable setup | ||
s2i_core_env_init | ||
|
||
JAVA_OPTS="${JAVA_OPTS:-${JAVA_OPTIONS}}" | ||
if [ -f "${JBOSS_CONTAINER_JOLOKIA_MODULE}/jolokia-opts" ]; then | ||
# Always include jolokia-opts, which can be empty if switched off via env | ||
JAVA_OPTS="${JAVA_OPTS} $(${JBOSS_CONTAINER_JOLOKIA_MODULE}/jolokia-opts)" | ||
fi | ||
if [ -f "${JBOSS_CONTAINER_PROMETHEUS_MODULE}/prometheus-opts" ]; then | ||
JAVA_OPTS="${JAVA_OPTS} $(source ${JBOSS_CONTAINER_PROMETHEUS_MODULE}/prometheus-opts && get_prometheus_opts)" | ||
fi | ||
export JAVA_OPTS | ||
export JAVA_OPTIONS="$JAVA_OPTS" | ||
|
||
if [ -f "${S2I_TARGET_DEPLOYMENTS_DIR}/bin/run.sh" ]; then | ||
echo "Starting the application using the bundled ${S2I_TARGET_DEPLOYMENTS_DIR}/bin/run.sh ..." | ||
exec ${DEPLOYMENTS_DIR}/bin/run.sh $args ${JAVA_ARGS} | ||
else | ||
echo "Starting the Java application using ${JBOSS_CONTAINER_JAVA_RUN_MODULE}/run-java.sh $args..." | ||
exec "${JBOSS_CONTAINER_JAVA_RUN_MODULE}/run-java.sh" $args ${JAVA_ARGS} | ||
fi |
2 changes: 2 additions & 0 deletions
2
modules/org.eclipse.jkube.s2i/bash/artifacts/usr/local/s2i/usage
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,2 @@ | ||
#!/bin/sh | ||
cat $(dirname $0)/usage.txt |
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,15 @@ | ||
#!/bin/sh | ||
# Configure module | ||
set -e | ||
|
||
SCRIPT_DIR=$(dirname $0) | ||
ARTIFACTS_DIR=${SCRIPT_DIR}/artifacts | ||
|
||
chown -R $USER:root $SCRIPT_DIR | ||
chmod -R ug+rwX $SCRIPT_DIR | ||
chmod ug+x ${ARTIFACTS_DIR}/opt/jboss/container/java/s2i/* | ||
chmod ug+x ${ARTIFACTS_DIR}/usr/local/s2i/* | ||
|
||
pushd ${ARTIFACTS_DIR} | ||
cp -pr * / | ||
popd |
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,30 @@ | ||
schema_version: 1 | ||
name: org.eclipse.jkube.s2i.bash | ||
version: 1.0.0 | ||
description: > | ||
Customization of common Maven S2I for Java S2I image. | ||
Adapted from: | ||
- https://github.com/jboss-container-images/openjdk/blob/d14ec7f363956b73684409c8b6bd9c766507013b/modules/s2i/bash/ | ||
- https://github.com/jboss-openshift/cct_module/tree/f91fb2f80dd880ed7498d4dfc3afb35dfcef60bd/jboss/container/java/s2i/bash | ||
envs: | ||
- name: JBOSS_CONTAINER_JAVA_S2I_MODULE | ||
value: /opt/jboss/container/java/s2i | ||
- name: S2I_SOURCE_DEPLOYMENTS_FILTER | ||
value: "*.jar" | ||
|
||
execute: | ||
- script: configure.sh | ||
|
||
modules: | ||
install: | ||
- name: org.eclipse.jkube.user | ||
- name: org.eclipse.jkube.maven.s2i | ||
- name: org.eclipse.jkube.run.bash | ||
- name: org.eclipse.jkube.prometheus | ||
- name: jboss.container.util.logging.bash | ||
|
||
packages: | ||
install: | ||
- rsync |
151 changes: 151 additions & 0 deletions
151
modules/org.eclipse.jkube.s2i/core/artifacts/opt/jboss/container/s2i/core/s2i-core
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,151 @@ | ||
# include dependencies | ||
source "${JBOSS_CONTAINER_UTIL_LOGGING_MODULE}/logging.sh" | ||
|
||
# initializes the environment used by common s2i_core_*() functions | ||
function s2i_core_init() { | ||
# ensure all files are created with correct permissions for runtime | ||
umask ug+rwx | ||
|
||
# initialize core s2i environmet variables | ||
s2i_core_env_init | ||
|
||
# setup file permissions for injected content | ||
if [ -d "${S2I_ARTIFACTS_DIR}" ]; then | ||
chmod -R ug+rwX "${S2I_ARTIFACTS_DIR}" | ||
fi | ||
if [ -d "${S2I_SOURCE_DIR}" ]; then | ||
chmod -R ug+rwX "${S2I_SOURCE_DIR}" | ||
fi | ||
} | ||
|
||
function s2i_core_env_init() { | ||
# initialize core s2i environmet variables | ||
s2i_core_env_init_hook | ||
S2I_DESTINATION_DIR="${S2I_DESTINATION_DIR:-/tmp}" | ||
S2I_ARTIFACTS_DIR="${S2I_DESTINATION_DIR}/artifacts" | ||
S2I_SOURCE_DIR="${S2I_DESTINATION_DIR}/src" | ||
S2I_SOURCE_CONFIGURATION_DIR="${S2I_SOURCE_CONFIGURATION_DIR:-configuration}" | ||
S2I_SOURCE_DATA_DIR="${S2I_SOURCE_DATA_DIR:-${APP_DATADIR:-data}}" | ||
S2I_SOURCE_DEPLOYMENTS_DIR="${S2I_SOURCE_DEPLOYMENTS_DIR:-deployments}" | ||
S2I_TARGET_DEPLOYMENTS_DIR="${S2I_TARGET_DEPLOYMENTS_DIR:-${DEPLOYMENTS_DIR:-/deployments}}" | ||
S2I_TARGET_CONFIGURATION_DIR="${S2I_TARGET_CONFIGURATION_DIR:-${S2I_TARGET_DEPLOYMENTS_DIR}}" | ||
S2I_TARGET_DATA_DIR="${S2I_TARGET_DATA_DIR:-${JAVA_DATA_DIR:-${DATA_DIR:-${S2I_TARGET_DEPLOYMENTS_DIR}}}}" | ||
S2I_IMAGE_SOURCE_MOUNTS="${S2I_IMAGE_SOURCE_MOUNTS:-${CUSTOM_INSTALL_DIRECTORIES}}" | ||
S2I_ENABLE_INCREMENTAL_BUILDS="${S2I_ENABLE_INCREMENTAL_BUILDS:-true}" | ||
S2I_DELETE_SOURCE="${S2I_DELETE_SOURCE:-true}" | ||
} | ||
|
||
# extensions may override this method to initialize environment variables | ||
# to suit their own needs. | ||
function s2i_core_env_init_hook() { | ||
: | ||
} | ||
|
||
# copy configuration files | ||
# $1 - the base directory to which $S2I_SOURCE_CONFIGURATION_DIR is appended | ||
function s2i_core_copy_configuration() { | ||
if [ -d "${1}/${S2I_SOURCE_CONFIGURATION_DIR}" ]; then | ||
if [ -z "${S2I_TARGET_CONFIGURATION_DIR}" ]; then | ||
log_warning "Unable to copy configuration files. No target directory specified for S2I_TARGET_CONFIGURATION_DIR" | ||
else | ||
if [ ! -d "${S2I_TARGET_CONFIGURATION_DIR}" ]; then | ||
log_info "S2I_TARGET_CONFIGURATION_DIR does not exist, creating ${S2I_TARGET_CONFIGURATION_DIR}" | ||
mkdir -pm 775 "${S2I_TARGET_CONFIGURATION_DIR}" | ||
fi | ||
log_info "Copying configuration from $(realpath --relative-to ${S2I_SOURCE_DIR} ${1}/${S2I_SOURCE_CONFIGURATION_DIR}) to ${S2I_TARGET_CONFIGURATION_DIR}..." | ||
rsync --archive --out-format='%n' "${1}/${S2I_SOURCE_CONFIGURATION_DIR}"/ "${S2I_TARGET_CONFIGURATION_DIR}" | ||
fi | ||
fi | ||
} | ||
|
||
# copy data files | ||
# $1 - the base directory to which $S2I_SOURCE_DATA_DIR is appended | ||
function s2i_core_copy_data() { | ||
if [ -d "${1}/${S2I_SOURCE_DATA_DIR}" ]; then | ||
if [ -z "${S2I_TARGET_DATA_DIR}" ]; then | ||
log_warning "Unable to copy data files. No target directory specified for S2I_TARGET_DATA_DIR" | ||
else | ||
if [ ! -d "${S2I_TARGET_DATA_DIR}" ]; then | ||
log_info "S2I_TARGET_DATA_DIR does not exist, creating ${S2I_TARGET_DATA_DIR}" | ||
mkdir -pm 775 "${S2I_TARGET_DATA_DIR}" | ||
fi | ||
log_info "Copying app data from $(realpath --relative-to ${S2I_SOURCE_DIR} ${1}/${S2I_SOURCE_DATA_DIR}) to ${S2I_TARGET_DATA_DIR}..." | ||
rsync --archive --out-format='%n' "${1}/${S2I_SOURCE_DATA_DIR}"/ "${S2I_TARGET_DATA_DIR}" | ||
# s2i used to be more forgiving, but the build will fail if this call | ||
# fails. emit a warning and allow the build to succeed | ||
chmod -R g+rwX "${S2I_TARGET_DATA_DIR}" || log_warning "Errors occurred while adding read/write permissions to S2I_TARGET_DATA_DIR ($S2I_TARGET_DATA_DIR)." | ||
fi | ||
fi | ||
} | ||
|
||
# copy deployment (binary) files | ||
# $1 - the base directory to which $S2I_SOURCE_DEPLOYMENTS_DIR is appended | ||
function s2i_core_copy_deployments() { | ||
if [ -d "${1}/${S2I_SOURCE_DEPLOYMENTS_DIR}" ]; then | ||
if [ -z "${S2I_TARGET_DEPLOYMENTS_DIR}" ]; then | ||
log_warning "Unable to copy deployment files. No target directory specified for S2I_TARGET_DEPLOYMENTS_DIR" | ||
else | ||
if [ ! -d "${S2I_TARGET_DEPLOYMENTS_DIR}" ]; then | ||
log_info "S2I_TARGET_DEPLOYMENTS_DIR does not exist, creating ${S2I_TARGET_DEPLOYMENTS_DIR}" | ||
mkdir -pm 775 "${S2I_TARGET_DEPLOYMENTS_DIR}" | ||
fi | ||
local relative_source=$(realpath --relative-to "${S2I_SOURCE_DIR}" "${1}/${S2I_SOURCE_DEPLOYMENTS_DIR}") | ||
log_info "Copying deployments from $relative_source to ${S2I_TARGET_DEPLOYMENTS_DIR}..." | ||
for filter in ${S2I_SOURCE_DEPLOYMENTS_FILTER:-*}; do | ||
find "${S2I_SOURCE_DIR}/${relative_source}/" -maxdepth 1 -name "${filter}" | xargs -I '{}' -r cp -Lrpv '{}' "${S2I_TARGET_DEPLOYMENTS_DIR}" | ||
done | ||
fi | ||
fi | ||
} | ||
|
||
# extension may override this method to provide additional copy functions | ||
# $1 - the base directory | ||
function s2i_core_copy_artifacts_hook() { | ||
: | ||
} | ||
|
||
# main entry point for copying artifacts from the build to the target | ||
# $1 - the base directory | ||
function s2i_core_copy_artifacts() { | ||
s2i_core_copy_configuration $* | ||
s2i_core_copy_data $* | ||
s2i_core_copy_deployments $* | ||
s2i_core_copy_artifacts_hook $* | ||
} | ||
|
||
# processes any directories mounted into the build. see S2I_IMAGE_SOURCE_MOUNTS | ||
function s2i_core_process_image_mounts() { | ||
if [ "x${S2I_IMAGE_SOURCE_MOUNTS}" = "x" ]; then | ||
return 0 | ||
fi | ||
|
||
log_info "Processing ImageSource mounts: $S2I_IMAGE_SOURCE_MOUNTS" | ||
IFS=',' read -a install_dir_entries <<< $S2I_IMAGE_SOURCE_MOUNTS | ||
for install_dir_entry in "${install_dir_entries[@]}"; do | ||
for install_dir in $(find ${S2I_SOURCE_DIR}/$install_dir_entry -maxdepth 0 2>/dev/null); do | ||
log_info "Processing ImageSource from $install_dir" | ||
chmod -R ug+x ${install_dir} | ||
if [ -f ${install_dir}/install.sh ]; then | ||
${install_dir}/install.sh "${install_dir}" | ||
else | ||
s2i_core_copy_artifacts "${install_dir}" | ||
fi | ||
done | ||
done | ||
} | ||
|
||
function s2i_core_cleanup() { | ||
if [ "${S2I_DELETE_SOURCE,,}" == "true" ]; then | ||
if [ -n "$(find ${S2I_SOURCE_DIR} -maxdepth 0 -type d ! -empty 2> /dev/null)" ]; then | ||
log_info "Cleaning up source directory (${S2I_SOURCE_DIR})" | ||
rm -rf ${S2I_SOURCE_DIR} | ||
fi | ||
fi | ||
if [ "${S2I_ENABLE_INCREMENTAL_BUILDS,,}" == "true" ]; then | ||
return 0 | ||
fi | ||
if [ -n "$(find ${S2I_ARTIFACTS_DIR} -maxdepth 0 -type d ! -empty 2> /dev/null)" ]; then | ||
log_info "Cleaning up artifacts directory (${S2I_ARTIFACTS_DIR})" | ||
rm -rf ${S2I_ARTIFACTS_DIR} | ||
fi | ||
} |
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,22 @@ | ||
#!/bin/sh | ||
# Configure module | ||
set -e | ||
|
||
SCRIPT_DIR=$(dirname $0) | ||
ARTIFACTS_DIR=${SCRIPT_DIR}/artifacts | ||
|
||
chown -R $USER:root $SCRIPT_DIR | ||
chmod -R ug+rwX $SCRIPT_DIR | ||
chmod ug+x ${ARTIFACTS_DIR}/opt/jboss/container/s2i/core/* | ||
|
||
pushd ${ARTIFACTS_DIR} | ||
cp -pr * / | ||
popd | ||
|
||
mkdir -p /usr/local/s2i \ | ||
&& chmod 775 /usr/local/s2i \ | ||
&& chown -R $USER:root /usr/local/s2i | ||
|
||
mkdir -p /deployments \ | ||
&& chmod -R "ug+rwX" /deployments \ | ||
&& chown -R $USER:root /deployments |
Oops, something went wrong.