Commit 3d0e5f42 authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Merge branch 'feat/pathcomp-component-frontend' of...

Merge branch 'feat/pathcomp-component-frontend' of https://gitlab.com/teraflow-h2020/controller into feat/pathcomp-component
parents e33c0b22 ef420f23
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -25,4 +25,4 @@ RCFILE=$PROJECTDIR/coverage/.coveragerc
#-o log_cli=true -o log_file=service.log -o log_file_level=DEBUG

coverage run --rcfile=$RCFILE --append -m pytest --log-level=INFO --verbose \
    pathcomp/tests/test_unitary.py
    pathcomp/frontend/tests/test_unitary.py
+31 −6
Original line number Diff line number Diff line
@@ -13,15 +13,15 @@
# limitations under the License.

# Build, tag and push the Docker image to the GitLab registry
build pathcomp:
build pathcomp_frontend:
  variables:
    IMAGE_NAME: 'pathcomp' # name of the microservice
    IMAGE_NAME: 'pathcomp_frontend' # name of the microservice
    IMAGE_TAG: 'latest' # tag of the container image (production, development, etc)
  stage: build
  before_script:
    - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
  script:
    - docker build -t "$IMAGE_NAME:$IMAGE_TAG" -f ./src/$IMAGE_NAME/Dockerfile .
    - docker build -t "$IMAGE_NAME:$IMAGE_TAG" -f ./src/$IMAGE_NAME/frontend/Dockerfile .
    - docker tag "$IMAGE_NAME:$IMAGE_TAG" "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG"
    - docker push "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG"
  after_script:
@@ -32,9 +32,34 @@ build pathcomp:
    - changes:
      - src/common/**/*.py
      - proto/*.proto
      - src/$IMAGE_NAME/**/*.{py,in,yml}
      - src/$IMAGE_NAME/Dockerfile
      - src/$IMAGE_NAME/tests/*.py
      - src/$IMAGE_NAME/frontend/**/*.{py,in,yml}
      - src/$IMAGE_NAME/frontend/Dockerfile
      - src/$IMAGE_NAME/frontend/tests/*.py
      - manifests/${IMAGE_NAME}service.yaml
      - .gitlab-ci.yml

build pathcomp_backend:
  variables:
    IMAGE_NAME: 'pathcomp_backend' # name of the microservice
    IMAGE_TAG: 'latest' # tag of the container image (production, development, etc)
  stage: build
  before_script:
    - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
  script:
    - docker build -t "$IMAGE_NAME:$IMAGE_TAG" -f ./src/$IMAGE_NAME/backend/Dockerfile .
    - docker tag "$IMAGE_NAME:$IMAGE_TAG" "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG"
    - docker push "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG"
  after_script:
    - docker images --filter="dangling=true" --quiet | xargs -r docker rmi
  rules:
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && ($CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "develop" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH)'
    - if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "develop"'
    - changes:
      - proto/*.proto
      - src/$IMAGE_NAME/.gitlab-ci.yml
      - src/$IMAGE_NAME/backend/**/*.{c,h,conf}
      - src/$IMAGE_NAME/backend/Makefile
      - src/$IMAGE_NAME/backend/Dockerfile
      - manifests/${IMAGE_NAME}service.yaml
      - .gitlab-ci.yml

+37 −0
Original line number Diff line number Diff line
# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/)
#
# 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.

# Multi-stage Docker image build

# Stage 1
FROM ubuntu:20.04 AS builder
ARG DEBIAN_FRONTEND=noninteractive

# Install build software
RUN apt-get update -y && apt-get install build-essential libglib2.0-dev -y
RUN apt-get install gdb gdbserver -y

# mkdir
RUN mkdir -p /var/teraflow

# Define working directory
WORKDIR /var/teraflow

# Copy every file in working directory
COPY src/pathcomp/backend/. ./
RUN make

EXPOSE 8081

ENTRYPOINT [ "gdb", "--args", "./pathComp", "config/pathcomp.conf", "pathcomp.log" ] 
+4 −0
Original line number Diff line number Diff line
@@ -11,3 +11,7 @@
# 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.

BACKEND_URL  = 'http://{:s}:{:d}/pathComp/api/v1/compRoute'
BACKEND_HOST = '172.28.0.2'
BACKEND_PORT = 8081
+2 −2
Original line number Diff line number Diff line
@@ -56,7 +56,7 @@ RUN find . -type f -exec sed -i -E 's/(import\ .*)_pb2/from . \1_pb2/g' {} \;
# Create component sub-folders, get specific Python packages
RUN mkdir -p /var/teraflow/pathcomp
WORKDIR /var/teraflow/pathcomp
COPY src/pathcomp/requirements.in requirements.in
COPY src/pathcomp/frontend/requirements.in requirements.in
RUN pip-compile --quiet --output-file=requirements.txt requirements.in
RUN python3 -m pip install -r requirements.txt

@@ -66,4 +66,4 @@ COPY src/context/. context/
COPY src/pathcomp/. pathcomp/

# Start the service
ENTRYPOINT ["python", "-m", "pathcomp.service"]
ENTRYPOINT ["python", "-m", "pathcomp.frontend.service"]
Loading