From 761266d3456ad4c18c3ddd963e73d0b36029eae3 Mon Sep 17 00:00:00 2001 From: Benedetto Debora <Debora.Benedetto@hpecds.com> Date: Mon, 28 Feb 2022 14:14:55 +0100 Subject: [PATCH] Refactoring: update Dockerfile and README with fastapi integration --- Dockerfile | 2 +- README.md | 29 +++++++++++++++++++++-------- requirements.txt | 3 +-- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index e26e070..95128cc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,4 +5,4 @@ COPY . /opt/ RUN pip install -r requirements.txt -CMD ["uvicorn", "app.main:fast_api", "--host", "0.0.0.0", "--port", "8080"] \ No newline at end of file +CMD ["uvicorn", "main:fast_api", "--host", "0.0.0.0", "--port", "5000"] \ No newline at end of file diff --git a/README.md b/README.md index 772c2f0..c62e9cc 100644 --- a/README.md +++ b/README.md @@ -2,22 +2,35 @@ This repository contains all the required code and templates to run the ICG component, it also contains a Dockerfile that builds the complete image of the ICG with a provided REST API +Requirements +------------- +- Docker + Installation ------------- To have a functional ICG application the following steps can be used. - - Download the full content of this repository - - Build the docker image launching the following command: docker build -t icg-image:0.1 . - - Create a volume for the container: docker volume create ICG-volume - - Run the container: docker run --mount source=ICG-volume,target=/opt -p 5000:5000 icg-image:0.1 +- Download the full content of this repository +- Build the docker image launching the following command: `docker build -t icg:0.1 .` +- Run the container: `docker run --name icg -d -p 5000:5000 icg:0.1` -User manual +Usage ------------ To use the now running ICG docker container we can call the available REST API. -The API is available at http://localhost:5000/ . -Sending a POST request at this endpoint with the indicated json body (see parameters.json as an example body) it will respond with a .tar.gz file containing all the required IaC files.: +The API is available at http://localhost:5000/docs. You can try here the endpoint behavior (see input_file_example/nginx/parameters.json as an example body). + +Otherwise, send a POST request at this endpoint with the indicated json body (see input_file_example/nginx/parameters.json as an example body) it will respond with a .tar.gz file containing all the required IaC files: + + - curl --location --request POST localhost:5000/infrastructure/files --header "Content-Type: application/json" --data "@parameters.json" --output "OutputIaC.tar.gz" + +Uninstall +------------ +Remove the docker container and the docker image: - - curl --location --request POST localhost:5000/ --header "Content-Type: application/json" --data "@parameters.json" --output "OutputIaC.tar.gz" +``` +docker container rm -f icg +docker rmi icg:0.1 +``` \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 7c2d192..5d502ac 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,4 @@ Jinja2==3.0.3 -flask==2.0.2 PyYAML==6.0 fastapi~=0.74.1 -uvicorn=0.17.5 \ No newline at end of file +uvicorn==0.17.5 \ No newline at end of file -- GitLab