blob: 89dc88f0b141bda925f64042816b2b2998ffd0a7 [file] [log] [blame]
mesaj8031c7f2025-06-10 18:44:35 +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: Build Stage #
22##########################
23
24FROM apache/airflow:2.5.3-python3.10 AS build
25
26ENV PIP_DISABLE_PIP_VERSION_CHECK=1
27
28ARG COMMON_GERRIT_REFSPEC=master
29
30USER root
31
32# Install only essential build dependencies
33RUN apt-get update && \
34 apt-get install -y --no-install-recommends \
35 gcc git python3-dev && \
36 rm -rf /var/lib/apt/lists/*
37
38USER airflow
39# Install base requirements
40RUN pip install --no-cache-dir setuptools-scm wheel
41
42# Install OSM common from Git
43RUN 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
52COPY requirements.txt /tmp/osm-ngsa/requirements.txt
53RUN pip wheel --no-cache-dir -r /tmp/osm-ngsa/requirements.txt -w /tmp/wheels
54
55# Install NG_SA
56COPY . /tmp/osm-ngsa
57USER root
58# workaound to allow the airflow user to write files in the copied folder
59RUN chown -R airflow:root /tmp/osm-ngsa && \
60 chmod -R u+w /tmp/osm-ngsa
61USER airflow
62RUN pip wheel --no-cache-dir /tmp/osm-ngsa -w /tmp/wheels
63
64
65#########################################################################################################################################################################
66
67################################
68# Stage 2: Runtime environment #
69################################
70
71FROM apache/airflow:2.5.3-python3.10
72
73USER airflow
74
75# Copy all artifacts to install
76COPY --chown=airflow:root --from=build /tmp/wheels /tmp/wheels
77COPY --chown=airflow:root --from=build /tmp/osm-common/requirements.txt /tmp/osm-requirements.txt
78COPY --chown=airflow:root --from=build /tmp/osm-ngsa/requirements.txt /tmp/ngsa-requirements.txt
79
80RUN 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