Skip to content

Commit 4fb2276

Browse files
committed
Refactor documentation 2
1 parent 7635cb9 commit 4fb2276

File tree

2 files changed

+128
-0
lines changed

2 files changed

+128
-0
lines changed

docs/docker_building.md

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Building Docker image
2+
3+
In order to prepare Docker image inside root directory of project execute:
4+
```bash
5+
docker build . -t dracan:latest
6+
```
7+
> You may want to change name or tag for this build command
8+
9+
> Docker image released on DockerHub does not contain config JSON files, remember to uncomment them from `.dockerignore` file!
10+
11+
### Docker environmental variables
12+
13+
To **explicitly disable** validation, filtering or restriction, use environment variables which, when passed to the container, will ignore the activation via `rules_config.json`.
14+
> Dracan by default disables filtering/limiting/validation if entry is not present in `rules_config.json` file.
15+
16+
Additional `env`:
17+
```bash
18+
# Proxy TimeOut can be set or it will be 180 seconds by default
19+
PROXY_TIMEOUT=180
20+
21+
# Health Check variables
22+
HEALTHCHECK_DISABLED=false
23+
HEALTHCHECK_PORT=9000 # Unused when HEALTHCHECK_DISABLED=true
24+
25+
# Metrics variables
26+
ALLOW_METRICS_ENDPOINT=true
27+
METRICS_PORT=9100 # Unused when ALLOW_METRICS_ENDPOINT=false
28+
29+
# Optional
30+
LOG_LEVEL=INFO
31+
CONFIG_LOCATION=/some/dir
32+
```
33+
For further details on configuration of env variables, refer to [this doc](./docs/docker_env_config.md).

docs/local_development.md

+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# Local development, testing and quality checking
2+
3+
To start developing Dracan on your local machine, you can set up a mock service for live debugging. Follow these steps to get started:
4+
5+
1. **Clone the Repository**: First, clone the Dracan repository to your local machine if you haven't done so already.
6+
```bash
7+
git clone https://github.com/Veinar/dracan.git
8+
cd dracan
9+
```
10+
2. Set Up a Virtual Environment: It’s recommended to create a virtual environment for your development work to manage dependencies.
11+
```bash
12+
python -m venv venv
13+
source venv/bin/activate # On Windows use `venv\Scripts\Activate.ps1`
14+
```
15+
3. Install Required Dependencies: Install the necessary Python packages using pip. Ensure you have Flask installed, as it is used for the mock service.
16+
```bash
17+
pip install -r requirements.txt
18+
```
19+
4. Run the Mock Service: Start the mock service provided in the Dracan package. This service is located in `tests/destination_mock.py` and simulates the application your Dracan middleware will be interfacing with.
20+
```bash
21+
python tests/destination_mock.py
22+
```
23+
5. Live Debugging: With the mock service running, you can now run Dracan in your local environment. This allows you to test and debug how Dracan interacts with the mock service in real-time.
24+
6. Modify and Test: Make changes to Dracan's code as needed, and observe the interactions with the mock service. This setup enables you to develop efficiently and troubleshoot any issues in real-time.
25+
26+
## Running Unit Tests
27+
28+
> **This is "must have" to be done before submitting a PR to avoid breaking Dracan itself**
29+
30+
Dracan includes a suite of unit tests to ensure the functionality and reliability of the code. Running these tests is an important step when contributing to the project, especially when adding new features or enhancements.
31+
Please note that these tests were written using ChatGPT due to my lack of experience in this area.
32+
33+
### Prerequisites
34+
35+
Before running the tests, make sure you have **pytest** installed in your environment. You can install it using pip:
36+
37+
```bash
38+
pip install pytest
39+
```
40+
41+
### Running the tests
42+
43+
To run the unit tests for Dracan, execute the following command from the root directory of the project:
44+
45+
```bash
46+
pytest tests/
47+
```
48+
49+
This command will run all the tests located in the `tests` directory and provide you with feedback on the results.
50+
51+
### Expanding Tests
52+
53+
As you work on expanding Dracan with new features or validations, it is essential to also expand the test suite. Ensure that any new validations or limiting functionalities are covered by corresponding tests. This practice not only helps maintain the integrity of the project but also provides assurance that existing functionality remains unaffected by new changes.
54+
55+
We encourage you to contribute by writing additional tests and improving the overall test coverage. Your efforts in this area will help ensure that Dracan remains a reliable and robust middleware solution.
56+
57+
## Running Linter
58+
59+
> **This should be done before submitting a PR to avoid major issues in code**
60+
61+
To maintain code quality and ensure adherence to coding standards, Dracan uses a linter to analyze the codebase. Linting is essential in identifying stylistic errors and enforcing a consistent code format, making it easier to read and maintain.
62+
63+
### Prerequisites
64+
65+
Before running the linter, ensure that **pylint** is installed in your environment. You can install it using pip:
66+
67+
```bash
68+
pip install pylint
69+
```
70+
To run the linter for Dracan, execute the following command from the root directory of the project. This command checks for code issues while disabling the C0301 rule, which restricts line length:
71+
72+
```bash
73+
pylint --disable=C0301 dracan/
74+
```
75+
76+
## Running Security analysis
77+
78+
> **This should be done before submitting a PR to avoid major security issues in code**
79+
80+
Security analysis is a critical step to help identify potential vulnerabilities in the code. Dracan uses Bandit, a security tool designed to detect common security issues in Python code.
81+
82+
### Prerequisites
83+
84+
Before running the security analysis, make sure bandit is installed in your environment. You can install it with the following command:
85+
86+
```bash
87+
pip install bandit
88+
```
89+
90+
To run a security analysis on the Dracan codebase, execute the following command from the root directory of the project:
91+
92+
```bash
93+
bandit -r dracan/
94+
```
95+
This command scans the code recursively and reports any detected security issues.

0 commit comments

Comments
 (0)