This repository contains ...
This repository will not work without the following external dependencies:
- docker
- traefik, following the dockerswarm.rocks instructions
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
.envfile. - 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:
Create a new environment file .env and place it in the src/configs directory, then add the follow environment variables:
### GENERAL
DEBUG=TrueCreate a new virtual environment by running the command below:
python -m venv .venvActivate it in a Linux enviroment by running:
source .venv/bin/activateor in a Windows enviroment by running:
.\.venv\Scripts\activateInstall the dependencies by running:
pip install -r requirements.txtIn order to run the app localy you need to locate in root dir and run:
python src/main.pyIf you are developing with vscode, the .vscode folder contains the launch.json to be able to run the app in debugging mode.
If you want to deploy the app into a Docker container using Docker Swarm as a container orchertrator you can simply run:
./deploy.shThe 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!
Run the following command to install pip-tools that is required to compile the requirements.txt
pip install pip-toolsIn 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.tomlIn order to initialize the environment for pre-commit-hooks run the following command:
pre-commit installIn order to run tests with coverage report run this command:
pytest -v -W ignore --cov=. --cov-config=config/.coveragerc tests/Stefano Ravagnan - stefano.ravagnan@outlook.com
Project Link: https://github.com/sravagnan/template-project