diff --git a/test-management-processor-deployment/Dockerfile b/test-management-processor-deployment/Dockerfile new file mode 100644 index 000000000..d80abe2af --- /dev/null +++ b/test-management-processor-deployment/Dockerfile @@ -0,0 +1,62 @@ +# Use a base image +FROM amazoncorretto:17 + +# Create a non-root user +ARG USER=knowhowuser +ARG UID=1000 +ARG GID=1000 + +RUN ln -sf /bin/bash /bin/sh \ + && yum install -y shadow-utils \ + && groupadd -g $GID $USER \ + && useradd -u $UID -g $GID -m -s /bin/bash $USER \ + && yum clean all -y + +# Set environment variables for volumes +ENV APP_DIR="/app" \ + PROPERTIES_DIR="/app/properties" \ + keytoolalias="myknowhow" \ + certhostpath="/app/certs/" \ + keystorefile="/usr/lib/jvm/java-17-amazon-corretto/lib/security/cacerts" \ + JAVA_OPTS="" + +# Define environment variables to control which jars to run (can be set during container run) +ENV RUN_ZEPHYR=true \ + RUN_JIRATEST=true + +# Set the working directory +WORKDIR $APP_DIR + +# Create the volumes +VOLUME $PROPERTIES_DIR + +# Set the JAR file variables +ARG ZEPHYR_JAR_FILE=zephyr-processor-exec.jar +ARG JIRA_TEST_JAR_FILE=jiratest-processor-exec.jar + +# Set the properties file names +ARG ZEPHYR_PROPERTIES_FILE_NAME=zephyr.properties +ARG JIRATEST_PROPERTIES_FILE_NAME=jiratest.properties + +# Copy JAR files +ADD ${ZEPHYR_JAR_FILE} $APP_DIR/zephyr.jar +ADD ${JIRA_TEST_JAR_FILE} $APP_DIR/jiratest.jar + + +# Expose ports +EXPOSE 50001 +EXPOSE 50020 + +# Copy startup script +ADD test-management-processor-deployment/init-services.sh $APP_DIR/init-services.sh + +# Set the ownership of the working directory to the non-root user +RUN chown -R $USER:$USER $APP_DIR \ + && chmod +x $APP_DIR/init-services.sh \ + && chmod 766 $keystorefile + +# Switch to the non-root user +USER $USER:$GID + +# Command to run the application +CMD ["sh", "init-services.sh"] \ No newline at end of file diff --git a/test-management-processor-deployment/init-services.sh b/test-management-processor-deployment/init-services.sh new file mode 100644 index 000000000..9c5a7fed6 --- /dev/null +++ b/test-management-processor-deployment/init-services.sh @@ -0,0 +1,48 @@ +#!/bin/bash +################################################################################ +# Copyright 2014 CapitalOne, LLC. +# Further development Copyright 2022 Sapient Corporation. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +################################################################################ + +counter=1 + +# Loop through each certificate file and import it to the keystore with an incrementing alias +for cert_file in $certhostpath/*.cer +do + # Generate the alias for the certificate + alias="$keytoolalias$counter" + echo -e "\033[32m" + # Import the certificate to the keystore + keytool -importcert -keystore "$keystorefile" -storepass changeit -alias "$alias" -file "$cert_file" -noprompt -v + echo -e "\033[0m" + # Increment the counter + counter=$((counter+1)) + echo "Imported $cert_file to $keystorefile as $alias." +done + +# Conditionally run the JAR files based on environment variables + +if [ "$RUN_ZEPHYR" == "true" ]; then + java -jar zephyr.jar --spring.config.location=classpath:/BOOT-INF/classes/application.properties --spring.config.additional-location=optional:file:/app/properties/zephyr.properties & + echo "Running Zephyr processor..." +fi + +if [ "$RUN_JIRATEST" == "true" ]; then + java -jar jiratest.jar --spring.config.location=classpath:/BOOT-INF/classes/application.properties --spring.config.additional-location=optional:file:/app/properties/jiratest.properties & + echo "Running Jira Test processor..." +fi + +wait \ No newline at end of file