diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..61c6bdd --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,50 @@ + +name: ci + +on: + push: + branches: [ "main" ] + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +permissions: + contents: read + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.10"] + + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + # You can test your matrix by printing the current Python version + - name: Display Python version + run: python -c "import sys; print(sys.version)" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r req.txt + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Login to Registry + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_TOKEN }} + + - name: Build and push docker image + uses: docker/build-push-action@v6 + with: + platforms: linux/amd64,linux/arm64 + push: true + tags: fraunhoferiosb/fx-ccm-dataspace-poc-machine-builder-condition-service:latest diff --git a/.gitignore b/.gitignore index 524f096..de19de4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,15 @@ # Compiled class file *.class +# Ignore Gradle build output directory +build + +.idea +.vs +.vscode + +/secrets + # Log file *.log diff --git a/app/MBCS_API.py b/app/MBCS_API.py index addec70..7f5c9cf 100644 --- a/app/MBCS_API.py +++ b/app/MBCS_API.py @@ -5,7 +5,7 @@ import uuid # in python import base64 # in python import copy # in python -import yaml # MIT +import os # MIT from enum import Enum # in python from typing import Annotated @@ -26,18 +26,16 @@ logging.FileHandler('example.log'), ])#filename='example.log') -# obtain config: -with open('consumer_cfg.yaml', 'r') as file: - consumer_cfg = yaml.safe_load(file) - # - control plane - -url_edc_consumer_control_plane_base = consumer_cfg['consumer-edc-control-plane']['endpoint'] -header_control_plane = consumer_cfg['consumer-edc-control-plane']['header'] # this contains secrets, so please use -at least- a secretsmanager instead +url_edc_consumer_control_plane_base = os.getenv('ENDPOINT') +header_control_plane = { + 'Content-Type': 'application/json', + 'x-api-key': os.getenv('XAPIKEY') +} # - "identities" - -edc_provider_bpn = consumer_cfg['trusted-providers']['Facotry_Operator_A']['BPN'] # "{{EDCTX-10-1-BPN}}" -url_edc_provider_control_plane_base = consumer_cfg['trusted-providers']['Facotry_Operator_A']['endpoint-control-plane'] - +edc_provider_bpn = os.getenv('BPN') +url_edc_provider_control_plane_base = os.getenv('ENDPOINTCONTROLPLANE') class allowed_asset_types(str, Enum): Submodel = "Submodel" @@ -50,9 +48,6 @@ class allowed_asset_types(str, Enum): async def root(): return "Machine Builder Condition Service [PoC TP2.04 & TP4.1]" -@app.get("/config") # REMOVE THIS BECAUSE YOU CAN ACCESS SECRETS!!! -async def get_condig(): - return consumer_cfg # obtain/view available offers