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