3d76af35df45f17c906bf4bc0b406c0e0ae5aa08
[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/inventry
29 RUN mkdir -p /usr/app/test/resources
30 RUN mkdir -p /usr/app/images
31
32 # Set the home directory to our app user's home.
33 ENV APP_HOME=/usr/app
34 ENV UID=166
35 ENV GID=166
36 ENV USER_NAME=eguser
37 ENV GROUP_NAME=eggroup
38 ENV ENV="/etc/profile"
39
40 # Create an app user so our program doesn't run as root.
41 RUN apt-get -y update &&\
42     groupadd -r -g $GID $GROUP_NAME &&\
43     useradd -r -u $UID -g $GID -d $APP_HOME -s /sbin/nologin -c "Docker image user" $USER_NAME
44
45 RUN apt-get install -y --fix-missing \
46     build-essential \
47     cmake \
48     gfortran \
49     git \
50     wget \
51     curl \
52     graphicsmagick \
53     libgraphicsmagick1-dev \
54     libatlas-dev \
55     libavcodec-dev \
56     libavformat-dev \
57     libgtk2.0-dev \
58     libjpeg-dev \
59     liblapack-dev \
60     libswscale-dev \
61     pkg-config \
62     python3-dev \
63     python3-numpy \
64     software-properties-common \
65     zip \
66     && apt-get clean && rm -rf /tmp/* /var/tmp/*
67
68 # Set the working directory.
69 WORKDIR $APP_HOME
70
71 # Copy the application & scripts
72 COPY config.py requirements.txt run.py $APP_HOME/
73 COPY inventry $APP_HOME/inventry/
74 COPY test $APP_HOME/test/
75 COPY test/resources $APP_HOME/test/resources/
76 #COPY configs/*.sh $APP_HOME/bin
77 COPY configs/start.sh $APP_HOME/bin
78
79 RUN chmod 750 $APP_HOME &&\
80     chmod -R 550 $APP_HOME/bin &&\
81     mkdir -p -m 750 $APP_HOME/log &&\
82     mkdir -p -m 700 $APP_HOME/ssl &&\
83     chown -R $USER_NAME:$GROUP_NAME $APP_HOME
84
85 # Exposed port
86 EXPOSE 9996
87
88 # Change to the app user.
89 USER $USER_NAME
90
91 # Install requirements
92 RUN pip install -r requirements.txt
93
94 # Execute script & application
95 ENTRYPOINT ["sh", "./bin/start.sh"]