Add DCAE MOD design tool project
[dcaegen2/platform.git] / mod / designtool / designtool-web / Dockerfile
1 # ============LICENSE_START=====================================================
2 # Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
3 # ==============================================================================
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #      http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 # ============LICENSE_END=======================================================
16
17 FROM apache/nifi:${nifi.version} as original
18
19 FROM openjdk:8 as artifactbase
20
21 ENV NIFI_BASE_DIR /opt/nifi
22
23 COPY --from=original $NIFI_BASE_DIR $NIFI_BASE_DIR
24
25 ADD sh/ /tmp/patches
26
27 COPY target/designtool-web-${project.version}.war /tmp/patches
28
29 RUN bash /tmp/patches/applypatches.sh ${project.version} ${nifi.version}
30
31 FROM openjdk:8-jre
32
33 ARG UID=1000
34 ARG GID=1000
35
36 ENV NIFI_BASE_DIR /opt/nifi
37 ENV NIFI_HOME ${NIFI_BASE_DIR}/nifi-current
38 ENV NIFI_TOOLKIT_HOME ${NIFI_BASE_DIR}/nifi-toolkit-current
39 ENV NIFI_PID_DIR=${NIFI_HOME}/run
40 ENV NIFI_LOG_DIR=${NIFI_HOME}/logs
41
42 # Setup NiFi user and create necessary directories
43 RUN groupadd -g ${GID} nifi || groupmod -n nifi `getent group ${GID} | cut -d: -f1` \
44     && useradd --shell /bin/bash -u ${UID} -g ${GID} -m nifi \
45     && apt-get update \
46     && apt-get install -y jq xmlstarlet procps
47
48 COPY --chown=nifi:nifi --from=artifactbase $NIFI_BASE_DIR $NIFI_BASE_DIR
49
50 VOLUME ${NIFI_LOG_DIR} \
51        ${NIFI_HOME}/conf \
52        ${NIFI_HOME}/database_repository \
53        ${NIFI_HOME}/flowfile_repository \
54        ${NIFI_HOME}/content_repository \
55        ${NIFI_HOME}/provenance_repository \
56        ${NIFI_HOME}/state
57
58 USER nifi
59
60 # Clear nifi-env.sh in favour of configuring all environment variables in the Dockerfile
61 RUN echo "#!/bin/sh\n" > $NIFI_HOME/bin/nifi-env.sh
62
63 # Web HTTP(s) & Socket Site-to-Site Ports
64 EXPOSE 8080 8443 10000
65
66 WORKDIR ${NIFI_HOME}
67
68 # Apply configuration and start NiFi
69 #
70 # We need to use the exec form to avoid running our command in a subshell and omitting signals,
71 # thus being unable to shut down gracefully:
72 # https://docs.docker.com/engine/reference/builder/#entrypoint
73 #
74 # Also we need to use relative path, because the exec form does not invoke a command shell,
75 # thus normal shell processing does not happen:
76 # https://docs.docker.com/engine/reference/builder/#exec-form-entrypoint-example
77 ENTRYPOINT ["../scripts/start.sh"]