From: mesaj Date: Tue, 10 Jun 2025 15:16:47 +0000 (+0200) Subject: Move Dockerfile from devops to the repo, base image Alpine Linux X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=75ec890acf9347da0355f59a75be334fb3336836;p=osm%2Ftests.git Move Dockerfile from devops to the repo, base image Alpine Linux Change-Id: I7e5ea86bc9dc5ec7f433465716789143f87913f5 Signed-off-by: mesaj Signed-off-by: garciadeblas --- diff --git a/Dockerfile.production b/Dockerfile.production new file mode 100644 index 0000000..3a11eec --- /dev/null +++ b/Dockerfile.production @@ -0,0 +1,145 @@ +# syntax=docker/dockerfile:1 +####################################################################################### +# Copyright ETSI Contributors and Others. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. +####################################################################################### + + +####################### +# Stage 1: Base Stage # +####################### + +FROM python:3.10-alpine AS base + +ENV PYTHONUNBUFFERED=1 \ + PYTHONDONTWRITEBYTECODE=1 \ + PIP_DISABLE_PIP_VERSION_CHECK=1 + + +############################################################################################################################################################ + +########################## +# Stage 2: Builder Stage # +########################## + +FROM base AS builder + +RUN --mount=type=cache,target=/var/cache/apk \ + apk add --no-cache --virtual .build-deps \ + build-base gcc \ + musl-dev \ + libffi-dev \ + libmagic \ + openssl-dev \ + curl \ + git \ + jq \ + file \ + openssh-client \ + openssh-keygen \ + bash \ + ca-certificates + +WORKDIR /app/tests + +# Isolate dependencies in a venv +RUN python -m venv /app/tests/.venv +ENV PATH="/app/tests/.venv/bin:$PATH" + +# Instalar kubectl (versión 1.30) +RUN curl -LO "https://dl.k8s.io/release/v1.30.13/bin/linux/amd64/kubectl" && \ + install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl && \ + rm kubectl + +# Instalar Google Cloud SDK (versión simplificada para Alpine) +RUN curl -sSL https://sdk.cloud.google.com > /tmp/install.sh && \ + bash /tmp/install.sh --disable-prompts --install-dir=/local && \ + rm /tmp/install.sh +#ENV PATH $PATH:/local/google-cloud-sdk/bin + +# Instalar Azure CLI (versión simplificada para Alpine) +RUN apk add --no-cache py3-pip && \ + pip install --no-cache-dir azure-cli + +# Add vCluster CLI +ENV VCLUSTER_VERSION "v0.26.0" +RUN curl -L -o /tmp/vcluster "https://github.com/loft-sh/vcluster/releases/download/${VCLUSTER_VERSION}/vcluster-linux-amd64" \ + && install -c -m 0755 /tmp/vcluster /usr/local/bin \ + && rm -f /tmp/vcluster +# Copy vCluster configuration +COPY configs/vcluster.yaml /etc/vcluster.yaml + +ARG IM_GERRIT_REFSPEC=master +RUN --mount=type=cache,target=/root/.cache/pip \ + git clone --filter=blob:none --tags https://osm.etsi.org/gerrit/osm/IM.git /tmp/osm-im && \ + cd /tmp/osm-im && \ + git fetch origin ${IM_GERRIT_REFSPEC} && \ + git checkout FETCH_HEAD && \ + cd - && \ + pip install --no-cache-dir -r /tmp/osm-im/requirements.txt && \ + pip install /tmp/osm-im + + +ARG CLIENT_GERRIT_REFSPEC=master +RUN --mount=type=cache,target=/root/.cache/pip \ + git clone --filter=blob:none --tags https://osm.etsi.org/gerrit/osm/osmclient.git /tmp/osmclient && \ + cd /tmp/osmclient && \ + git fetch origin ${CLIENT_GERRIT_REFSPEC} && \ + git checkout FETCH_HEAD && \ + cd - && \ + pip install --no-cache-dir -r /tmp/osmclient/requirements.txt && \ + pip install /tmp/osmclient + +COPY . /tmp/osm-tests/ + +# Install test requirements leveraging BuildKit cache +RUN --mount=type=cache,target=/root/.cache/pip \ + cd /tmp/osm-tests && \ + pip install --no-cache-dir -r /tmp/osm-tests/requirements.txt && \ + pip install /tmp/osm-tests && \ + cd - + +RUN mv /tmp/osm-tests/robot-systest /robot-systest/ && \ + mv /tmp/osm-tests/cloud-scripts /robot-systest/ && \ + mv /tmp/osm-tests/conformance-tests/ /robot-systest/ && \ + mv /tmp/osm-tests/charm.sh /usr/sbin/charm + +WORKDIR /robot-systest + +# Folder where Robot tests are stored +ENV ROBOT_DEVOPS_FOLDER=/robot-systest + +# Folder to save alternative DUT environments (optional) +ENV ENVIRONMENTS_FOLDER=environments + +# Folder where all required packages are stored +ENV PACKAGES_FOLDER=/robot-systest/osm-packages + +# Folder where test results should be exported +ENV ROBOT_REPORT_FOLDER=/robot-systest/results + +# Kubeconfig file +ENV K8S_CREDENTIALS=/root/.kube/config + +# Kubeconfig file of the existing cluster for Gitops tests +ENV CLUSTER_KUBECONFIG_CREDENTIALS=/robot-systest/cluster-kubeconfig.yaml + +# OSM RSA file +ENV OSM_RSA_FILE=/root/osm_id_rsa + +ENV LC_ALL=C.UTF-8 +ENV LANG=C.UTF-8 + +ENTRYPOINT [ "/robot-systest/run_test.sh"] diff --git a/configs/vcluster.yaml b/configs/vcluster.yaml new file mode 100644 index 0000000..52a0fa8 --- /dev/null +++ b/configs/vcluster.yaml @@ -0,0 +1,32 @@ +####################################################################################### +# Copyright ETSI Contributors and Others. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. +####################################################################################### +controlPlane: + proxy: + extraSANs: + - "e2e.vcluster.svc.cluster.local" + distro: + k8s: + image: + tag: v1.29.3 +exportKubeConfig: + server: https://e2e.vcluster.svc.cluster.local:443 + secret: + name: vcluster-flux-kubeconfig +sync: + fromHost: + storageClasses: + enabled: true