Containers should not run as root by default
[aai/data-router.git] / src / main / docker / Dockerfile
1 FROM @aai.docker.namespace@/aai-common-@aai.base.image@:@aai.base.image.version@
2
3 ARG MICRO_HOME=/opt/app/data-router
4 ARG BIN_HOME=$MICRO_HOME/bin
5 ARG DR_LOGS=/var/log/onap/AAI-DR
6
7 # AAI-2176 Additional optional steps for Ubuntu
8 RUN if  ((uname -v | grep -i "ubuntu") || ( cat /etc/*release|grep -i "ubuntu")      ) ; then \
9    #####################################
10    #if JAVA doesnt exist then install it: 
11    ######################################
12    if type  java  2>/dev/null; then \   
13      echo "skipping java installation"; \       
14    else \
15      apt-get update && apt-get install -y software-properties-common; \
16      ## sudo -E is required to preserve the environment. If you remove that line, it will most like freeze at this step
17      sudo -E add-apt-repository ppa:openjdk-r/ppa && apt-get update && apt-get install -y openjdk-8-jdk ; \
18      ## Setup JAVA_HOME, this is useful for docker commandline
19      JAVA_HOME=usr/lib/jvm/java-8-openjdk-amd64; \
20      export JAVA_HOME ; \
21    fi; \
22 fi
23 RUN mkdir -p $MICRO_HOME $MICRO_HOME/logs $DR_LOGS
24
25 RUN groupadd aaiadmin -g 1000
26 RUN adduser -u 1000 -h /opt/aaihome/aaiadmin -S -D -G aaiadmin -s /bin/bash aaiadmin
27
28 WORKDIR $MICRO_HOME
29 RUN chown -R aaiadmin:aaiadmin $MICRO_HOME $MICRO_HOME/logs $DR_LOGS
30
31 COPY --chown=aaiadmin:aaiadmin /maven/data-router/ .
32
33 USER aaiadmin
34
35 RUN chmod 755 $BIN_HOME/* \
36     && ln -snf /logs $MICRO_HOME/logs
37
38 EXPOSE 9502 9502
39
40 CMD ["/opt/app/data-router/bin/start.sh"]