pcb defect detetcion application
[ealt-edge.git] / example-apps / PDD / pcb-defect-detection / 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/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
38
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
53 #output image path
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
66
67 # Set the home directory to our app user's home.
68 ENV APP_HOME=/usr/app
69 ENV UID=166
70 ENV GID=166
71 ENV USER_NAME=eguser
72 ENV GROUP_NAME=eggroup
73 ENV ENV="/etc/profile"
74 ENV PYTHONUNBUFFERED=0
75
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
80
81 RUN apt-get install -y --fix-missing \
82     build-essential \
83     cmake \
84     gfortran \
85     git \
86     wget \
87     curl \
88     graphicsmagick \
89     libgraphicsmagick1-dev \
90     libavcodec-dev \
91     libavformat-dev \
92     libgtk2.0-dev \
93     libjpeg-dev \
94     liblapack-dev \
95     libswscale-dev \
96     pkg-config \
97     software-properties-common \
98     zip \
99     imagemagick \
100     && apt-get clean && rm -rf /tmp/* /var/tmp/*
101
102 # Set the working directory.
103 WORKDIR $APP_HOME
104
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
109
110 # Install requirements
111 RUN pip install Pillow
112
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
128
129
130 COPY configs/start.sh $APP_HOME/bin
131
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
137
138 # Exposed port
139 EXPOSE 9991
140
141 # Change to the app user.
142 # USER $USER_NAME
143
144 # Install requirements
145 #RUN pip install -r requirements.txt
146
147 # Execute script & application
148 ENTRYPOINT ["sh", "./bin/start.sh"]