This is a simple application to be used in the technical test of DevOps.
- Python 3.11.3
Clone this repo.
git clone https://bitbucket.org/devsu/demo-devops-python.git
Install dependencies.
pip install -r requirements.txt
Migrate database
py manage.py makemigrations
py manage.py migrate
The database is generated as a file in the main path when the project is first run, and its name is db.sqlite3
.
Consider giving access permissions to the file for proper functioning.
To run tests you can use this command.
py manage.py test
To run locally the project you can use this command.
py manage.py runserver
Open http://localhost:8000/api/ with your browser to see the result.
These services can perform,
To create a user, the endpoint /api/users/ must be consumed with the following parameters:
Method: POST
{
"dni": "dni",
"name": "name"
}
If the response is successful, the service will return an HTTP Status 200 and a message with the following structure:
{
"id": 1,
"dni": "dni",
"name": "name"
}
If the response is unsuccessful, we will receive status 400 and the following message:
{
"detail": "error"
}
To get all users, the endpoint /api/users must be consumed with the following parameters:
Method: GET
If the response is successful, the service will return an HTTP Status 200 and a message with the following structure:
[
{
"id": 1,
"dni": "dni",
"name": "name"
}
]
To get an user, the endpoint /api/users/ must be consumed with the following parameters:
Method: GET
If the response is successful, the service will return an HTTP Status 200 and a message with the following structure:
{
"id": 1,
"dni": "dni",
"name": "name"
}
If the user id does not exist, we will receive status 404 and the following message:
{
"detail": "Not found."
}
Copyright © 2023 Devsu. All rights reserved.
Developer Documentation
Docker image create using DockerFile the image is public accesible on DockerHub
https://hub.docker.com/repository/docker/vantares/docker-django-app/general
On GitHub Packages in: https://github.com/users/vantares/packages/container/package/docker-django-app
Workflows created:
- Build and push
- Release
- Lint code check with flake8
- Synk security scan
Application deployed to EKS