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
simple api build with django rest framework

Django Rest API django-rest-framework Employees management simple API in this project wrote test suites for endpoints wrote simple doc string for clas

OMAR.A 1 Mar 31, 2022
Simple Crud Api With Django Rest Framework

SIMPLE CRUD API WITH DJANGO REST FRAMEWORK Django REST framework is a powerful and flexible toolkit for building Web APIs. Requirements Python 3.6 Dja

kibet hillary 1 May 3, 2022
A simple API example in Python (Flask framework)

API-Example A simple API in Python(Flask) ✨ Features An API i guess? ??‍♀️ How to use first download the main.py install python then install flask fra

Portgas D Ace 2 Jan 6, 2022
Generate Views, Serializers, and Urls for your Django Rest Framework application

DRF Generators Writing APIs can be boring and repetitive work. Don't write another CRUDdy view in Django Rest Framework. With DRF Generators, one simp

Tobin Brown 332 Dec 17, 2022
REST API framework designed for human beings

Eve Eve is an open source Python REST API framework designed for human beings. It allows to effortlessly build and deploy highly customizable, fully f

eve 6.6k Jan 4, 2023
The Web API toolkit. 🛠

?? The Web API toolkit. ?? Community: https://discuss.apistar.org ?? ?? ?? ?? ?? Documentation: https://docs.apistar.com ?? Requirements: Python 3.6+

Encode 5.6k Dec 27, 2022
Automatically generate a RESTful API service for your legacy database. No code required!

sandman2 sandman2 documentation [ ~ Dependencies scanned by PyUp.io ~ ] sandman2 automagically generates a RESTful API service from your existing data

Jeff Knupp 1.9k Jan 7, 2023
Restful API framework wrapped around MongoEngine

Flask-MongoRest A Restful API framework wrapped around MongoEngine. Setup from flask import Flask from flask_mongoengine import MongoEngine from flask

Close 525 Jan 1, 2023
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
Django REST API with React BoilerPlate

This is a setup of Authentication and Registration Integrated with React.js inside the Django Templates for web apps

Faisal Nazik 91 Dec 30, 2022