c41cd38042e384074b56f143685c9e59c3321c35
[policy/models.git] / models-sim / policy-models-simulators / src / main / package / docker / Dockerfile
1 #
2 # ============LICENSE_START=======================================================
3 # ONAP
4 # ================================================================================
5 # Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
6 # ================================================================================
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
10 #
11 #      http://www.apache.org/licenses/LICENSE-2.0
12 #
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
18 #
19 # SPDX-License-Identifier: Apache-2.0
20 # ============LICENSE_END=========================================================
21 #
22
23 #
24 # Docker file to build an image that runs the simulators
25 #
26
27 FROM onap/policy-jre-alpine:2.0.1
28
29 LABEL maintainer="Policy Team"
30
31 ARG POLICY_LOGS=/var/log/onap/policy/simulators
32
33 ENV POLICY_HOME /opt/app/policy
34 ENV POLICY_LOGS ${POLICY_LOGS}
35
36 # Create DMaaP simulator user and group
37 # Add simulator-specific directories and set ownership as the simulator user
38 RUN mkdir -p ${POLICY_HOME}/simulators \
39     && mkdir -p ${POLICY_HOME}/simulators/bin \
40     && mkdir -p ${POLICY_LOGS} \
41     && mkdir /packages
42
43 # Unpack the tarball
44 COPY policy-models-simulators-tarball.tar.gz /packages
45 RUN tar xvfz /packages/policy-models-simulators-tarball.tar.gz --directory ${POLICY_HOME}/simulators \
46     && rm /packages/policy-models-simulators-tarball.tar.gz
47
48 # Ensure everything has the correct permissions
49 # Copy scripts simulator user area
50 COPY simulators.sh ${POLICY_HOME}/simulators/bin
51 RUN find /opt/app -type d -perm 755 \
52     && find /opt/app -type f -perm 644 \
53     && chmod 755 ${POLICY_HOME}/simulators/bin/* \
54     && chown -R policy:policy $POLICY_HOME $POLICY_LOGS
55
56 USER policy:policy
57
58 ENV PATH ${POLICY_HOME}/simulators/bin:$PATH
59 ENTRYPOINT [ "bash", "simulators.sh" ]