diff --git a/Dockerfile b/Dockerfile index 8adff3cc1119e59a4563e0d7ae403974159493f6..ac73058c068cdfe89e31fdec854f10cb6e6c1602 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,12 @@ -FROM python:3.10-bullseye +FROM python:3.11.3-buster AS requirements-stage -COPY . /opt/mc_openapi +WORKDIR /code -RUN useradd -mU mc -USER mc -ENV PATH="/home/mc/.local/bin:${PATH}" -RUN pip install --upgrade pip \ - && pip install -r /opt/mc_openapi/requirements.txt -WORKDIR /opt/mc_openapi +COPY ./requirements.txt /code/requirements.txt -ENV UVICORN_PORT=8080 \ - UVICORN_HOST=0.0.0.0 +RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt -CMD ["uvicorn", "mc_openapi.fastapi:app"] +COPY ./mc_openapi /code/mc_openapi +COPY ./tests /code/tests + +CMD ["uvicorn", "mc_openapi.api:app", "--proxy-headers", "--host", "0.0.0.0", "--port", "80"] diff --git a/docker-compose.yaml b/docker-compose.yaml deleted file mode 100644 index 2bbf5c3aaebf132d4a7ccf5a80818e779532008c..0000000000000000000000000000000000000000 --- a/docker-compose.yaml +++ /dev/null @@ -1,10 +0,0 @@ -version: '3.9' -services: - dmc: - build: . - ports: - - "8080:8080" - environment: - UVICORN_PORT: 8080 - UVICORN_HOST: "0.0.0.0" - UVICORN_WORKERS: 2 diff --git a/mc_openapi/__main__.py b/mc_openapi/__main__.py index 8b0d655649ceacce4573a1045b7e1fdd4c83578b..9fc5fd29b74d6380ad35dc3497f78fa4b4196424 100644 --- a/mc_openapi/__main__.py +++ b/mc_openapi/__main__.py @@ -7,7 +7,7 @@ import re from tabulate import tabulate import uvicorn -from mc_openapi.fastapi import app +from mc_openapi.api import app from mc_openapi.doml_mc import DOMLVersion, init_model, verify_csp_compatibility, verify_model, synthesize_model from mc_openapi.doml_mc.domlr_parser.exceptions import RequirementException from mc_openapi.doml_mc.mc_result import MCResult diff --git a/mc_openapi/fastapi.py b/mc_openapi/api.py similarity index 100% rename from mc_openapi/fastapi.py rename to mc_openapi/api.py diff --git a/mc_openapi/openapi/model_checker.yaml b/mc_openapi/openapi/model_checker.yaml deleted file mode 100644 index 3a20209a933620f3a45da32c76595d088a1f4f4b..0000000000000000000000000000000000000000 --- a/mc_openapi/openapi/model_checker.yaml +++ /dev/null @@ -1,203 +0,0 @@ -openapi: 3.0.2 -info: - license: - name: Apache-2.0 - title: PIACERE Model Checker - version: "2.2.1" -paths: - /modelcheck: - post: - summary: Verify a DOML model - description: Send a DOML model in XMI format. - The response says whether the model satisfies the requirements, - with a description of the issue if it is not. - operationId: mc_openapi.handlers.modelcheck - requestBody: - content: - application/xml: - schema: - type: string - required: true - parameters: - - in: query - name: version - schema: - type: string - description: > - The DOML version you're currently using, written as e.g. `2.0` or `V2_0`. - If not specified, it will try to infer it by trying to parse it for each supported - DOML version, starting with the most recent. - required: false - responses: - "200": - content: - application/json: - schema: - type: object - properties: - result: - type: string - enum: - - sat - - unsat - - dontknow - description: - type: string - required: - - result - description: OK - model checking succeded - "400": - content: - application/json: - schema: - $ref: '#/components/schemas/error' - description: malformed request - "500": - content: - application/json: - schema: - $ref: '#/components/schemas/error' - description: internal error - /modelcheck_html: - post: - summary: Verify a DOML model - description: Send a DOML model in XMI format. - The response says whether the model satisfies the requirements, - with a description of the issue if it is not. The output is in HTML. - operationId: mc_openapi.handlers.modelcheck_html - requestBody: - content: - application/xml: - schema: - type: string - required: true - parameters: - - in: query - name: version - schema: - type: string - description: > - The DOML version you're currently using, written as e.g. `2.0` or `V2_0`. - If not specified, it will try to infer it by trying to parse it for each supported - DOML version, starting with the most recent. - required: false - responses: - "200": - content: - text/html: - schema: - type: string - description: OK - model checking succeded - "400": - content: - application/json: - schema: - $ref: '#/components/schemas/error' - description: malformed request - "500": - content: - application/json: - schema: - $ref: '#/components/schemas/error' - description: internal error - /csp: - post: - summary: Verify compatibility of a DOML model with a set of Cloud Service Providers. - description: Send a DOML model in XMI format and a requirement to check. - The response says whether the model can be deployed on the supported CSPs. - It produces a compatibility matrix and lists required properties for each CSP. - operationId: mc_openapi.handlers.csp - requestBody: - content: - application/xml: - schema: - type: string - required: true - parameters: - - in: query - name: version - schema: - type: string - description: > - The DOML version you're currently using, written as e.g. `2.0` or `V2_0`. - If not specified, it will try to infer it by trying to parse it for each supported - DOML version, starting with the most recent. - required: false - responses: - "200": - content: - application/json: - schema: - type: object - description: OK - CSP compatibility successfully completed. - "400": - content: - application/json: - schema: - $ref: '#/components/schemas/error' - description: malformed request - "500": - content: - application/json: - schema: - $ref: '#/components/schemas/error' - description: internal error - /csp_html: - post: - summary: Verify compatibility of a DOML model with a set of Cloud Service Providers. - description: Send a DOML model in XMI format and a requirement to check. - The response says whether the model can be deployed on the supported CSPs. - It produces a compatibility matrix and lists required properties for each CSP. - operationId: mc_openapi.handlers.csp_html - requestBody: - content: - application/xml: - schema: - type: string - required: true - parameters: - - in: query - name: version - schema: - type: string - description: > - The DOML version you're currently using, written as e.g. `2.0` or `V2_0`. - If not specified, it will try to infer it by trying to parse it for each supported - DOML version, starting with the most recent. - required: false - responses: - "200": - content: - text/html: - schema: - type: string - description: OK - CSP compatibility successfully completed. - "400": - content: - application/json: - schema: - $ref: '#/components/schemas/error' - description: malformed request - "500": - content: - application/json: - schema: - $ref: '#/components/schemas/error' - description: internal error -components: - schemas: - error: - type: object - properties: - timestamp: - type: string - format: date-time - message: - type: string - description: Error message for the user - debug_message: - type: string - description: Detailed error message for debugging purposes - required: - - timestamp - - message