| mesaj | 75ec890 | 2025-06-10 17:16:47 +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: Base Stage # |
| 22 | ####################### |
| 23 | |
| 24 | FROM python:3.10-alpine AS base |
| 25 | |
| 26 | ENV PYTHONUNBUFFERED=1 \ |
| 27 | PYTHONDONTWRITEBYTECODE=1 \ |
| 28 | PIP_DISABLE_PIP_VERSION_CHECK=1 |
| 29 | |
| 30 | |
| 31 | ############################################################################################################################################################ |
| 32 | |
| 33 | ########################## |
| 34 | # Stage 2: Builder Stage # |
| 35 | ########################## |
| 36 | |
| 37 | FROM base AS builder |
| 38 | |
| caviedesj | aeebf1f | 2026-01-09 11:46:40 +0100 | [diff] [blame^] | 39 | RUN apk add --no-cache --virtual .build-deps \ |
| mesaj | 75ec890 | 2025-06-10 17:16:47 +0200 | [diff] [blame] | 40 | build-base gcc \ |
| 41 | musl-dev \ |
| 42 | libffi-dev \ |
| 43 | libmagic \ |
| 44 | openssl-dev \ |
| 45 | curl \ |
| 46 | git \ |
| 47 | jq \ |
| 48 | file \ |
| 49 | openssh-client \ |
| 50 | openssh-keygen \ |
| 51 | bash \ |
| 52 | ca-certificates |
| 53 | |
| 54 | WORKDIR /app/tests |
| 55 | |
| 56 | # Isolate dependencies in a venv |
| 57 | RUN python -m venv /app/tests/.venv |
| 58 | ENV PATH="/app/tests/.venv/bin:$PATH" |
| 59 | |
| 60 | # Instalar kubectl (versión 1.30) |
| 61 | RUN curl -LO "https://dl.k8s.io/release/v1.30.13/bin/linux/amd64/kubectl" && \ |
| 62 | install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl && \ |
| 63 | rm kubectl |
| 64 | |
| 65 | # Instalar Google Cloud SDK (versión simplificada para Alpine) |
| 66 | RUN curl -sSL https://sdk.cloud.google.com > /tmp/install.sh && \ |
| 67 | bash /tmp/install.sh --disable-prompts --install-dir=/local && \ |
| 68 | rm /tmp/install.sh |
| 69 | #ENV PATH $PATH:/local/google-cloud-sdk/bin |
| 70 | |
| 71 | # Instalar Azure CLI (versión simplificada para Alpine) |
| 72 | RUN apk add --no-cache py3-pip && \ |
| 73 | pip install --no-cache-dir azure-cli |
| 74 | |
| 75 | # Add vCluster CLI |
| garciadeblas | a2c60b1 | 2025-12-16 17:56:14 +0100 | [diff] [blame] | 76 | ENV VCLUSTER_VERSION "v0.30.1" |
| mesaj | 75ec890 | 2025-06-10 17:16:47 +0200 | [diff] [blame] | 77 | RUN curl -L -o /tmp/vcluster "https://github.com/loft-sh/vcluster/releases/download/${VCLUSTER_VERSION}/vcluster-linux-amd64" \ |
| 78 | && install -c -m 0755 /tmp/vcluster /usr/local/bin \ |
| 79 | && rm -f /tmp/vcluster |
| 80 | # Copy vCluster configuration |
| 81 | COPY configs/vcluster.yaml /etc/vcluster.yaml |
| 82 | |
| 83 | ARG IM_GERRIT_REFSPEC=master |
| caviedesj | aeebf1f | 2026-01-09 11:46:40 +0100 | [diff] [blame^] | 84 | RUN git clone --filter=blob:none --tags https://osm.etsi.org/gerrit/osm/IM.git /tmp/osm-im && \ |
| mesaj | 75ec890 | 2025-06-10 17:16:47 +0200 | [diff] [blame] | 85 | cd /tmp/osm-im && \ |
| 86 | git fetch origin ${IM_GERRIT_REFSPEC} && \ |
| 87 | git checkout FETCH_HEAD && \ |
| 88 | cd - && \ |
| 89 | pip install --no-cache-dir -r /tmp/osm-im/requirements.txt && \ |
| 90 | pip install /tmp/osm-im |
| 91 | |
| 92 | |
| 93 | ARG CLIENT_GERRIT_REFSPEC=master |
| caviedesj | aeebf1f | 2026-01-09 11:46:40 +0100 | [diff] [blame^] | 94 | RUN git clone --filter=blob:none --tags https://osm.etsi.org/gerrit/osm/osmclient.git /tmp/osmclient && \ |
| mesaj | 75ec890 | 2025-06-10 17:16:47 +0200 | [diff] [blame] | 95 | cd /tmp/osmclient && \ |
| 96 | git fetch origin ${CLIENT_GERRIT_REFSPEC} && \ |
| 97 | git checkout FETCH_HEAD && \ |
| 98 | cd - && \ |
| 99 | pip install --no-cache-dir -r /tmp/osmclient/requirements.txt && \ |
| 100 | pip install /tmp/osmclient |
| 101 | |
| 102 | COPY . /tmp/osm-tests/ |
| 103 | |
| 104 | # Install test requirements leveraging BuildKit cache |
| 105 | RUN --mount=type=cache,target=/root/.cache/pip \ |
| 106 | cd /tmp/osm-tests && \ |
| 107 | pip install --no-cache-dir -r /tmp/osm-tests/requirements.txt && \ |
| 108 | pip install /tmp/osm-tests && \ |
| 109 | cd - |
| 110 | |
| 111 | RUN mv /tmp/osm-tests/robot-systest /robot-systest/ && \ |
| 112 | mv /tmp/osm-tests/cloud-scripts /robot-systest/ && \ |
| 113 | mv /tmp/osm-tests/conformance-tests/ /robot-systest/ && \ |
| 114 | mv /tmp/osm-tests/charm.sh /usr/sbin/charm |
| 115 | |
| 116 | WORKDIR /robot-systest |
| 117 | |
| 118 | # Folder where Robot tests are stored |
| 119 | ENV ROBOT_DEVOPS_FOLDER=/robot-systest |
| 120 | |
| 121 | # Folder to save alternative DUT environments (optional) |
| 122 | ENV ENVIRONMENTS_FOLDER=environments |
| 123 | |
| 124 | # Folder where all required packages are stored |
| 125 | ENV PACKAGES_FOLDER=/robot-systest/osm-packages |
| 126 | |
| 127 | # Folder where test results should be exported |
| 128 | ENV ROBOT_REPORT_FOLDER=/robot-systest/results |
| 129 | |
| 130 | # Kubeconfig file |
| 131 | ENV K8S_CREDENTIALS=/root/.kube/config |
| 132 | |
| 133 | # Kubeconfig file of the existing cluster for Gitops tests |
| 134 | ENV CLUSTER_KUBECONFIG_CREDENTIALS=/robot-systest/cluster-kubeconfig.yaml |
| 135 | |
| 136 | # OSM RSA file |
| 137 | ENV OSM_RSA_FILE=/root/osm_id_rsa |
| 138 | |
| 139 | ENV LC_ALL=C.UTF-8 |
| 140 | ENV LANG=C.UTF-8 |
| 141 | |
| 142 | ENTRYPOINT [ "/robot-systest/run_test.sh"] |