73e1bd07b3ece5a0ae705a72c874826a578d8cc5
[osm/devops.git] / docker / Webhook / Dockerfile
1 #######################################################################################
2 # Copyright ETSI Contributors and Others.
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
13 # implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 #######################################################################################
17
18 FROM ubuntu:20.04 as INSTALL
19
20 ARG APT_PROXY
21 RUN if [ ! -z $APT_PROXY ] ; then \
22     echo "Acquire::http::Proxy \"$APT_PROXY\";" > /etc/apt/apt.conf.d/proxy.conf ;\
23     echo "Acquire::https::Proxy \"$APT_PROXY\";" >> /etc/apt/apt.conf.d/proxy.conf ;\
24     fi
25
26 RUN DEBIAN_FRONTEND=noninteractive apt-get --yes update && \
27     DEBIAN_FRONTEND=noninteractive apt-get --yes install \
28     gcc=4:9.3.* \
29     python3=3.8.* \
30     python3-dev=3.8.* \
31     python3-pip=20.0.2* \
32     python3-setuptools=45.2.* \
33     curl=7.68.*
34
35 ARG PYTHON3_OSM_WEBHOOK_TRANSLATOR_URL
36
37 RUN curl $PYTHON3_OSM_WEBHOOK_TRANSLATOR_URL -o osm_webhook_translator.deb
38 RUN dpkg -i ./osm_webhook_translator.deb
39
40 RUN pip3 install \
41     -r /usr/lib/python3/dist-packages/osm_webhook_translator/requirements.txt
42
43 #######################################################################################
44 FROM ubuntu:20.04 as FINAL
45
46 ARG APT_PROXY
47 RUN if [ ! -z $APT_PROXY ] ; then \
48     echo "Acquire::http::Proxy \"$APT_PROXY\";" > /etc/apt/apt.conf.d/proxy.conf ;\
49     echo "Acquire::https::Proxy \"$APT_PROXY\";" >> /etc/apt/apt.conf.d/proxy.conf ;\
50     fi
51
52 RUN DEBIAN_FRONTEND=noninteractive apt-get --yes update && \
53     DEBIAN_FRONTEND=noninteractive apt-get --yes install \
54     python3-minimal=3.8.* \
55     && rm -rf /var/lib/apt/lists/*
56
57 RUN rm -f /etc/apt/apt.conf.d/proxy.conf
58
59 COPY --from=INSTALL /usr/lib/python3/dist-packages /usr/lib/python3/dist-packages
60 COPY --from=INSTALL /usr/local/lib/python3.8/dist-packages /usr/local/lib/python3.8/dist-packages
61 COPY --from=INSTALL /usr/local/bin/uvicorn /usr/local/bin/uvicorn
62
63 # Creating the user for the app
64 RUN groupadd -g 1000 appuser && \
65     useradd -u 1000 -g 1000 -d /app appuser && \
66     mkdir -p /app/osm_webhook_translator && \
67     chown -R appuser:appuser /app
68
69 WORKDIR /app/osm_webhook_translator
70
71 # Changing the security context
72 USER appuser
73
74 EXPOSE 9998
75
76 CMD ["uvicorn", "osm_webhook_translator.main:app", "--host", "0.0.0.0", "--port", "80"]
77
78