Eazytraining - Simple application to show how to query API from webapp

Overview

student-list

Eazytraining - Simple application to show how to query API from webapp

This repo is a simple application to list student with a webserver (PHP) and API (Flask)

project


Objectives

The objectives of this practice exam are to ensure that you are able to manage a docker infrastructure, so you will be evaluated about the following

Themes:

  • improve an existed application deployment process
  • versioning your infrastructure release
  • address best practice when implementing docker infrastructure
  • Infrastructure As Code

Context

POZOS is an IT company located in France and develops software for High School.

The innovation department want to disrupt the existing infrastructure to ensure that

it can be scalable, easily deployed with a maximum of automation.

POZOS wants you to build a POC to show how docker can help you and how much this technology is efficient.

For this POC, POZOS will give you an application and want you to build a "decouple" infrastructure based on Docker.

Currently, the application is running on a single server with any scalability and any high availability.

When POZOS needs to deploy a new release, every time some goes wrong.

In conclusion, POZOS needs agility on its software farm.

Infrastructure

For this POC, you will only use one single machine with a docker installed on it.

The build and the deployment will be made on this machine.

POZOS recommends you to use centos7.6 OS because it's the most used in the company.

Please also note that you are authorized to use a virtual machine base on Centos7.6 and not your physical machine.

The security is a very critical aspect of POZOS DSI so please do not disable the firewall or other security mechanisms otherwise please explain your reasons in your delivery.

Application

The application that you will be working on is named "student_list", this application is very basic and enables POZOS to show the list of the student with their age.

student_list has two modules:

  • the first module is a REST API (with basic authentication needed) who send the desire list of the student based on JSON file
  • The second module is a web app written in HTML + PHP who enable end-user to get a list of students

Your work is to build one container for each module an make them interact with each other

Application source code can be found here

The files that you must provide (in your delivery) are Dockerfile and docker-compose.yml (currently both are empty)

Now it is time to explain you each file's role:

  • docker-compose.yml: to launch the application (API and web app)
  • Dockerfile: the file that will be used to build the API image (details will be given)
  • student_age.json: contain student name with age on JSON format
  • student_age.py: contains the source code of the API in python
  • index.php: PHP  page where end-user will be connected to interact with the service to - list students with age. You need to update the following line before running the website container to make api_ip_or_name and port fit your deployment $url = 'http:// /pozos/api/v1.0/get_student_ages';

Build and test (7 points)

POZOS will give you information to build the API container

  • Base image

To build API image you must use "python:2.7-stretch"

  • Maintainer

Please don't forget to specify the maintainer information

  • Add the source code

You need to copy the source code of the API in the container at the root "/" path

  • Prerequisite

The API is using FLASK engine,  here is a list of the package you need to install

apt-get update -y && apt-get install python-dev python3-dev libsasl2-dev python-dev libldap2-dev libssl-dev -y
pip install flask==1.1.2 flask_httpauth==4.1.0 flask_simpleldap python-dotenv==0.14.0
  • Persistent data (volume)

Create data folder at the root "/" where data will be stored and declare it as a volume

You will use this folder to mount student list

  • API Port

To interact with this API expose 5000 port

  • CMD

When container start, it must run the student_age.py (copied at step 4), so it should be something like

CMD [ "python", "./student_age.py" ]

