Commit 86a871f4 authored by Javier Velázquez's avatar Javier Velázquez
Browse files

Merge branch 'feat/18-dev-containerize-nsc' into 'develop'

Resolve "(Dev) Create dockerfile to build the nsc image"

See merge request !17
parents c6cc0086 942795db
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
+19 −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.

docker logs nsc
 No newline at end of file
Loading