2 # Copyright 2020 Huawei Technologies Co., Ltd.
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
8 # http://www.apache.org/licenses/LICENSE-2.0
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.
17 # Prepare stage for multistage image build
19 # FROM python:3.6-slim-stretch
21 # FROM python:3.9-slim-buster
22 # # CREATE APP USER ##
27 RUN sed -i "s|umask 022|umask 027|g" /etc/profile
29 # Create the home directory for the new app user.
31 RUN mkdir -p /usr/app/bin
32 RUN mkdir -p /usr/app/data
33 RUN mkdir -p /usr/app/help_utils
34 RUN mkdir -p /usr/app/libs
35 RUN mkdir -p /usr/app/output
36 RUN mkdir -p /usr/app/results
37 RUN mkdir -p /usr/app/tools
39 RUN mkdir -p /usr/app/input_image
40 RUN mkdir -p /usr/app/output_image
41 RUN mkdir -p /usr/app/input_image/beijinglab
42 RUN mkdir -p /usr/app/input_image/beijinglab/camera1
43 RUN mkdir -p /usr/app/input_image/beijinglab/camera2
44 RUN mkdir -p /usr/app/input_image/beijinglab/camera3
45 RUN mkdir -p /usr/app/input_image/shenzhenlab
46 RUN mkdir -p /usr/app/input_image/shenzhenlab/camera1
47 RUN mkdir -p /usr/app/input_image/shenzhenlab/camera2
48 RUN mkdir -p /usr/app/input_image/shenzhenlab/camera3
49 RUN mkdir -p /usr/app/input_image/shanghailab
50 RUN mkdir -p /usr/app/input_image/shanghailab/camera1
51 RUN mkdir -p /usr/app/input_image/shanghailab/camera2
52 RUN mkdir -p /usr/app/input_image/shanghailab/camera3
54 RUN mkdir -p /usr/app/output_image/beijinglab
55 RUN mkdir -p /usr/app/output_image/beijinglab/camera1
56 RUN mkdir -p /usr/app/output_image/beijinglab/camera2
57 RUN mkdir -p /usr/app/output_image/beijinglab/camera3
58 RUN mkdir -p /usr/app/output_image/shenzhenlab
59 RUN mkdir -p /usr/app/output_image/shenzhenlab/camera1
60 RUN mkdir -p /usr/app/output_image/shenzhenlab/camera2
61 RUN mkdir -p /usr/app/output_image/shenzhenlab/camera3
62 RUN mkdir -p /usr/app/output_image/shanghailab
63 RUN mkdir -p /usr/app/output_image/shanghailab/camera1
64 RUN mkdir -p /usr/app/output_image/shanghailab/camera2
65 RUN mkdir -p /usr/app/output_image/shanghailab/camera3
67 # Set the home directory to our app user's home.
72 ENV GROUP_NAME=eggroup
73 ENV ENV="/etc/profile"
74 ENV PYTHONUNBUFFERED=0
76 # Create an app user so our program doesn't run as root.
77 RUN apt-get -y update &&\
78 groupadd -r -g $GID $GROUP_NAME &&\
79 useradd -r -u $UID -g $GID -d $APP_HOME -s /sbin/nologin -c "Docker image user" $USER_NAME
81 RUN apt-get install -y --fix-missing \
89 libgraphicsmagick1-dev \
97 software-properties-common \
100 && apt-get clean && rm -rf /tmp/* /var/tmp/*
102 # Set the working directory.
105 # Copy the application & scripts
106 COPY config.py requirements.txt run.py $APP_HOME/
107 # Install requirements
108 RUN pip install -r requirements.txt
110 # Install requirements
111 RUN pip install Pillow
113 COPY data $APP_HOME/data/
114 COPY help_utils $APP_HOME/help_utils/
115 COPY libs $APP_HOME/libs/
116 COPY output $APP_HOME/output/
117 COPY results $APP_HOME/results/
118 COPY tools $APP_HOME/tools/
119 COPY input_image/1 $APP_HOME/input_image/beijinglab/camera1
120 COPY input_image/2 $APP_HOME/input_image/shenzhenlab/camera1
121 COPY input_image/3 $APP_HOME/input_image/shanghailab/camera1
122 COPY input_image/4 $APP_HOME/input_image/beijinglab/camera2
123 COPY input_image/5 $APP_HOME/input_image/beijinglab/camera3
124 COPY input_image/6 $APP_HOME/input_image/shenzhenlab/camera2
125 COPY input_image/7 $APP_HOME/input_image/shenzhenlab/camera3
126 COPY input_image/8 $APP_HOME/input_image/shanghailab/camera2
127 COPY input_image/9 $APP_HOME/input_image/shanghailab/camera3
130 COPY configs/start.sh $APP_HOME/bin
132 RUN chmod 750 $APP_HOME &&\
133 chmod -R 550 $APP_HOME/bin &&\
134 mkdir -p -m 750 $APP_HOME/log &&\
135 mkdir -p -m 700 $APP_HOME/ssl &&\
136 chown -R $USER_NAME:$GROUP_NAME $APP_HOME
141 # Change to the app user.
144 # Install requirements
145 #RUN pip install -r requirements.txt
147 # Execute script & application
148 ENTRYPOINT ["sh", "./bin/start.sh"]