OpenSuse docker file for policy API
[policy/api.git] / packages / policy-api-docker / src / main / docker / policy-api.sh
1 #!/usr/bin/env sh
2 #
3 # ============LICENSE_START=======================================================
4 #  Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
5 #  Modifications Copyright (C) 2019-2022 Nordix Foundation.
6 #  Modifications Copyright (C) 2022 Bell Canada. All rights reserved.
7 # ================================================================================
8 # Licensed under the Apache License, Version 2.0 (the "License");
9 # you may not use this file except in compliance with the License.
10 # You may obtain a copy of the License at
11 #
12 #      http://www.apache.org/licenses/LICENSE-2.0
13 #
14 # Unless required by applicable law or agreed to in writing, software
15 # distributed under the License is distributed on an "AS IS" BASIS,
16 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 # See the License for the specific language governing permissions and
18 # limitations under the License.
19 #
20 # SPDX-License-Identifier: Apache-2.0
21 # ============LICENSE_END=========================================================
22 #
23
24 KEYSTORE="${KEYSTORE:-$POLICY_HOME/etc/ssl/policy-keystore}"
25 TRUSTSTORE="${TRUSTSTORE:-$POLICY_HOME/etc/ssl/policy-truststore}"
26 KEYSTORE_PASSWD="${KEYSTORE_PASSWD:-Pol1cy_0nap}"
27 TRUSTSTORE_PASSWD="${TRUSTSTORE_PASSWD:-Pol1cy_0nap}"
28
29 if [ "$#" -eq 1 ]; then
30     CONFIG_FILE=$1
31 else
32     CONFIG_FILE=${CONFIG_FILE}
33 fi
34
35 if [ -z "$CONFIG_FILE" ]; then
36     CONFIG_FILE="${POLICY_HOME}/etc/apiParameters.yaml"
37 fi
38
39 echo "Policy api config file: $CONFIG_FILE"
40
41 if [ -f "${POLICY_HOME}/etc/mounted/policy-truststore" ]; then
42     echo "overriding policy-truststore"
43     cp -f "${POLICY_HOME}"/etc/mounted/policy-truststore "${TRUSTSTORE}"
44 fi
45
46 if [ -f "${POLICY_HOME}/etc/mounted/policy-keystore" ]; then
47     echo "overriding policy-keystore"
48     cp -f "${POLICY_HOME}"/etc/mounted/policy-keystore "${KEYSTORE}"
49 fi
50
51 if [ -f "${POLICY_HOME}/etc/mounted/logback.xml" ]; then
52     echo "overriding logback.xml"
53     cp -f "${POLICY_HOME}"/etc/mounted/logback.xml "${POLICY_HOME}"/etc/
54 fi
55
56 $JAVA_HOME/bin/java \
57     -Dlogging.config="${POLICY_HOME}/etc/logback.xml" \
58     -Dserver.ssl.key-store="${KEYSTORE}" \
59     -Dserver.ssl.key-store-password="${KEYSTORE_PASSWD}" \
60     -Djavax.net.ssl.trustStore="${TRUSTSTORE}" \
61     -Djavax.net.ssl.trustStorePassword="${TRUSTSTORE_PASSWD}" \
62     -jar /app/api.jar \
63     --spring.config.location="${CONFIG_FILE}"