[AAI-2177] Run container process as non-root
[aai/gizmo.git] / src / main / docker / Dockerfile
1 FROM ubuntu:14.04
2
3 ARG MICRO_HOME=/opt/app/crud-api
4 ARG BIN_HOME=$MICRO_HOME/bin
5
6 RUN apt-get update
7
8 # Install and setup java8
9 RUN apt-get update && apt-get install -y software-properties-common
10 ## sudo -E is required to preserve the environment. If you remove that line, it will most like freeze at this step
11 RUN sudo -E add-apt-repository ppa:openjdk-r/ppa && apt-get update && apt-get install -y openjdk-8-jdk
12 ## Setup JAVA_HOME, this is useful for docker commandline
13 ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64
14 RUN export JAVA_HOME
15
16 # Build up the deployment folder structure
17 RUN mkdir -p $MICRO_HOME
18 RUN mkdir -p $MICRO_HOME/bundleconfig/etc
19 COPY gizmo.jar $MICRO_HOME/
20 RUN mkdir -p $BIN_HOME
21 COPY *.sh $BIN_HOME
22 COPY bundleconfig-local $MICRO_HOME/bundleconfig
23 COPY bundleconfig-local/etc/logback.xml $MICRO_HOME/bundleconfig/etc
24 RUN chmod 755 $BIN_HOME/*
25
26 # Changes related to:AAI-2177
27 # Change aai gizmo container processes to run as non-root on the host
28
29 #Note:The group id and user id used below (492382 & 341790 respectively) are chosen arbitarily based on assumption that
30 # these are not used elsewhere. Please see  https://jira.onap.org/browse/AAI-2172 for more background on this.
31
32 RUN mkdir /opt/aaihome && \
33      groupadd -g 492382 aaiadmin && \
34      useradd -r -u 341790  -g 492382 -ms /bin/sh -d /opt/aaihome/aaiadmin aaiadmin && \
35      chown -R aaiadmin:aaiadmin $MICRO_HOME &&\
36      mkdir /logs && \
37      chown -R aaiadmin:aaiadmin  /logs
38
39 USER aaiadmin
40
41 RUN ln -s /logs $MICRO_HOME/logs
42
43 EXPOSE 9520 9520
44
45 CMD ["/opt/app/crud-api/bin/start.sh"]