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