diff --git a/.github/workflows/docker-description.yml b/.github/workflows/docker-description.yml index df8120d..aa42c7e 100644 --- a/.github/workflows/docker-description.yml +++ b/.github/workflows/docker-description.yml @@ -18,5 +18,5 @@ jobs: with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - repository: slominskir/${{ github.event.repository.name }}-weblib + repository: jeffersonlab/${{ github.event.repository.name }} short-description: ${{ github.event.repository.description }} \ No newline at end of file diff --git a/.github/workflows/docker-publish-demo.yml b/.github/workflows/docker-publish-demo.yml deleted file mode 100644 index 2d0f579..0000000 --- a/.github/workflows/docker-publish-demo.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: Publish to DockerHub (Demo) - -on: -# release: -# types: [published] - workflow_dispatch: - -jobs: - push_to_registry: - name: Push Docker image to Docker Hub - runs-on: ubuntu-latest - steps: - - - name: Checkout - uses: actions/checkout@v3 - - - name: Docker meta - id: meta - uses: docker/metadata-action@v4 - with: - images: | - slominskir/${{ github.event.repository.name }}-demo - tags: | - type=semver,pattern={{version}} - - - name: Login to DockerHub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Push to Docker Hub - uses: docker/build-push-action@v3 - with: - file: Dockerfile-demo - push: true - build-args: | - CUSTOM_CRT_URL=http://pki.jlab.org/JLabCA.crt - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index ee00d63..28e4286 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -19,7 +19,7 @@ jobs: uses: docker/metadata-action@v4 with: images: | - slominskir/${{ github.event.repository.name }}-weblib + jeffersonlab/${{ github.event.repository.name }}-demo tags: | type=semver,pattern={{version}} - @@ -32,7 +32,6 @@ jobs: name: Push to Docker Hub uses: docker/build-push-action@v3 with: - file: Dockerfile-weblib push: true build-args: | CUSTOM_CRT_URL=http://pki.jlab.org/JLabCA.crt diff --git a/Dockerfile-demo b/Dockerfile similarity index 59% rename from Dockerfile-demo rename to Dockerfile index 87b4045..4db0ca8 100644 --- a/Dockerfile-demo +++ b/Dockerfile @@ -1,5 +1,5 @@ ARG BUILD_IMAGE=gradle:7.4-jdk17 -ARG RUN_IMAGE=slominskir/smoothness-weblib:3.13.0 +ARG RUN_IMAGE=jeffersonlab/wildfly:1.0.0 ################## Stage 0 FROM ${BUILD_IMAGE} as builder @@ -18,6 +18,13 @@ RUN cd /app && gradle build -x test --no-watch-fs $OPTIONAL_CERT_ARG ################## Stage 1 FROM ${RUN_IMAGE} as runner COPY --from=builder /app/docker/demo/smoothness-demo-setup.env / -RUN /app-setup.sh /smoothness-demo-setup.env \ - && rm -rf /opt/jboss/wildfly/standalone/configuration/standalone_xml_history +USER root +RUN /server-setup.sh /smoothness-demo-setup.env wildfly_start_and_wait \ + && /app-setup.sh /smoothness-demo-setup.env config_keycloak_client \ + && /app-setup.sh /smoothness-demo-setup.env config_oracle_client \ + && /server-setup.sh /smoothness-demo-setup.env config_email \ + && /server-setup.sh /smoothness-demo-setup.env wildfly_reload \ + && /server-setup.sh /smoothness-demo-setup.env wildfly_stop \ + && rm -rf /opt/jboss/wildfly/standalone/configuration/standalone_xml_history \ +USER jboss:jboss COPY --from=builder /app/smoothness-demo/build/libs/* /opt/jboss/wildfly/standalone/deployments \ No newline at end of file diff --git a/Dockerfile-weblib b/Dockerfile-weblib deleted file mode 100644 index 4c0d521..0000000 --- a/Dockerfile-weblib +++ /dev/null @@ -1,63 +0,0 @@ -ARG BUILD_IMAGE=gradle:7.4-jdk17 -ARG RUN_IMAGE=quay.io/wildfly/wildfly:26.1.3.Final-jdk17 -ARG ORACLE_DRIVER_PATH=/ojdbc11-21.7.0.0.jar - -################## Stage 0 -FROM ${BUILD_IMAGE} as builder -ARG CUSTOM_CRT_URL -USER root -WORKDIR / -RUN if [ -z "${CUSTOM_CRT_URL}" ] ; then echo "No custom cert needed"; else \ - wget -O /usr/local/share/ca-certificates/customcert.crt $CUSTOM_CRT_URL \ - && update-ca-certificates \ - && keytool -import -alias custom -file /usr/local/share/ca-certificates/customcert.crt -cacerts -storepass changeit -noprompt \ - && export OPTIONAL_CERT_ARG=--cert=/etc/ssl/certs/ca-certificates.crt \ - ; fi -COPY . /app - -## Let's minimize layers in final-product by organizing files into a single copy structure -RUN mkdir /unicopy \ - && cp /app/docker/weblib/TestOracleConnection.java /unicopy \ - && cp /app/docker/weblib/docker-entrypoint.sh /unicopy \ - && cp /app/docker/weblib/docker-server.env /unicopy \ - && cp /app/bash/wildfly/server-setup.sh /unicopy \ - && cp /app/bash/wildfly/provided-setup.sh /unicopy \ - && cp /app/bash/wildfly/app-setup.sh /unicopy \ - && grep gradle.rootProject.version /app/settings.gradle | tr -s ' ' | cut -d' ' -f3 | tr -d '\047' > /unicopy/version.txt - -################## Stage 1 -FROM ${RUN_IMAGE} as runner -ARG CUSTOM_CRT_URL -ARG INCLUDE_SMOOTH_LIB -ARG RUN_USER=jboss:jboss -ARG ORACLE_DRIVER_PATH -USER root -COPY --from=builder /unicopy / -RUN if [ -z "${CUSTOM_CRT_URL}" ] ; then echo "No custom cert needed"; else \ - curl -sS -o /etc/pki/ca-trust/source/anchors/customcert.crt $CUSTOM_CRT_URL \ - && update-ca-trust \ - && keytool -import -alias custom -file /etc/pki/ca-trust/source/anchors/customcert.crt -cacerts -storepass changeit -noprompt \ - ; fi \ - && yum install -y wget \ - && chsh -s /bin/bash jboss \ - && if [ -z "${INCLUDE_SMOOTH_LIB}" ] ; then echo "Smooth lib excluded"; else \ - echo 'Smooth lib included. This mode is not supported' \ - && SMOOTH_VER=`cat /version.txt | tr -d '\r'` \ - && echo SMOOTH_VER: $SMOOTH_VER \ - && A='GLOBAL_ADD_LIBS=' \ - && A+="'org.jlab.smoothness-weblib" \ - && A+='|https://repo1.maven.org/maven2/org/jlab/smoothness-weblib/' \ - && A+="${SMOOTH_VER}/smoothness-weblib-${SMOOTH_VER}.jar" \ - && A+='|javaee.api,org.jboss.as.web,org.keycloak.admin-client,javax.servlet.jstl.api' \ - && A+="'" \ - && echo "${A}" > /lib.env \ - && echo WILDFLY_APP_HOME=/opt/jboss/wildfly >> /lib.env \ - && echo "cat lib.env: " \ - && cat /lib.env \ - && echo EXTRA_ADD_ENV_FILE=/lib.env >> /docker-server.env \ - ; fi \ - && /server-setup.sh /docker-server.env \ - && rm -rf /opt/jboss/wildfly/standalone/configuration/standalone_xml_history -ENTRYPOINT ["/docker-entrypoint.sh"] -ENV ORACLE_DRIVER_PATH=$ORACLE_DRIVER_PATH -USER ${RUN_USER} \ No newline at end of file diff --git a/README.md b/README.md index a3139d1..2dc0aa1 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# smoothness [![CI](https://github.com/JeffersonLab/smoothness/actions/workflows/ci.yml/badge.svg)](https://github.com/JeffersonLab/smoothness/actions/workflows/ci.yml) [![Docker (weblib)](https://img.shields.io/docker/v/slominskir/smoothness-weblib?sort=semver&label=DockerHub+weblib)](https://hub.docker.com/r/slominskir/smoothness-weblib) [![Docker (demo)](https://img.shields.io/docker/v/slominskir/smoothness-demo?sort=semver&label=DockerHub+demo)](https://hub.docker.com/r/slominskir/smoothness-demo) [![Maven Central](https://badgen.net/maven/v/maven-central/org.jlab/smoothness-weblib)](https://repo1.maven.org/maven2/org/jlab/smoothness-weblib/) +# smoothness [![CI](https://github.com/JeffersonLab/smoothness/actions/workflows/ci.yml/badge.svg)](https://github.com/JeffersonLab/smoothness/actions/workflows/ci.yml) [![Docker (demo)](https://img.shields.io/docker/v/jeffersonlab/smoothness-demo?sort=semver&label=DockerHub+demo)](https://hub.docker.com/r/jeffersonlab/smoothness-demo) [![Maven Central](https://badgen.net/maven/v/maven-central/org.jlab/smoothness-weblib)](https://repo1.maven.org/maven2/org/jlab/smoothness-weblib/) A [Java EE 8](https://en.wikipedia.org/wiki/Jakarta_EE) web application template and [JSP tag library](https://docs.oracle.com/javaee/5/tutorial/doc/bnama.html) based on the [JQuery UI Smoothness](https://jqueryui.com/themeroller/) theme. The included demo web application showcases the template layout. ![Screenshot](https://github.com/JeffersonLab/smoothness/raw/main/smoothness-demo/Screenshot.png?raw=true "Screenshot") @@ -185,41 +185,29 @@ gradlew build **See**: [Docker Development Quick Reference](https://gist.github.com/slominskir/a7da801e8259f5974c978f9c3091d52c#development-quick-reference) ## Release -Since this is a monorepo there are actually two projects: the weblib and the demo of the weblib. Further, both projects have two artifacts: a Java distributable (demo war and weblib jar) and a Docker image. The Docker build is complicated by fact that dependencies generally should be installed directly into Wildfly as opposed to being bundled inside a war file, but the smoothness weblib itself should not and must be packaged inside the war file of each app using the lib. This is necessary as the smoothness weblib is [incompatible as a JBoss Module](https://github.com/JeffersonLab/smoothness/issues/4), plus this bundling makes development of the lib easier as it allows iteration without constantly updating weblib code installed in Wildfly. Since the demo has a dependency on the weblib, either all artifacts needed for both subprojects need to tagged together, else two separate releases would be needed as a release corresponds to a git tag and Docker images are built using the Git tag context. We attempt to avoid needing two tags per release by updating the demo image reference to point to the upcoming release before it even exists. +Since this is a monorepo there are actually two projects: the weblib and the demo of the weblib. Further, both projects have two artifacts: a Java distributable (demo war and weblib jar), plus there is a demo Docker image. -1. During development the build is run locally to ensure everything is working. You can use deps.yml Docker Compose in concert with a local Wildfly instance to quickly iterate. -2. To confirm the new Docker images are good, run the docker build locally for weblib and tag it as SNAPSHOT for testing with demo: -``` -docker build -f Dockerfile-weblib --build-arg CUSTOM_CRT_URL=http://pki.jlab.org/JLabCA.crt . -t weblib:snapshot --no-cache --progress=plain -``` -**Note**: This step could go in the `build.yml` if there was a way to instruct services to depend on each other at BUILD time. Currently `depends_on` only works at runtime (builds are parallel). +Dependencies (libraries) generally should be installed directly into Wildfly as opposed to being bundled inside a war file, but the smoothness weblib itself should not and must be packaged inside the war file of each app using the lib. This is necessary as the smoothness weblib is [incompatible as a JBoss Module](https://github.com/JeffersonLab/smoothness/issues/4), plus this bundling makes development of the lib easier as it allows iteration without constantly updating weblib code installed in Wildfly. Since the demo has a dependency on the weblib, either all artifacts needed for both subprojects need to tagged together, else two separate releases would be needed as a release corresponds to a git tag and Docker images are built using the Git tag context. We use a shared release. -3. Build the "build" compose project that leverages the SNAPSHOT weblib and test it before moving forward: +1. During development the build is run locally to ensure everything is working. You can use deps.yml Docker Compose in concert with a local Wildfly instance to quickly iterate. +2. To confirm the new demo Docker image is good, run the docker build and test locally: ``` docker compose -f build.yml build demo --no-cache --progress=plain ... docker compose -f build.yml up ``` -4. Bump the version number and release date in settings.gradle and commit and push to GitHub (using [Semantic Versioning](https://semver.org/)). -5. Update Dockerfile-demo to use the new weblib image version and commit and push to GitHub. Do this first before creating release else you'll have to create second release since we run Docker build from GitHub tag. - -**WEBLIB** -1. Create a new release on the GitHub [Releases](https://github.com/JeffersonLab/smoothness/releases) page corresponding to same version in settings.gradle (Enumerate changes and link issues). Attach the smoothness-demo.war. -2. Publish new artifact on maven central with: +3. Bump the version number and release date in settings.gradle and commit and push to GitHub (using [Semantic Versioning](https://semver.org/)). +4. Create a new release on the GitHub [Releases](https://github.com/JeffersonLab/smoothness/releases) page corresponding to same version in settings.gradle (Enumerate changes and link issues). Attach the smoothness-demo.war. +5. Publish new artifact on maven central with: ``` gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository ``` **Note**: There is a [GitHub action](https://github.com/JeffersonLab/smoothness/actions/workflows/maven-publish.yml) for this to happen automatically. To run locally you'll need to configure credentials. See: [Gradle Publish Notes](https://gist.github.com/slominskir/5fcd5cf84182bf1542c07cbca953904a) -3. Build and push [Docker image](https://gist.github.com/slominskir/a7da801e8259f5974c978f9c3091d52c#8-build-an-image-based-of-github-tag). For the weblib so use `-f Dockerfile-weblib`. This time we use the github tagged context instead of local `.`. This is automated as a [GitHub Action](https://github.com/JeffersonLab/smoothness/actions/workflows/docker-publish.yml) and should be done automatically on new release published. - -4. Update javadocs and tlddocs by copying them from build dir into gh-pages branch and updating index.html (commit, push). This should occur automatically via [Publish to gh-pages](https://github.com/JeffersonLab/smoothness/actions/workflows/gh-pages-publish.yml) GitHub Action. -5. Copy updated minified JS and CSS to any CDN as needed. - -**DEMO** - -1. Build and push Docker image for the demo `-f Dockerfile-demo`. You must wait for weblib image to post on DockerHub else build on same host with already locally cached weblib image. This is automated as a [GitHub Action](https://github.com/JeffersonLab/smoothness/actions/workflows/docker-publish-demo.yml) but must be manually invoked after the weblib image is published. -2. Bump and commit quick start [image version](https://github.com/JeffersonLab/smoothness/blob/main/docker-compose.override.yml). For the demo. +5. Build and push [Docker image](https://gist.github.com/slominskir/a7da801e8259f5974c978f9c3091d52c#8-build-an-image-based-of-github-tag) for the demo. This time we use the github tagged context instead of local `.`. This is automated as a [GitHub Action](https://github.com/JeffersonLab/smoothness/actions/workflows/docker-publish.yml) and should be done automatically on new release published. +6. Update javadocs and tlddocs by copying them from build dir into gh-pages branch and updating index.html (commit, push). This should occur automatically via [Publish to gh-pages](https://github.com/JeffersonLab/smoothness/actions/workflows/gh-pages-publish.yml) GitHub Action. +7. Copy updated minified JS and CSS to any CDN as needed. +8. Bump and commit quick start [image version](https://github.com/JeffersonLab/smoothness/blob/main/docker-compose.override.yml). For the demo. ## See Also - [Beam authorization manager (BAM)](https://github.com/JeffersonLab/bam) diff --git a/bash/wildfly/app-setup.sh b/bash/wildfly/app-setup.sh deleted file mode 100755 index b26dfe7..0000000 --- a/bash/wildfly/app-setup.sh +++ /dev/null @@ -1,114 +0,0 @@ -#!/bin/bash - -FUNCTIONS=(wildfly_start_and_wait - config_keycloak_client - config_oracle_client - wildfly_reload - wildfly_stop) - -VARIABLES=(KEYCLOAK_REALM - KEYCLOAK_RESOURCE - KEYCLOAK_SECRET - KEYCLOAK_SERVER_URL - KEYCLOAK_WAR - ORACLE_DATASOURCE - ORACLE_PASS - ORACLE_SERVER - ORACLE_SERVICE - ORACLE_USER - WILDFLY_APP_HOME) - -if [[ $# -eq 0 ]] ; then - echo "Usage: $0 [var file] " - echo "The var file arg should be the path to a file with bash variables that will be sourced." - echo "The optional function name arg if provided is the sole function to call, else all functions are invoked sequentially." - printf 'Variables: ' - printf '%s ' "${VARIABLES[@]}" - printf '\n' - printf 'Functions: ' - printf '%s ' "${FUNCTIONS[@]}" - printf '\n' - exit 0 -fi - -if [ ! -z "$1" ] && [ -f "$1" ] -then -echo "Loading environment $1" -. $1 -fi - -# Verify expected env set: -for i in "${!VARIABLES[@]}"; do - var=${VARIABLES[$i]} - [ -z "${!var}" ] && { echo "$var is not set. Exiting."; exit 1; } -done - -# Optional params -# - WILDFLY_SKIP_START -# - WILDFLY_SKIP_STOP - -WILDFLY_CLI_PATH=${WILDFLY_APP_HOME}/bin/jboss-cli.sh - -wildfly_start_and_wait() { -if [[ ! -z "${WILDFLY_SKIP_START}" ]]; then - echo "Skipping Wildfly start because WILDFLY_SKIP_START defined" - return 0 -fi - -${WILDFLY_APP_HOME}/bin/standalone.sh -b 0.0.0.0 -bmanagement 0.0.0.0 & - -until curl http://localhost:8080 -sf -o /dev/null; -do - echo $(date) " Still waiting for Wildfly to start..." - sleep 5 -done - -echo $(date) " Wildfly started!" -} - -config_keycloak_client() { -DEPLOYMENT_CONFIG=principal-attribute="preferred_username",ssl-required=EXTERNAL,resource="${KEYCLOAK_RESOURCE}",realm="${KEYCLOAK_REALM}",auth-server-url=${KEYCLOAK_SERVER_URL} - -${WILDFLY_CLI_PATH} -c <" - echo "The var file arg should be the path to a file with bash variables that will be sourced." - echo "The optional function name arg if provided is the sole function to call, else all functions are invoked sequentially." - printf 'Variables: ' - printf '%s ' "${VARIABLES[@]}" - printf '\n' - printf 'Functions: ' - printf '%s ' "${FUNCTIONS[@]}" - printf '\n' - exit 0 -fi - -if [ ! -z "$1" ] && [ -f "$1" ] -then -echo "Loading environment $1" -. $1 -fi - -# Verify expected env set: -for i in "${!VARIABLES[@]}"; do - var=${VARIABLES[$i]} - [ -z "${!var}" ] && { echo "$var is not set. Exiting."; exit 1; } -done - -WILDFLY_CLI_PATH=${WILDFLY_APP_HOME}/bin/jboss-cli.sh - -deploy() { -cd /tmp -rm -rf /tmp/${WAR_FILE} -wget ${DOWNLOAD_URL} -${WILDFLY_CLI_PATH} -c "deploy --force /tmp/${WAR_FILE}" -} - -if [ ! -z "$2" ] -then - echo "------------------------" - echo "$2" - echo "------------------------" - $2 -else -for i in "${!FUNCTIONS[@]}"; do - echo "------------------------" - echo "${FUNCTIONS[$i]}" - echo "------------------------" - ${FUNCTIONS[$i]}; -done -fi diff --git a/bash/wildfly/pem-to-java-keystore.sh b/bash/wildfly/pem-to-java-keystore.sh deleted file mode 100755 index 74c5a96..0000000 --- a/bash/wildfly/pem-to-java-keystore.sh +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/bash - -FUNCTIONS=(combine_with_intermediate - convert_to_pkcs12 - convert_to_keystore) - -VARIABLES=(KEYSTORE_OUTPUT_PATH - KEYSTORE_PASS - PEM_CERT_PATH - PEM_INTERMEDIATE_CERT_PATH - PEM_KEY_PATH) - -if [[ $# -eq 0 ]] ; then - echo "Usage: $0 [var file] " - echo "The var file arg should be the path to a file with bash variables that will be sourced." - echo "The optional function name arg if provided is the sole function to call, else all functions are invoked sequentially." - printf 'Variables: ' - printf '%s ' "${VARIABLES[@]}" - printf '\n' - printf 'Functions: ' - printf '%s ' "${FUNCTIONS[@]}" - printf '\n' - exit 0 -fi - -if [ ! -z "$1" ] && [ -f "$1" ] -then -echo "Loading environment $1" -. $1 -fi - -# Verify expected env set: -for i in "${!VARIABLES[@]}"; do - var=${VARIABLES[$i]} - [ -z "${!var}" ] && { echo "$var is not set. Exiting."; exit 1; } -done - -combine_with_intermediate() { -cat ${PEM_CERT_PATH} ${PEM_INTERMEDIATE_CERT_PATH} > /tmp/combined.pem -} - -convert_to_pkcs12() { -openssl pkcs12 -export -in /tmp/combined.pem -inkey ${PEM_KEY_PATH} -name combined -password pass:${KEYSTORE_PASS} > /tmp/combined.p12 -} - -convert_to_keystore() { -keytool -importkeystore -srckeystore /tmp/combined.p12 -destkeystore ${KEYSTORE_OUTPUT_PATH} -srcstoretype pkcs12 -alias combined -deststorepass ${KEYSTORE_PASS} -srcstorepass ${KEYSTORE_PASS} -} - -if [ ! -z "$2" ] -then - echo "------------------------" - echo "$2" - echo "------------------------" - $2 -else -for i in "${!FUNCTIONS[@]}"; do - echo "------------------------" - echo "${FUNCTIONS[$i]}" - echo "------------------------" - ${FUNCTIONS[$i]}; -done -fi diff --git a/bash/wildfly/provided-setup.sh b/bash/wildfly/provided-setup.sh deleted file mode 100755 index 8bc1e5b..0000000 --- a/bash/wildfly/provided-setup.sh +++ /dev/null @@ -1,128 +0,0 @@ -#!/bin/bash - -FUNCTIONS=(add_modules - enable_globals) - -VARIABLES=(WILDFLY_APP_HOME) - -if [[ $# -eq 0 ]] ; then - echo "Usage: $0 [var file] " - echo "The var file arg should be the path to a file with bash variables that will be sourced." - echo "The optional function name arg if provided is the sole function to call, else all functions are invoked sequentially." - printf 'Variables: ' - printf '%s ' "${VARIABLES[@]}" - printf '\n' - printf 'Functions: ' - printf '%s ' "${FUNCTIONS[@]}" - printf '\n' - exit 0 -fi - -if [ ! -z "$1" ] && [ -f "$1" ] -then -echo "Loading environment $1" -. $1 -fi - -# Verify expected env set: -for i in "${!VARIABLES[@]}"; do - var=${VARIABLES[$i]} - [ -z "${!var}" ] && { echo "$var is not set. Exiting."; exit 1; } -done - -WILDFLY_CLI_PATH=${WILDFLY_APP_HOME}/bin/jboss-cli.sh - -set_global() { -${WILDFLY_CLI_PATH} -c "/subsystem=ee/:list-add(name=global-modules,value={\"name\"=>\"${MODULE_NAME}\",\"slot\"=>\"main\"})" -} - -add_module() { - -cd /tmp - -LOCAL_RESOURCES=() -IFS="," -read -a resources <<<"${RESOURCES_CSV}" -for x in "${resources[@]}" ;do - #echo "> [$x]" - wget -nv ${x} - LOCAL_RESOURCES+=(/tmp/`basename "${x}"`) -done - -IFS="," -LOCAL_RESOURCES_CSV=`echo "${LOCAL_RESOURCES[*]}"` - -${WILDFLY_CLI_PATH} -c <" - echo "The var file arg should be the path to a file with bash variables that will be sourced." - echo "The optional function name arg if provided is the sole function to call, else all functions are invoked sequentially." - printf 'Variables: ' - printf '%s ' "${VARIABLES[@]}" - printf '\n' - printf 'Functions: ' - printf '%s ' "${FUNCTIONS[@]}" - printf '\n' - exit 0 -fi - -if [ ! -z "$1" ] && [ -f "$1" ] -then -echo "Loading environment $1" -. $1 -fi - -# Verify expected env set: -for i in "${!VARIABLES[@]}"; do - var=${VARIABLES[$i]} - [ -z "${!var}" ] && { echo "$var is not set. Exiting."; exit 1; } -done - -WILDFLY_APP_HOME=${WILDFLY_USER_HOME}/${WILDFLY_VERSION} - -remove_java_11() { -# We're assuming this leaves only JDK17 -yum remove java-11-openjdk-headless -y -alternatives --auto java -} - -create_user_and_group() { -groupadd -r -g ${WILDFLY_GROUP_ID} ${WILDFLY_GROUP} -useradd -r -m -u ${WILDFLY_USER_ID} -g ${WILDFLY_GROUP_ID} -d ${WILDFLY_USER_HOME} -s /bin/bash ${WILDFLY_USER} -} - -download() { -cd /tmp -wget https://github.com/wildfly/wildfly/releases/download/${WILDFLY_VERSION}/wildfly-${WILDFLY_VERSION}.zip -} - -unzip_and_chmod() { -unzip /tmp/wildfly-${WILDFLY_VERSION}.zip -d ${WILDFLY_USER_HOME} -mv ${WILDFLY_USER_HOME}/wildfly-${WILDFLY_VERSION} ${WILDFLY_APP_HOME} -chown -R ${WILDFLY_USER}:${WILDFLY_GROUP} ${WILDFLY_USER_HOME} -} - -create_symbolic_links() { -cd ${WILDFLY_USER_HOME} -ln -s ${WILDFLY_VERSION} current -ln -s current/standalone/configuration configuration -ln -s current/standalone/log log -} - -adjust_jvm_options() { -sed -i "s|#JAVA_HOME=\"/opt/java/jdk\"|JAVA_HOME=\"${JDK_HOME}\"|g" ${WILDFLY_APP_HOME}/bin/standalone.conf -sed -i "s/MaxMetaspaceSize=256m/MaxMetaspaceSize=${JDK_MAX_META}/g" ${WILDFLY_APP_HOME}/bin/standalone.conf -sed -i "s/Xmx512m/Xmx${JDK_MAX_HEAP}/g" ${WILDFLY_APP_HOME}/bin/standalone.conf -} - -create_systemd_service() { -if (( ${WILDFLY_HTTPS_PORT} < 1024 )) -then - sysctl -w net.ipv4.ip_unprivileged_port_start=${WILDFLY_HTTPS_PORT} >> /etc/sysctl.conf -fi - -cat > /etc/systemd/system/wildfly.service << EOF -[Unit] -Description=The WildFly Application Server -After=syslog.target network.target -Before=httpd.service -[Service] -EnvironmentFile=${WILDFLY_USER_HOME}/configuration/run.env -Environment=LAUNCH_JBOSS_IN_BACKGROUND=1 -User=${WILDFLY_USER} -LimitNOFILE=102642 -PIDFile=/run/wildfly.pid -ExecStart=${WILDFLY_USER_HOME}/current/bin/standalone.sh -b ${WILDFLY_BIND_ADDRESS} -Djboss.https.port=${WILDFLY_HTTPS_PORT} -StandardOutput=null -[Install] -WantedBy=multi-user.target -EOF -systemctl enable wildfly -} - -create_log_file_cleanup_cron() { -cat > /root/delete-old-wildfly-logs.sh << EOF -#!/bin/sh -if [ -d ${WILDFLY_USER_HOME}/log ] ; then - /usr/bin/find ${WILDFLY_USER_HOME}/log/ -mtime +30 -exec /usr/bin/rm {} \; -fi -EOF -chmod +x /root/delete-old-wildfly-logs.sh -cat > /etc/cron.d/delete-old-wildfly-logs.cron << EOF -0 0 * * * /root/delete-old-wildfly-logs.sh >/dev/null 2>&1 -EOF -} - -if [ ! -z "$2" ] -then - echo "------------------------" - echo "$2" - echo "------------------------" - $2 -else -for i in "${!FUNCTIONS[@]}"; do - echo "------------------------" - echo "${FUNCTIONS[$i]}" - echo "------------------------" - ${FUNCTIONS[$i]}; -done -fi diff --git a/bash/wildfly/server-setup.sh b/bash/wildfly/server-setup.sh deleted file mode 100755 index 7748101..0000000 --- a/bash/wildfly/server-setup.sh +++ /dev/null @@ -1,248 +0,0 @@ -#!/bin/bash - -FUNCTIONS=(apply_elytron_patch - wildfly_start_and_wait - config_oracle_driver - config_access_log - config_admin_user - config_ssl - config_gzip - config_email - config_persist_sessions_on_redeploy - config_param_limits - config_provided - config_extra_provided - config_proxy - wildfly_reload - wildfly_stop) - -VARIABLES=(EMAIL_FROM - EMAIL_HOST - EMAIL_PORT - ORACLE_DRIVER_PATH - ORACLE_DRIVER_URL - WILDFLY_APP_HOME - WILDFLY_RUN_USER - WILDFLY_USER - WILDFLY_PASS) - -if [[ $# -eq 0 ]] ; then - echo "Usage: $0 [var file] " - echo "The var file arg should be the path to a file with bash variables that will be sourced." - echo "The optional function name arg if provided is the sole function to call, else all functions are invoked sequentially." - printf 'Variables: ' - printf '%s ' "${VARIABLES[@]}" - printf '\n' - printf 'Functions: ' - printf '%s ' "${FUNCTIONS[@]}" - printf '\n' - exit 0 -fi - -if [ ! -z "$1" ] && [ -f "$1" ] -then -echo "Loading environment $1" -. $1 -fi - -# Verify expected env set: -for i in "${!VARIABLES[@]}"; do - var=${VARIABLES[$i]} - [ -z "${!var}" ] && { echo "$var is not set. Exiting."; exit 1; } -done - -# Optional params -# - PROVIDED_LIBS -# - MAX_PARAM_COUNT -# - KEYSTORE_NAME -# - KEYSTORE_PASS -# - PERSISTENT_SESSIONS -# - WILDFLY_SKIP_START -# - WILDFLY_SKIP_STOP - -WILDFLY_CLI_PATH=${WILDFLY_APP_HOME}/bin/jboss-cli.sh -MAIN_ENV_FILE=$1 - -wildfly_start_and_wait() { -if [[ ! -z "${WILDFLY_SKIP_START}" ]]; then - echo "Skipping Wildfly start because WILDFLY_SKIP_START defined" - return 0 -fi - -su ${WILDFLY_RUN_USER} -c "${WILDFLY_APP_HOME}/bin/standalone.sh -b 0.0.0.0 -bmanagement 0.0.0.0 &" - -until curl http://localhost:8080 -sf -o /dev/null; -do - echo $(date) " Still waiting for Wildfly to start..." - sleep 5 -done - -echo $(date) " Wildfly started!" -} - -config_oracle_driver() { -if [[ -z "${ORACLE_DRIVER_PATH}" ]]; then - echo "Skipping Oracle Driver Setup: Must provide ORACLE_DRIVER_PATH in environment" - return 0 -fi - -wget -O "${ORACLE_DRIVER_PATH}" "${ORACLE_DRIVER_URL}" - -${WILDFLY_CLI_PATH} -c < 1 && "true".equals(args[1])) { - t.printStackTrace(); - } - System.exit(-1); - } - } -} \ No newline at end of file diff --git a/docker/weblib/docker-entrypoint.sh b/docker/weblib/docker-entrypoint.sh deleted file mode 100755 index 277176c..0000000 --- a/docker/weblib/docker-entrypoint.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash - -echo "----------------------------------------------------" -echo "| Step 1: Waiting for Oracle DB to start listening |" -echo "----------------------------------------------------" -if [[ -n ${ORACLE_USER} && -n ${ORACLE_PASS} && -n ${ORACLE_SERVER} && -n ${ORACLE_SERVICE} && -n ${ORACLE_DRIVER_PATH} ]]; then - - until java -cp "/:${ORACLE_DRIVER_PATH}" \ - /TestOracleConnection.java "jdbc:oracle:thin:${ORACLE_USER}/${ORACLE_PASS}@${ORACLE_SERVER}/${ORACLE_SERVICE}" "${DB_DEBUG}" - do - echo $(date) " Still waiting for Oracle to start..." - sleep 5 - done - - echo $(date) " Oracle connection successful!" -else - echo $(date) " Skipping DB Wait" -fi - -echo "----------------------------" -echo "| Step 2: Starting Wildfly |" -echo "----------------------------" - -/opt/jboss/wildfly/bin/standalone.sh -b 0.0.0.0 -bmanagement 0.0.0.0 & - -until curl http://localhost:8080 -sf -o /dev/null; -do - echo $(date) " Still waiting for Wildfly to start..." - sleep 5 -done - -echo $(date) " Wildfly started!" - -sleep infinity \ No newline at end of file diff --git a/docker/weblib/docker-server.env b/docker/weblib/docker-server.env deleted file mode 100644 index 3f00957..0000000 --- a/docker/weblib/docker-server.env +++ /dev/null @@ -1,13 +0,0 @@ -EMAIL_FROM=tester@example.com -EMAIL_HOST=mailhog -EMAIL_PORT=1025 -ORACLE_DRIVER_URL=https://repo1.maven.org/maven2/com/oracle/database/jdbc/ojdbc11/21.7.0.0/ojdbc11-21.7.0.0.jar -WILDFLY_APP_HOME=/opt/jboss/wildfly -WILDFLY_RUN_USER=jboss -WILDFLY_PASS=admin -WILDFLY_USER=admin -APPLY_ELYTRON_PATCH=defined -ADD_JBOSS_MODULES='local|org.apache.poi|https://repo1.maven.org/maven2/org/apache/poi/poi/5.2.3/poi-5.2.3.jar,https://repo1.maven.org/maven2/org/apache/poi/poi-ooxml/5.2.3/poi-ooxml-5.2.3.jar,https://repo1.maven.org/maven2/org/apache/poi/poi-ooxml-lite/5.2.3/poi-ooxml-lite-5.2.3.jar,https://repo1.maven.org/maven2/org/apache/xmlbeans/xmlbeans/5.1.1/xmlbeans-5.1.1.jar,https://repo1.maven.org/maven2/org/apache/commons/commons-math3/3.6.1/commons-math3-3.6.1.jar,https://repo1.maven.org/maven2/org/apache/commons/commons-compress/1.22/commons-compress-1.22.jar,https://repo1.maven.org/maven2/com/zaxxer/SparseBitSet/1.2/SparseBitSet-1.2.jar,https://repo1.maven.org/maven2/org/apache/commons/commons-collections4/4.4/commons-collections4-4.4.jar|javaee.api,org.jboss.as.web,org.apache.commons.io,org.apache.commons.codec,org.apache.logging.log4j.api -global|org.tuckey.urlrewritefilter|https://repo1.maven.org/maven2/org/tuckey/urlrewritefilter/4.0.4/urlrewritefilter-4.0.4.jar|javaee.api,org.jboss.as.web -global|org.jlab.jlog|https://repo1.maven.org/maven2/org/jlab/jlog/5.0.0/jlog-5.0.0.jar|javaee.api,org.jboss.as.web -global|org.keycloak.admin-client|https://repo1.maven.org/maven2/org/keycloak/keycloak-admin-client/20.0.5/keycloak-admin-client-20.0.5.jar,https://repo1.maven.org/maven2/org/keycloak/keycloak-core/20.0.5/keycloak-core-20.0.5.jar,https://repo1.maven.org/maven2/org/keycloak/keycloak-common/20.0.5/keycloak-common-20.0.5.jar|org.jboss.ws.api,javax.ws.rs.api,org.jboss.logging,org.jboss.resteasy.resteasy-client,org.jboss.resteasy.resteasy-jackson2-provider,org.jboss.resteasy.resteasy-jaxb-provider,org.jboss.resteasy.resteasy-multipart-provider'