blob: f63736255c68bc4479324b61dd13c857943bfa3e [file] [log] [blame]
beierlme7646252022-01-13 10:53:08 -05001#######################################################################################
2# Copyright ETSI Contributors and Others.
magnussonl2ec08082020-05-01 10:43:30 +02003#
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.
beierlme7646252022-01-13 10:53:08 -050016#######################################################################################
magnussonl2ec08082020-05-01 10:43:30 +020017
beierlmd7449362022-01-13 10:53:08 -050018FROM 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
David Garciaa60ec732021-03-17 15:28:47 +010026RUN DEBIAN_FRONTEND=noninteractive apt-get --yes update && \
27 DEBIAN_FRONTEND=noninteractive apt-get --yes install \
beierlmd7449362022-01-13 10:53:08 -050028 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.*
magnussonl2ec08082020-05-01 10:43:30 +020034
David Garciaa60ec732021-03-17 15:28:47 +010035ARG PYTHON3_OSM_COMMON_URL
36ARG PYTHON3_OSM_PLA_URL
magnussonl2ec08082020-05-01 10:43:30 +020037
David Garciaa60ec732021-03-17 15:28:47 +010038RUN curl $PYTHON3_OSM_COMMON_URL -o osm_common.deb
39RUN dpkg -i ./osm_common.deb
magnussonl2ec08082020-05-01 10:43:30 +020040
David Garciaa60ec732021-03-17 15:28:47 +010041RUN curl $PYTHON3_OSM_PLA_URL -o osm_pla.deb
42RUN dpkg -i ./osm_pla.deb
magnussonl2ec08082020-05-01 10:43:30 +020043
David Garciaa60ec732021-03-17 15:28:47 +010044RUN pip3 install \
45 -r /usr/lib/python3/dist-packages/osm_common/requirements.txt \
46 -r /usr/lib/python3/dist-packages/osm_pla/requirements.txt
magnussonl2ec08082020-05-01 10:43:30 +020047
magnussonld0420fb2020-07-02 19:32:36 +020048ADD https://github.com/MiniZinc/MiniZincIDE/releases/download/2.4.2/MiniZincIDE-2.4.2-bundle-linux-x86_64.tgz /minizinc.tgz
49
50RUN tar -zxf /minizinc.tgz && \
51 mv /MiniZincIDE-2.4.2-bundle-linux /minizinc
52
beierlmd7449362022-01-13 10:53:08 -050053#######################################################################################
54FROM ubuntu:20.04 as FINAL
55
56ARG APT_PROXY
57RUN if [ ! -z $APT_PROXY ] ; then \
58 echo "Acquire::http::Proxy \"$APT_PROXY\";" > /etc/apt/apt.conf.d/proxy.conf ;\
59 echo "Acquire::https::Proxy \"$APT_PROXY\";" >> /etc/apt/apt.conf.d/proxy.conf ;\
60 fi
David Garciaa60ec732021-03-17 15:28:47 +010061
62RUN DEBIAN_FRONTEND=noninteractive apt-get --yes update && \
beierlmd7449362022-01-13 10:53:08 -050063 DEBIAN_FRONTEND=noninteractive apt-get --yes install \
64 python3-minimal=3.8.* \
garciadeblas6ba74b52021-09-23 17:43:15 +020065 && rm -rf /var/lib/apt/lists/*
David Garciaa60ec732021-03-17 15:28:47 +010066
Mark Beierle5b9ba62022-09-08 05:44:06 -040067RUN rm -f /etc/apt/apt.conf.d/proxy.conf
68
beierlmd7449362022-01-13 10:53:08 -050069LABEL authors="Lars-Göran Magnusson"
70
David Garciaa60ec732021-03-17 15:28:47 +010071COPY --from=INSTALL /usr/lib/python3/dist-packages /usr/lib/python3/dist-packages
beierlmd7449362022-01-13 10:53:08 -050072COPY --from=INSTALL /usr/local/lib/python3.8/dist-packages /usr/local/lib/python3.8/dist-packages
David Garciaa60ec732021-03-17 15:28:47 +010073COPY --from=INSTALL /usr/bin/osm* /usr/bin/
74COPY --from=INSTALL /minizinc /minizinc
75
sousaedu4bd81772021-11-09 23:59:54 +000076RUN mkdir /entry_data && \
77 mkdir /placement && \
78 mkdir /entry_data/mzn-lib && \
79 ln -s /entry_data/mzn-lib /minizinc/share/minizinc/exec
magnussonld0420fb2020-07-02 19:32:36 +020080
sousaedu4bd81772021-11-09 23:59:54 +000081COPY scripts/ /app/osm_pla/scripts/
82
83# Creating the user for the app
84RUN groupadd -g 1000 appuser && \
85 useradd -u 1000 -g 1000 -d /app appuser && \
86 mkdir -p /app/osm_pla && \
87 chown -R appuser:appuser /app && \
88 chown -R appuser:appuser /entry_data && \
89 chown -R appuser:appuser /minizinc && \
90 chown -R appuser:appuser /placement
91
92WORKDIR /app/osm_pla
93
94# Changing the security context
Mark Beierle5b9ba62022-09-08 05:44:06 -040095USER appuser
magnussonld0420fb2020-07-02 19:32:36 +020096
magnussonl2ec08082020-05-01 10:43:30 +020097ENV OSMPLA_MESSAGE_DRIVER kafka
98ENV OSMPLA_MESSAGE_HOST kafka
99ENV OSMPLA_MESSAGE_PORT 9092
100
101ENV OSMPLA_DATABASE_DRIVER mongo
102ENV OSMPLA_DATABASE_URI mongodb://mongo:27017
103
104ENV OSMPLA_SQL_DATABASE_URI sqlite:///pla_sqlite.db
105
106ENV OSMPLA_GLOBAL_LOG_LEVEL INFO
107
108ENV FZNEXEC "/entry_data/fzn-exec"
109ENV PATH "/minizinc/bin:${PATH}"
110ENV LD_LIBRARY_PATH "/minizinc/lib:${LD_LIBRARY_PATH}"
111
112# No healtcheck yet...
113#HEALTHCHECK --start-period=120s --interval=10s --timeout=5s --retries=5 \
114# CMD osm-pla-healthcheck || exit 1
115
sousaedu4bd81772021-11-09 23:59:54 +0000116CMD [ "/bin/bash", "scripts/start.sh" ]