blob: 5130fe9c4c4cfd361b2a1bfd177836cd9253b06e [file] [log] [blame]
mesajfbd8f492025-06-10 17:08:07 +02001# syntax=docker/dockerfile:1
2#######################################################################################
3# Copyright ETSI Contributors and Others.
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
14# implied.
15# See the License for the specific language governing permissions and
16# limitations under the License.
17#######################################################################################
18
19
20######################
21# Stage 1: Base Stage#
22######################
23
24FROM python:3.10-alpine AS base
25
26# RUN apk add --no-cache \
27# libgcc \
28# libstdc++
29
30ENV PYTHONUNBUFFERED=1 \
31 PYTHONDONTWRITEBYTECODE=1 \
32 PIP_DISABLE_PIP_VERSION_CHECK=1
33
34
35#########################################################################################################################################################################
36
37########################
38# Stage 2: Build Stage #
39########################
40
41FROM base AS build
42
43# Install required system packages
44RUN apk add --no-cache \
45 build-base \
46 git \
47 patch \
48 curl \
49 zlib-dev \
50 cdrkit \
51 linux-headers \
52 openssl \
53 openssl-dev \
54 libffi-dev \
55 libmagic \
56 cargo \
57 rust \
58 musl-dev \
59 bash \
60 openssh-client
61
62# Verify git installation
63RUN git --version
64
65WORKDIR /app/ro
66
67# Isolate dependencies in a venv
68RUN python -m venv /app/ro/.venv
69ENV PATH="/app/ro/.venv/bin:$PATH"
70
71ARG COMMON_GERRIT_REFSPEC=master
72ARG IM_GERRIT_REFSPEC=master
73
74# Install build tools
75RUN pip install -U pip setuptools wheel build
76
77RUN test -x /app/ro/.venv/bin/python && /app/ro/.venv/bin/python -c "import sys; print(sys.prefix)"
78
79# Install OSM dependency modules
80
caviedesj89d37452026-01-09 11:15:25 +010081RUN git clone --filter=blob:none --tags https://osm.etsi.org/gerrit/osm/common.git /tmp/osm-common && \
mesajfbd8f492025-06-10 17:08:07 +020082 cd /tmp/osm-common && \
83 git fetch origin ${COMMON_GERRIT_REFSPEC} && \
84 git checkout FETCH_HEAD && \
85 cd - && \
86 pip install -r /tmp/osm-common/requirements.txt && \
87 pip install /tmp/osm-common
88
89COPY requirements.txt ./
90
91# Install py-radix from source with a one-line patch (no build isolation)
caviedesj89d37452026-01-09 11:15:25 +010092RUN \
mesajfbd8f492025-06-10 17:08:07 +020093 # py-radix is installed as dependency of the ipconflict package
94 # the installation is a bit special as it is not fully compatible with Alpine library versions
95 # similar issue reported here: https://github.com/mjschultz/py-radix/issues/70
96 git clone --filter=blob:none https://github.com/mjschultz/py-radix.git /tmp/py-radix && \
97 sed -i 's/from setuptools\.dist import Version/from packaging.version import Version/' /tmp/py-radix/setup.py && \
98 pip install --no-build-isolation /tmp/py-radix && \
99 pip install -r requirements.txt
100
caviedesj89d37452026-01-09 11:15:25 +0100101RUN pip install git+https://github.com/mjschultz/py-radix.git && \
mesajfbd8f492025-06-10 17:08:07 +0200102 pip install -r requirements.txt
103
104COPY . .
105
106RUN for component in common RO-plugin NG-RO RO-VIM-* RO-SDN-*; do \
107 if [ -d "$component" ]; then \
108 python -m build $component && \
109 pip install $component/dist/*.whl; \
110 fi; \
111 done
112
113
114################################################################################################################################################################
115
116########################
117# Stage 3: Final Stage #
118########################
119
120FROM base AS final
121WORKDIR /app
122
123RUN apk add --no-cache \
124 cdrkit \
125 git \
126 curl \
127 libmagic \
128 bash
129
130RUN addgroup -g 1000 appuser && \
131 adduser -D -G appuser -u 1000 appuser -h /app appuser && \
132 mkdir -p /app/storage/kafka && \
133 mkdir -p /app/log && \
134 chown -R appuser:appuser /app
135
136USER appuser:appuser
137
138ENV VIRTUAL_ENV=/app/.venv \
139 PATH="/app/.venv/bin:$PATH"
140
141COPY --from=build --chown=appuser:appuser /app/ro/ /app/
142
143EXPOSE 9090
144
145# Database configuration
146ENV RO_DB_HOST="" \
147 RO_DB_OVIM_HOST="" \
148 RO_DB_ROOT_PASSWORD="" \
149 RO_DB_OVIM_ROOT_PASSWORD="" \
150 RO_DB_USER=mano \
151 RO_DB_OVIM_USER=mano \
152 RO_DB_PASSWORD=manopw \
153 RO_DB_OVIM_PASSWORD=manopw \
154 RO_DB_PORT=3306 \
155 RO_DB_OVIM_PORT=3306 \
156 RO_DB_NAME=mano_db \
157 RO_DB_OVIM_NAME=mano_vim_db \
158 OPENMANO_TENANT=osm
159
160# Application configuration
161ENV OSMRO_DATABASE_DRIVER=mongo \
162 OSMRO_DATABASE_URI=mongodb://mongo:27017 \
163 OSMRO_MESSAGE_DRIVER=kafka \
164 OSMRO_MESSAGE_HOST=kafka \
165 OSMRO_MESSAGE_PORT=9092 \
166 OSMRO_LOG_LEVEL=INFO
167
168# Expose ports and volumes
169VOLUME /var/log/osm
170
171# Set user and entrypoint
172USER appuser
173CMD ["python", "-u", "-m", "osm_ng_ro.ro_main"]
174