Loading ci_cd_test/Dockerfile +1 −1 Original line number Original line Diff line number Diff line Loading @@ -3,7 +3,7 @@ FROM labs.etsi.org:5050/ocf/capif/python:3-slim-bullseye WORKDIR /sdk WORKDIR /sdk # Copy project files into the container # Copy project files into the container COPY .. . COPY . . # Install Python dependencies # Install Python dependencies RUN python -m pip install --upgrade pip RUN python -m pip install --upgrade pip Loading ci_cd_test/test_sdk.sh +25 −1 Original line number Original line Diff line number Diff line #!/bin/bash #!/bin/bash # Name of container image # ---------------------------- # Configuration # ---------------------------- CONTAINER_NAME=capif-sdk-runner CONTAINER_NAME=capif-sdk-runner IMAGE_NAME=opencapif_sdk IMAGE_NAME=opencapif_sdk BRANCH_NAME=${CI_COMMIT_REF_NAME} BRANCH_NAME=${CI_COMMIT_REF_NAME} Loading @@ -9,14 +11,36 @@ NETWORK_NAME=capif-network SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" PROJECT_ROOT="$(dirname "$SCRIPT_DIR")" PROJECT_ROOT="$(dirname "$SCRIPT_DIR")" # ---------------------------- # Create Docker network (if it doesn't exist) # ---------------------------- echo "🌐 Checking for existing Docker network: $NETWORK_NAME..." if ! docker network ls --format '{{.Name}}' | grep -q "^${NETWORK_NAME}$"; then echo "🔧 Network not found. Creating network: $NETWORK_NAME..." docker network create $NETWORK_NAME else echo "✅ Network $NETWORK_NAME already exists." fi # ---------------------------- # Build Docker image # ---------------------------- echo "🛠️ Building image: $IMAGE_NAME from branch: $BRANCH_NAME with no cache..." echo "🛠️ Building image: $IMAGE_NAME from branch: $BRANCH_NAME with no cache..." docker build --no-cache "$PROJECT_ROOT" -t $IMAGE_NAME -f "$SCRIPT_DIR/Dockerfile" --build-arg BRANCH=$BRANCH_NAME docker build --no-cache "$PROJECT_ROOT" -t $IMAGE_NAME -f "$SCRIPT_DIR/Dockerfile" --build-arg BRANCH=$BRANCH_NAME # ---------------------------- # Run Docker container # ---------------------------- echo "🚀 Running container: $CONTAINER_NAME in network: $NETWORK_NAME..." echo "🚀 Running container: $CONTAINER_NAME in network: $NETWORK_NAME..." docker run \ docker run \ --rm \ --rm \ --name $CONTAINER_NAME \ --name $CONTAINER_NAME \ --network $NETWORK_NAME \ --network $NETWORK_NAME \ $IMAGE_NAME $IMAGE_NAME # ---------------------------- # Done # ---------------------------- echo "✅ End of script" echo "✅ End of script" No newline at end of file Loading
ci_cd_test/Dockerfile +1 −1 Original line number Original line Diff line number Diff line Loading @@ -3,7 +3,7 @@ FROM labs.etsi.org:5050/ocf/capif/python:3-slim-bullseye WORKDIR /sdk WORKDIR /sdk # Copy project files into the container # Copy project files into the container COPY .. . COPY . . # Install Python dependencies # Install Python dependencies RUN python -m pip install --upgrade pip RUN python -m pip install --upgrade pip Loading
ci_cd_test/test_sdk.sh +25 −1 Original line number Original line Diff line number Diff line #!/bin/bash #!/bin/bash # Name of container image # ---------------------------- # Configuration # ---------------------------- CONTAINER_NAME=capif-sdk-runner CONTAINER_NAME=capif-sdk-runner IMAGE_NAME=opencapif_sdk IMAGE_NAME=opencapif_sdk BRANCH_NAME=${CI_COMMIT_REF_NAME} BRANCH_NAME=${CI_COMMIT_REF_NAME} Loading @@ -9,14 +11,36 @@ NETWORK_NAME=capif-network SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" PROJECT_ROOT="$(dirname "$SCRIPT_DIR")" PROJECT_ROOT="$(dirname "$SCRIPT_DIR")" # ---------------------------- # Create Docker network (if it doesn't exist) # ---------------------------- echo "🌐 Checking for existing Docker network: $NETWORK_NAME..." if ! docker network ls --format '{{.Name}}' | grep -q "^${NETWORK_NAME}$"; then echo "🔧 Network not found. Creating network: $NETWORK_NAME..." docker network create $NETWORK_NAME else echo "✅ Network $NETWORK_NAME already exists." fi # ---------------------------- # Build Docker image # ---------------------------- echo "🛠️ Building image: $IMAGE_NAME from branch: $BRANCH_NAME with no cache..." echo "🛠️ Building image: $IMAGE_NAME from branch: $BRANCH_NAME with no cache..." docker build --no-cache "$PROJECT_ROOT" -t $IMAGE_NAME -f "$SCRIPT_DIR/Dockerfile" --build-arg BRANCH=$BRANCH_NAME docker build --no-cache "$PROJECT_ROOT" -t $IMAGE_NAME -f "$SCRIPT_DIR/Dockerfile" --build-arg BRANCH=$BRANCH_NAME # ---------------------------- # Run Docker container # ---------------------------- echo "🚀 Running container: $CONTAINER_NAME in network: $NETWORK_NAME..." echo "🚀 Running container: $CONTAINER_NAME in network: $NETWORK_NAME..." docker run \ docker run \ --rm \ --rm \ --name $CONTAINER_NAME \ --name $CONTAINER_NAME \ --network $NETWORK_NAME \ --network $NETWORK_NAME \ $IMAGE_NAME $IMAGE_NAME # ---------------------------- # Done # ---------------------------- echo "✅ End of script" echo "✅ End of script" No newline at end of file