Skip to content

sravagnan/template-project

Repository files navigation

TEMPLATE PROJECT

Logo

TEMPLATE PROJECT

Report Bug/Request Feature

This repository contains ...

Prerequisites

This repository will not work without the following external dependencies:

(back to top)

Structure

The project structure follows the structure below:

  • deploy.sh: this bash file contains the deployment steps to create a Docker Swarm Stack based on the .env file.
  • app: this directory contains the Django application.
    • apps: this directory contains all the reusable apps.
    • config: this directory stores the project configuration files:
      • .env: contains environment variables
      • config.ini: contains logger configuration
      • environment.py: contains pydantic environment model
    • tools: this directory stores reusable tools:

(back to top)

Getting Started

Create a new environment file .env and place it in the src/configs directory, then add the follow environment variables:

### GENERAL
DEBUG=True

Create a new virtual environment by running the command below:

python -m venv .venv

Activate it in a Linux enviroment by running:

source .venv/bin/activate

or in a Windows enviroment by running:

.\.venv\Scripts\activate

Install the dependencies by running:

pip install -r requirements.txt

Run the App

In order to run the app localy you need to locate in root dir and run:

python src/main.py

If you are developing with vscode, the .vscode folder contains the launch.json to be able to run the app in debugging mode.

Deploy the App

If you want to deploy the app into a Docker container using Docker Swarm as a container orchertrator you can simply run:

./deploy.sh

The script builds a container image with the source code, then it creates a stack with some container repliacas, a network and a Swarm service.

Enjoy!

(back to top)

Requirements

Compile dependencies

Run the following command to install pip-tools that is required to compile the requirements.txt

pip install pip-tools

In order to compile the requirements.txt file based on a pyproject.toml file, run the following command:

pip-compile --resolver=backtracking --output-file=requirements.txt pyproject.toml

Setup pre-commit

In order to initialize the environment for pre-commit-hooks run the following command:

pre-commit install

Run tests

In order to run tests with coverage report run this command:

pytest -v -W ignore --cov=. --cov-config=config/.coveragerc tests/

(back to top)

Contact

Stefano Ravagnan - stefano.ravagnan@outlook.com

Project Link: https://github.com/sravagnan/template-project

(back to top)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published