This is python project, having one api that parses CI logs and give result in json format. In this code we used few frameworks listed below.
- Flask for rest api
- flasgger for OpenAPI documentation(swagger)
- gunicorn for WSGI HTTP Server
- pytest for unit testing
Go to project folder and run below commands.
pip3 install -r requirements.txt
gunicorn --workers=2 -b 0.0.0.0:5000 run:appworker=2 means 2 process/worker will run for this command, and it will host into 5000 port.
Step1: Go to project folder.
Step2: Build docker image with name as "api-challenge"
docker build -t api-challenge .Step3: Verify created docker image and Note the 'IMAGE ID' of created image
docker imagesStep4: Run docker image on port 5000 by giving docker image id that we got it from earlier command.
docker run -p 5000:5000 <image id>Step1: Pull docker image created from this code and hosted into docker hub using below command.
docker pull rajusem/api-challengeStep2: Verify image using below command.
docker imagesStep3: Run docker image on port 5000 by giving docker image id that we got it from earlier command.
docker run -p 5000:5000 <image id>POST /api/log-parser
content-type: multipart/form-data
parameters:
log-data : file which contains CI logs You can test the same using Swagger UI by following below steps.
- Open swagger UI locally by opening url "http://127.0.0.1:5000/apidocs/#/python-api-codding-challenge/post_api_log_parser" into browser.
(Hosted api into openshift platform : http://python-api-challenge.apps.us-west-2.online-starter.openshift.com/apidocs/#/python-api-codding-challenge/post_api_log_parser (Deprecated as trial subscription expired)) - Click on Try it out button
- Browse CI log file from your system and select the same. (Download sample CI logs from here)
- Click on Execute button
