Skip to content

Commit 50d7626

Browse files
authored
Merge pull request #14 from PublicisSapient/test-management-devops
added deployment file for init
2 parents 25d1f65 + 25cbbd5 commit 50d7626

File tree

2 files changed

+110
-0
lines changed

2 files changed

+110
-0
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Use a base image
2+
FROM amazoncorretto:17
3+
4+
# Create a non-root user
5+
ARG USER=knowhowuser
6+
ARG UID=1000
7+
ARG GID=1000
8+
9+
RUN ln -sf /bin/bash /bin/sh \
10+
&& yum install -y shadow-utils \
11+
&& groupadd -g $GID $USER \
12+
&& useradd -u $UID -g $GID -m -s /bin/bash $USER \
13+
&& yum clean all -y
14+
15+
# Set environment variables for volumes
16+
ENV APP_DIR="/app" \
17+
PROPERTIES_DIR="/app/properties" \
18+
keytoolalias="myknowhow" \
19+
certhostpath="/app/certs/" \
20+
keystorefile="/usr/lib/jvm/java-17-amazon-corretto/lib/security/cacerts" \
21+
JAVA_OPTS=""
22+
23+
# Define environment variables to control which jars to run (can be set during container run)
24+
ENV RUN_ZEPHYR=true \
25+
RUN_JIRATEST=true
26+
27+
# Set the working directory
28+
WORKDIR $APP_DIR
29+
30+
# Create the volumes
31+
VOLUME $PROPERTIES_DIR
32+
33+
# Set the JAR file variables
34+
ARG ZEPHYR_JAR_FILE=zephyr-processor-exec.jar
35+
ARG JIRA_TEST_JAR_FILE=jiratest-processor-exec.jar
36+
37+
# Set the properties file names
38+
ARG ZEPHYR_PROPERTIES_FILE_NAME=zephyr.properties
39+
ARG JIRATEST_PROPERTIES_FILE_NAME=jiratest.properties
40+
41+
# Copy JAR files
42+
ADD ${ZEPHYR_JAR_FILE} $APP_DIR/zephyr.jar
43+
ADD ${JIRA_TEST_JAR_FILE} $APP_DIR/jiratest.jar
44+
45+
46+
# Expose ports
47+
EXPOSE 50001
48+
EXPOSE 50020
49+
50+
# Copy startup script
51+
ADD test-management-processor-deployment/init-services.sh $APP_DIR/init-services.sh
52+
53+
# Set the ownership of the working directory to the non-root user
54+
RUN chown -R $USER:$USER $APP_DIR \
55+
&& chmod +x $APP_DIR/init-services.sh \
56+
&& chmod 766 $keystorefile
57+
58+
# Switch to the non-root user
59+
USER $USER:$GID
60+
61+
# Command to run the application
62+
CMD ["sh", "init-services.sh"]
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/bash
2+
################################################################################
3+
# Copyright 2014 CapitalOne, LLC.
4+
# Further development Copyright 2022 Sapient Corporation.
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#
18+
################################################################################
19+
20+
counter=1
21+
22+
# Loop through each certificate file and import it to the keystore with an incrementing alias
23+
for cert_file in $certhostpath/*.cer
24+
do
25+
# Generate the alias for the certificate
26+
alias="$keytoolalias$counter"
27+
echo -e "\033[32m"
28+
# Import the certificate to the keystore
29+
keytool -importcert -keystore "$keystorefile" -storepass changeit -alias "$alias" -file "$cert_file" -noprompt -v
30+
echo -e "\033[0m"
31+
# Increment the counter
32+
counter=$((counter+1))
33+
echo "Imported $cert_file to $keystorefile as $alias."
34+
done
35+
36+
# Conditionally run the JAR files based on environment variables
37+
38+
if [ "$RUN_ZEPHYR" == "true" ]; then
39+
java -jar zephyr.jar --spring.config.location=classpath:/BOOT-INF/classes/application.properties --spring.config.additional-location=optional:file:/app/properties/zephyr.properties &
40+
echo "Running Zephyr processor..."
41+
fi
42+
43+
if [ "$RUN_JIRATEST" == "true" ]; then
44+
java -jar jiratest.jar --spring.config.location=classpath:/BOOT-INF/classes/application.properties --spring.config.additional-location=optional:file:/app/properties/jiratest.properties &
45+
echo "Running Jira Test processor..."
46+
fi
47+
48+
wait

0 commit comments

Comments
 (0)