| mesaj | 8031c7f | 2025-06-10 18:44:35 +0200 | [diff] [blame] | 1 | # 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: Build Stage # |
| 22 | ########################## |
| 23 | |
| 24 | FROM apache/airflow:2.5.3-python3.10 AS build |
| 25 | |
| 26 | ENV PIP_DISABLE_PIP_VERSION_CHECK=1 |
| 27 | |
| 28 | ARG COMMON_GERRIT_REFSPEC=master |
| 29 | |
| 30 | USER root |
| 31 | |
| 32 | # Install only essential build dependencies |
| 33 | RUN apt-get update && \ |
| 34 | apt-get install -y --no-install-recommends \ |
| 35 | gcc git python3-dev && \ |
| 36 | rm -rf /var/lib/apt/lists/* |
| 37 | |
| 38 | USER airflow |
| 39 | # Install base requirements |
| 40 | RUN pip install --no-cache-dir setuptools-scm wheel |
| 41 | |
| 42 | # Install OSM common from Git |
| 43 | RUN git clone --filter=blob:none --tags https://osm.etsi.org/gerrit/osm/common.git /tmp/osm-common && \ |
| 44 | cd /tmp/osm-common && \ |
| 45 | git fetch origin ${COMMON_GERRIT_REFSPEC} && \ |
| 46 | git checkout FETCH_HEAD && \ |
| 47 | cd - && \ |
| 48 | pip3 wheel --no-cache-dir -r /tmp/osm-common/requirements.txt -w /tmp/wheels && \ |
| 49 | pip3 wheel --no-cache-dir /tmp/osm-common -w /tmp/wheels |
| 50 | |
| 51 | # Install NG_SA requirements |
| 52 | COPY requirements.txt /tmp/osm-ngsa/requirements.txt |
| 53 | RUN pip wheel --no-cache-dir -r /tmp/osm-ngsa/requirements.txt -w /tmp/wheels |
| 54 | |
| 55 | # Install NG_SA |
| 56 | COPY . /tmp/osm-ngsa |
| 57 | USER root |
| 58 | # workaound to allow the airflow user to write files in the copied folder |
| 59 | RUN chown -R airflow:root /tmp/osm-ngsa && \ |
| 60 | chmod -R u+w /tmp/osm-ngsa |
| 61 | USER airflow |
| 62 | RUN pip wheel --no-cache-dir /tmp/osm-ngsa -w /tmp/wheels |
| 63 | |
| 64 | |
| 65 | ######################################################################################################################################################################### |
| 66 | |
| 67 | ################################ |
| 68 | # Stage 2: Runtime environment # |
| 69 | ################################ |
| 70 | |
| 71 | FROM apache/airflow:2.5.3-python3.10 |
| 72 | |
| 73 | USER airflow |
| 74 | |
| 75 | # Copy all artifacts to install |
| 76 | COPY --chown=airflow:root --from=build /tmp/wheels /tmp/wheels |
| 77 | COPY --chown=airflow:root --from=build /tmp/osm-common/requirements.txt /tmp/osm-requirements.txt |
| 78 | COPY --chown=airflow:root --from=build /tmp/osm-ngsa/requirements.txt /tmp/ngsa-requirements.txt |
| 79 | |
| 80 | RUN pip install --no-cache-dir --no-index --find-links=/tmp/wheels \ |
| 81 | -r /tmp/osm-requirements.txt \ |
| 82 | -r /tmp/ngsa-requirements.txt \ |
| 83 | osm_common \ |
| 84 | osm_ngsa && \ |
| 85 | rm -rf /tmp/wheels |
| 86 | |