Commit 10280af3 authored by Javier Velázquez's avatar Javier Velázquez
Browse files

Create dockerfile to build the nsc image

Create deploy script to build and run the nsc container
Add docker ignore file
parent c6cc0086
Loading
Loading
Loading
Loading

.dockerignore

0 → 100644
+5 −0
Original line number Diff line number Diff line
__pycache__/
*.pyc
*.db
.env
.git/
 No newline at end of file

Dockerfile

0 → 100644
+38 −0
Original line number Diff line number Diff line
# Copyright 2022-2025 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# 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.

# This file is an original contribution from Telefonica Innovación Digital S.L.

FROM python:3.12-slim

# Establece el directorio de trabajo
WORKDIR /app

# Instala dependencias del sistema
RUN apt-get update -qq && \
    apt-get install -y -qq git python3-dev && \
    apt-get clean && rm -rf /var/lib/apt/lists/*

# Copia el contenido del proyecto
COPY . /app

# Instala dependencias de Python
RUN pip install --upgrade pip && \
    pip install -r requirements.txt

# Expone el puerto
EXPOSE 8081

# Comando de inicio
ENTRYPOINT ["python3", "app.py"]

deploy.sh

0 → 100644
+60 −0
Original line number Diff line number Diff line
#!/bin/bash

# Copyright 2022-2025 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)

# 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.

# This file is an original contribution from Telefonica Innovación Digital S.L.

# Container name
CONTAINER_NAME=nsc

# Verify if docker is active
if ! docker info > /dev/null 2>&1; then
    echo "Error: Docker not running. Please, restart Docker service and try again."
    exit 1
fi

# Stop container if running
echo "Verify if '$CONTAINER_NAME' is running..."
if [ $(docker ps -q -f name=$CONTAINER_NAME) ]; then
    echo "Stopping current container '$CONTAINER_NAME'..."
    docker stop $CONTAINER_NAME
fi

# Cleaning residual containers and images
echo "Cleaning old Docker containers and images..."
docker container prune -f
docker image prune -f

# Verificar que .env.example existe
if [ ! -f src/config/.env.example ]; then
    echo "Error: .env.example not found"
    exit 1
fi

# Copy .env.example to .env
echo "Generating .env file..."
cp src/config/.env.example .env

# Read NSC_PORT from .env
NSC_PORT=$(grep '^NSC_PORT=' .env | cut -d '=' -f2)

# Docker build
echo "Building docker image..."
docker build -t nsc .

# Executing nsc
echo "Running nsc on port $NSC_PORT..."
docker run -d --env-file .env -p $NSC_PORT:$NSC_PORT --name $CONTAINER_NAME $CONTAINER_NAME
echo "---READY---"
+16 −0
Original line number Diff line number Diff line
# Copyright 2022-2025 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# 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.

# This file is an original contribution from Telefonica Innovación Digital S.L.

Flask
flask-cors
flask-restx
+5 −2
Original line number Diff line number Diff line
@@ -17,7 +17,9 @@
# -------------------------
# General
# -------------------------
LOGGING_LEVEL=INFO  # Options: CRITICAL, ERROR, WARNING, INFO, DEBUG, NOTSET
NSC_PORT=8081
# Options: CRITICAL, ERROR, WARNING, INFO, DEBUG, NOTSET
LOGGING_LEVEL=INFO
DUMP_TEMPLATES=false

# -------------------------
@@ -46,7 +48,8 @@ DUMMY_MODE=true
# Teraflow
# -------------------------
TFS_IP=127.0.0.1
UPLOAD_TYPE=WEBUI   # Options: WEBUI o NBI
# Options: WEBUI or NBI
UPLOAD_TYPE=WEBUI
# Flag to determine if additional L2VPN configuration support is required for deploying L2VPNs with path selection
TFS_L2VPN_SUPPORT=false

Loading