Chore: Add gerrit maven verify GHA workflow
[sdnc/oam.git] / installation / sdnc / src / main / docker / Dockerfile
1 # Prepare stage for multistage image build
2 ## START OF STAGE0 ##
3 FROM onap/ccsdk-odlsli-alpine-image:${ccsdk.docker.version} AS stage0
4 USER root
5
6 ENV JAVA_HOME /opt/java/openjdk
7 ENV PATH $PATH:/opt/java/openjdk/bin
8
9 ENV SDNC_CONFIG_DIR /opt/onap/sdnc/data/properties
10 ENV SDNC_STORE_DIR /opt/onap/sdnc/data/stores
11 ENV JAVA_SECURITY_DIR /opt/java/openjdk/lib/security
12
13 ENV SDNC_KEYSTORE ${sdnc.keystore}
14 ENV SDNC_KEYPASS ${sdnc.keypass}
15 ENV SDNC_SECUREPORT ${sdnc.secureport}
16
17 ARG AAF=false
18
19 # Copy deliverables to opt
20 COPY opt /opt
21 RUN test -L /opt/sdnc || ln -s /opt/onap/sdnc /opt/sdnc
22 RUN mkdir $ODL_HOME/current/certs
23
24 # Copy SDNC mvn artifacts to ODL repository
25 COPY system /tmp/system
26 RUN rsync -a /tmp/system $ODL_HOME
27
28 # Backing up existing karaf cfg and updating features boot and features repositories defined in pom.xml
29 RUN cp $ODL_HOME/etc/org.apache.karaf.features.cfg $ODL_HOME/etc/org.apache.karaf.features.cfg.sdnc.orig
30 RUN sed -i -e "\|featuresBoot[^a-zA-Z]|s|$|,${sdnc.features.boot}|" $ODL_HOME/etc/org.apache.karaf.features.cfg
31 RUN sed -i -e "\|featuresRepositories|s|$|,${sdnr.features.repo},${sdnc.features.repo}|" $ODL_HOME/etc/org.apache.karaf.features.cfg
32
33 # Add odl-netconf-topology to boot repositories
34 RUN sed -i "s/odl-restconf-all/odl-restconf-all,odl-netconf-topology/g"  $ODL_HOME/etc/org.apache.karaf.features.cfg
35
36 # Add aaa-app-config.xml Only if AAF is set to true (being passed as an argument in docker-maven-plugin configuration)
37 COPY aaa-app-config.xml /tmp/aaa-app-config.xml
38 RUN if "${AAF}" ; then \
39         mkdir -p $ODL_HOME/etc/opendaylight/datastore/initial/config ;\
40         mv /tmp/aaa-app-config.xml $ODL_HOME/etc/opendaylight/datastore/initial/config/. ;\
41         echo "cadi_prop_files=$SDNC_CONFIG_DIR/org.onap.sdnc.props" >> $ODL_HOME/etc/system.properties ;\
42     fi
43
44 # Install ssl and java certificates
45 COPY truststoreONAPall.jks $SDNC_STORE_DIR
46 RUN if [ -f $JAVA_SECURITY_DIR}/cacerts ] ; then keytool -importkeystore -srckeystore $SDNC_STORE_DIR/truststoreONAPall.jks -srcstorepass changeit -destkeystore $JAVA_SECURITY_DIR/cacerts  -deststorepass changeit -noprompt ; fi
47 RUN keytool -importkeystore -srckeystore $SDNC_STORE_DIR/truststoreONAPall.jks -srcstorepass changeit -destkeystore /opt/java/openjdk/lib/security/cacerts  -deststorepass changeit -noprompt
48
49 # Secure with TLS
50 #RUN echo org.osgi.service.http.secure.enabled=true >> $ODL_HOME/etc/custom.properties
51 RUN echo org.osgi.service.http.secure.port=$SDNC_SECUREPORT >> $ODL_HOME/etc/custom.properties
52 RUN echo org.ops4j.pax.web.ssl.keystore=$SDNC_STORE_DIR/$SDNC_KEYSTORE >> $ODL_HOME/etc/custom.properties
53 RUN echo org.ops4j.pax.web.ssl.password=\"$SDNC_KEYPASS\" >> $ODL_HOME/etc/custom.properties
54 RUN echo org.ops4j.pax.web.ssl.keypassword=\"$SDNC_KEYPASS\" >> $ODL_HOME/etc/custom.properties
55
56 # Overwrite svclogic compiler properties
57 RUN cp /opt/onap/sdnc/data/properties/svclogic-compiler.properties /opt/onap/sdnc/svclogic/config/svclogic.properties
58
59 # Short term fix starts: for javax.servlet-api bundle (Replacing 4.0.1 to 3.1.0 as it's unique for javax.servlet-api)
60 RUN find /opt/opendaylight -name "*features*.xml" -exec sed -i -e 's|4.0.1|3.1.0|g' {} \;
61 # Short term fix ends
62
63 # Remediate log4shell vuln
64 RUN apk add zip
65 RUN find /opt/opendaylight/system/org/ops4j/pax/logging/pax-logging-log4j2 -name 'pax-logging-log4j2*.jar' -exec zip -q -d '{}' org/apache/logging/log4j/core/lookup/JndiLookup.class \;
66
67
68 # Changing ownership and permission of /opt
69 RUN chown -R odl:odl /opt && chmod -R 755 /opt
70
71
72
73 ## END OF STAGE0 ##
74
75 #################################################
76
77 ## This will create actual image
78 FROM scratch
79 LABEL maintainer="SDN-C Team (sdnc@lists.onap.org)"
80 USER root
81
82 ENV LC_ALL=en_US.UTF-8 \
83     JAVA_HOME=/opt/java/openjdk \
84     PATH=$PATH:/opt/java/openjdk/bin \
85     ODL_HOME=/opt/opendaylight/current \
86     SDNC_CONFIG_DIR=/opt/onap/sdnc/data/properties \
87     SDNC_KEYSTORE=${sdnc.keystore} \
88     SDNC_KEYPASS=${sdnc.keypass}
89
90 # Copy Everything from stage0
91 COPY --from=stage0 / /
92
93 USER odl
94 EXPOSE 8181
95 WORKDIR ${ODL_HOME}
96 ENTRYPOINT /opt/onap/sdnc/bin/startODL.sh