Build your image and try to run it (don't forget to mount student_age.json file at /data/student_age.json in the container), check logs and verify that the container is listening and is  ready to answer

Run this command to make sure that the API correctly responding (take a screenshot for delivery purpose)

curl -u toto:python -X GET http:// : /pozos/api/v1.0/get_student_ages

Congratulation! Now you are ready for the next step (docker-compose.yml)

Infrastructure As Code (5 points)

After testing your API image, you need to put all together and deploy it, using docker-compose.

The docker-compose.yml file will deploy two services :

  • website: the end-user interface with the following characteristics
    • image: php:apache   - environment: you will provide the USERNAME and PASSWORD to enable the web app to access the API through authentication
    • volumes: to avoid php:apache image run with the default website, we will bind the website given by POZOS to use. You must have something like ./website:/var/www/html
    • depend on: you need to make sure that the API will start first before the website
    • port: do not forget to expose the port
  • API: the image builded before should be used with the following specification
    • image: the name of the image builded previously   - volumes: You will mount student_age.json file in /data/student_age.json
    • port: don't forget to expose the port

Delete your previous created container

Run your docker-compose.yml

Finally, reach your website and click on the bouton "List Student"

If the list of the student appears, you are successfully dockerizing the POZOS application! Congratulation (make a screenshot)

Docker Registry (4 points)

POZOS need you to deploy a private registry and store the built images

So you need to deploy :

Or you can use Portus to run both

Don't forget to push your image on your private registry and show them in your delivery.

Delivery (4 points)

Your delivery must be zip named firstname.zip (replace firstname by your own) that contain:

  • A doc or PDF file with your screenshots and explanations.
  • Configuration files used to realize the graded exercise (docker-compose.yml and Dockerfile).

Your delivery will be evaluated on:

  • Explanations quality
  • Screenshots quality (relevance, visibility)
  • Presentation quality

Send your delivery at [email protected] and we will provide you the link of the solution.

good luck

You might also like...
Estudo e desenvolvimento de uma API REST

Estudo e desenvolvimento de uma API REST 🧑‍💻 Tecnologias Esse projeto utilizará as seguintes tecnologias: Git Python Flask DBeaver Vscode SQLite 🎯

Um aplicativo de usuários feito em Django REST Framework, nesse aplicativo eu modifiquei o modelo padrão de user do Django, adicionando campos personalizados e login com email e senha, também desenvolvi funcionalidades para a API e testes automatizados, para conferir tudo leia o README abaixo! RESTler is the first stateful REST API fuzzing tool for automatically testing cloud services through their REST APIs and finding security and reliability bugs in these services.
RESTler is the first stateful REST API fuzzing tool for automatically testing cloud services through their REST APIs and finding security and reliability bugs in these services.

RESTler is the first stateful REST API fuzzing tool for automatically testing cloud services through their REST APIs and finding security and reliability bugs in these services.

JSON:API support for Django REST framework

JSON:API and Django REST framework Overview JSON:API support for Django REST framework Documentation: https://django-rest-framework-json-api.readthedo

Django-rest-auth provides a set of REST API endpoints for Authentication and Registration

This app makes it extremely easy to build Django powered SPA's (Single Page App) or Mobile apps exposing all registration and authentication related functionality as CBV's (Class Base View) and REST (JSON)

One package to access multiple different data sources through their respective API platforms.

BESTLab Platform One package to access multiple different data sources through their respective API platforms. Usage HOBO Platform See hobo_example.py

A Django-powered API with various utility apps / endpoints.
A Django-powered API with various utility apps / endpoints.

A Django-powered API Includes various utility apps / endpoints. Demos These web apps provide a frontend to the APIs in this project. Issue API Explore

REST API with Flask. No data persistence.
REST API with Flask. No data persistence.

Flask REST API Python 3.9.7 The Flask experience, without data persistence :D First, to install all dependencies: python -m pip install -r requirement

BloodDonors: Built using Django REST Framework for the API backend and React for the frontend
BloodDonors: Built using Django REST Framework for the API backend and React for the frontend

BloodDonors By Daniel Yuan, Alex Tian, Aaron Pan, Jennifer Yuan As the pandemic raged, one of the side effects was an urgent shortage of blood donatio

Releases(v1.0)
Owner
⚡Christophe FREIJANES
Administrateur Systèmes - Enthousiaste - DevOps / SRE 🚀
⚡Christophe FREIJANES
RESTler is the first stateful REST API fuzzing tool for automatically testing cloud services through their REST APIs and finding security and reliability bugs in these services.

RESTler is the first stateful REST API fuzzing tool for automatically testing cloud services through their REST APIs and finding security and reliability bugs in these services.

Microsoft 1.8k Jan 04, 2023
Automated generation of real Swagger/OpenAPI 2.0 schemas from Django REST Framework code.

drf-yasg - Yet another Swagger generator Generate real Swagger/OpenAPI 2.0 specifications from a Django Rest Framework API. Compatible with Django Res

Cristi Vîjdea 3k Jan 06, 2023
A lightweight REST miniframework for Python.

restless A lightweight REST miniframework for Python. Documentation is at https://restless.readthedocs.io/. Works great with Django, Flask, Pyramid, T

Daniel Lindsley 824 Nov 20, 2022
Kong API Manager with Prometheus And Splunk

API Manager Stack Run Kong Server + Konga + Prometheus + Grafana + API & DDBB + Splunk Clone the proyect and run docker-compose up

Santiago Fernandez 82 Nov 26, 2022
A Django api to display items and their current up-to-date prices from different online retailers in one platform.

A Django api to display items and their current up-to-date prices from different online retailers in one platform. Utilizing scrapy to periodically scrape the latest prices from different online reta

Kennedy Ngugi Mwaura 1 Nov 05, 2021
Swagger Documentation Generator for Django REST Framework: deprecated

Django REST Swagger: deprecated (2019-06-04) This project is no longer being maintained. Please consider drf-yasg as an alternative/successor. I haven

Marc Gibbons 2.6k Dec 23, 2022
Django-rest-auth provides a set of REST API endpoints for Authentication and Registration

This app makes it extremely easy to build Django powered SPA's (Single Page App) or Mobile apps exposing all registration and authentication related functionality as CBV's (Class Base View) and REST

Tivix 2.4k Dec 29, 2022
Embrace the APIs of the future. Hug aims to make developing APIs as simple as possible, but no simpler.

Read Latest Documentation - Browse GitHub Code Repository hug aims to make developing Python driven APIs as simple as possible, but no simpler. As a r

Hug API Framework 6.7k Dec 27, 2022
Flask RestAPI Project - Transimage Rest API For Python

[ 이미지 변환 플라스크 Rest API ver01 ] 0. Flask Rest API - in SunnyWeb : 이미지 변환 웹의 Flask

OliverKim 1 Jan 12, 2022
Build a Backend REST API with Python & Django

Build a Backend REST API with Python & Django Skills Python Django djangorestframework Aws Git Use the below Git commands in the Windows Command Promp

JeonSoohyun a.k.a Edoc.. 1 Jan 25, 2022
RESTful Todolist API

RESTful Todolist API GET todolist/ POST todolist/ {"desc" : "Description of task to do"} DELETE todolist/int:id PUT todolist/int:id Requirements D

Gabriel Tavares 5 Dec 20, 2021
Country-specific Django helpers, to use in Django Rest Framework

django-rest-localflavor Country-specific serializers fields, to Django Rest Framework Documentation (soon) The full documentation is at https://django

Gilson Filho 19 Aug 30, 2022
Document Web APIs made with Django Rest Framework

DRF Docs Document Web APIs made with Django Rest Framework. View Demo Contributors Wanted: Do you like this project? Using it? Let's make it better! S

Manos Konstantinidis 626 Nov 20, 2022
A minimalistic manga reader for desktop built with React and Django

smanga A minimalistic manga reader/server for serving local manga images on desktop browser. Provides a two-page view layout just as reading a physica

Padam Upreti 13 Sep 24, 2022
Mlflow-rest-client - Python client for MLflow REST API

Python Client for MLflow Python client for MLflow REST API. Features: Minimal de

MTS 35 Dec 23, 2022
A light REST library for Django.

django-nap Read The Docs: https://django-nap.readthedocs.io/en/latest/ Change log: https://django-nap.readthedocs.io/en/latest/changelog.html An API l

Curtis Maloney 223 Dec 07, 2022
Sanic-RESTPlus is an extension for Sanic that adds support for quickly building REST APIs.

Sanic RestPlus Sanic-RESTPlus is an extension for Sanic that adds support for quickly building REST APIs. Sanic-RESTPlus encourages best practices wit

Ashley Sommer 106 Oct 14, 2022
Recursive Serialization for Django REST framework

djangorestframework-recursive Overview Recursive Serialization for Django REST framework This package provides a RecursiveField that enables you to se

336 Dec 28, 2022
FastAPI framework, high performance, easy to learn, fast to code, ready for production

FastAPI framework, high performance, easy to learn, fast to code, ready for production Documentation: https://fastapi.tiangolo.com Source Code: https:

Sebastián Ramírez 53.1k Jan 06, 2023
Key-Value база данных на Tarantool и REST API к ней.

KVmail Key-Value база данных на Tarantool и REST API к ней. Документация к API доступна здесь. Requiremrnts ubuntu 16.04+ python3.6+ supervisord nginx

1 Jun 16, 2021