c84560a78fb54da988b0b7aefe3b1ef79f9dd840
[ealt-edge.git] / example-apps / ROBO / retail_app / Dockerfile
1 #
2 # Copyright 2020 Huawei Technologies Co., Ltd.
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 #
16
17 # Prepare stage for multistage image build
18 ## START OF STAGE0 ##
19 FROM python:3.6-slim-stretch
20
21 # # CREATE APP USER ##
22 # Set umask
23 RUN sed -i "s|umask 022|umask 027|g" /etc/profile
24
25 # Create the home directory for the new app user.
26 RUN mkdir -p /usr/app
27 RUN mkdir -p /usr/app/bin
28 RUN mkdir -p /usr/app/detection
29 RUN mkdir -p /usr/app/resources
30
31 # Set the home directory to our app user's home.
32 ENV APP_HOME=/usr/app
33 ENV UID=166
34 ENV GID=166
35 ENV USER_NAME=eguser
36 ENV GROUP_NAME=eggroup
37 ENV ENV="/etc/profile"
38
39 # Create an app user so our program doesn't run as root.
40 RUN apt-get -y update &&\
41     groupadd -r -g $GID $GROUP_NAME &&\
42     useradd -r -u $UID -g $GID -d $APP_HOME -s /sbin/nologin -c "Docker image user" $USER_NAME
43
44 RUN apt-get install -y --fix-missing \
45     build-essential \
46     cmake \
47     gfortran \
48     git \
49     wget \
50     curl \
51     graphicsmagick \
52     libgraphicsmagick1-dev \
53     libatlas-dev \
54     libavcodec-dev \
55     libavformat-dev \
56     libgtk2.0-dev \
57     libjpeg-dev \
58     liblapack-dev \
59     libswscale-dev \
60     pkg-config \
61     python3-dev \
62     python3-numpy \
63     software-properties-common \
64     zip \
65     && apt-get clean && rm -rf /tmp/* /var/tmp/*
66
67 # Set the working directory.
68 WORKDIR $APP_HOME
69
70 # Copy the application & scripts
71 COPY config.py requirements.txt run.py $APP_HOME/
72 COPY detection $APP_HOME/monitoring/
73 COPY resources $APP_HOME/resources/
74 COPY configs/*.sh $APP_HOME/bin
75
76 RUN chmod 750 $APP_HOME &&\
77     chmod -R 550 $APP_HOME/bin &&\
78     mkdir -p -m 750 $APP_HOME/log &&\
79     mkdir -p -m 700 $APP_HOME/ssl &&\
80     chown -R $USER_NAME:$GROUP_NAME $APP_HOME
81
82 # Exposed port
83 EXPOSE 9997
84
85 # Change to the app user.
86 USER $USER_NAME
87
88 # Install requirements
89 RUN pip install -r requirements.txt
90
91 # Execute script & application
92 ENTRYPOINT ["sh", "./bin/start.sh"]