blob: 1205fbc53aab07eb9c02661c6925533be420f5ea [file] [log] [blame]
garciadeblas4c246cf2023-04-13 11:01:15 +02001#######################################################################################
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
18FROM ubuntu:20.04 as INSTALL
19
20ARG APT_PROXY
21RUN 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
26RUN 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
35ARG PYTHON3_OSM_WEBHOOK_TRANSLATOR_URL
36
37RUN curl $PYTHON3_OSM_WEBHOOK_TRANSLATOR_URL -o osm_webhook_translator.deb
38RUN dpkg -i ./osm_webhook_translator.deb
39
40RUN pip3 install \
41 -r /usr/lib/python3/dist-packages/osm_webhook_translator/requirements.txt
42
43#######################################################################################
44FROM ubuntu:20.04 as FINAL
45
46ARG APT_PROXY
47RUN 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
52RUN 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
57RUN rm -f /etc/apt/apt.conf.d/proxy.conf
58
59COPY --from=INSTALL /usr/lib/python3/dist-packages /usr/lib/python3/dist-packages
60COPY --from=INSTALL /usr/local/lib/python3.8/dist-packages /usr/local/lib/python3.8/dist-packages
61
62# Creating the user for the app
63RUN groupadd -g 1000 appuser && \
64 useradd -u 1000 -g 1000 -d /app appuser && \
65 mkdir -p /app/osm_webhook_translator && \
66 chown -R appuser:appuser /app
67
68WORKDIR /app/osm_webhook_translator
69
70# Changing the security context
71USER appuser
72
73EXPOSE 9998
74
75CMD ["uvicorn", "osm_webhook_translator.app.main:app", "--host", "0.0.0.0", "--port", "80"]
76
77