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