You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Setup.md
+79-32Lines changed: 79 additions & 32 deletions
Original file line number
Diff line number
Diff line change
@@ -17,37 +17,84 @@ cp .env.example .env
17
17
- Modify the .env file as per your local setup.
18
18
19
19
## Step 2: Choose your setup method (Docker recommended)
20
-
### 1.Recommended method: Setting up development server using docker-compose
21
-
22
-
- Install docker
23
-
24
-
25
-
```sh
26
-
# --- build the docker container ---
27
-
docker-compose build
28
-
29
-
# --- Run the docker container ---
30
-
docker-compose up
31
-
32
-
# --- Collect static files ---
33
-
34
-
### open container bash terminal
35
-
# `app` is the service name in docker-compose.yml
36
-
docker exec -it app /bin/bash
37
-
38
-
# Below commands are for container shell
39
-
### migrate SQL commands in the database file
40
-
python manage.py migrate
41
-
42
-
### collect staticfiles
43
-
python manage.py collectstatic
44
-
45
-
# --- exit out of container shell ---
46
-
exit
47
-
48
-
```
49
-
50
-
### 2.Setting up development server using vagrant
20
+
#### Prerequisites for Docker method
21
+
Ensure the following are installed on your system before proceeding:
22
+
23
+
- Docker
24
+
- Docker Compose
25
+
- PostgreSQL client (optional, for manual database interaction)
26
+
27
+
---
28
+
29
+
### 1. Ensure LF Line Endings
30
+
Before building the Docker images, ensure all files, especially scripts like `entrypoint.sh`, `.env`, `docker-compose.yml`, `Dockerfile`, `settings.py` use LF line endings. Using CRLF can cause build failures. To verify and correct line endings:
31
+
32
+
1. If you're working on a Windows machine or collaborating across different operating systems, ensure consistent line endings:
33
+
- Set `core.autocrlf=input` in Git configurations to enforce LF-style line endings in the repository while preserving your local OS line endings.
34
+
```bash
35
+
git config --global core.autocrlf input
36
+
```
37
+
- Alternatively, in VS Code, you can manually change the line endings:
38
+
- Open the file in the editor.
39
+
- Look forthe line ending type displayedin the bottom-right corner of the VS Code window (e.g., CRLF or LF).
40
+
- Click it and select"LF: Unix" from the dropdown to switch the line endings to LF.
41
+
42
+
2. If the browser **automatically redirects to HTTPS** even in incognito mode, you can try the following:
43
+
For **local development**, make these adjustments in `/blt/settings.py` to enable access over **HTTP**:
44
+
- Set:
45
+
```python
46
+
SECURE_SSL_REDIRECT = False
47
+
SECURE_PROXY_SSL_HEADER = None
48
+
```
49
+
50
+
3. To convert to LF (if needed):
51
+
- Using `dos2unix`:
52
+
```bash
53
+
dos2unix entrypoint.sh
54
+
```
55
+
56
+
⚠️ **Important:**
57
+
- If line endings are not set to LF, running `docker-compose build` may fail.
58
+
- Avoid creating a PR to commit these local changes back to the repository.
59
+
60
+
### 2. PostgreSQL Setup
61
+
The PostgreSQL database listens on a port specified in the .env file.
62
+
Default is 5432 and
63
+
If you encounter conflicts, it might be set to another port (e.g., 5433 in some cases). Adjust the .env file accordingly.
64
+
65
+
---
66
+
67
+
## Commands to Set Up the Project
68
+
69
+
- **Copy and configure the `.env` file:**
70
+
```bash
71
+
cp .env.example .env
72
+
Update credentials and settings as needed.
73
+
74
+
- #### Build the Docker images:
75
+
```bash
76
+
docker-compose build
77
+
- #### Start the containers:
78
+
```bash
79
+
docker-compose up
80
+
- #### Access the application:
81
+
82
+
- Open your browser and navigate to:
83
+
http://localhost:8000/
84
+
- #### Prevent Automatic Redirects to HTTPS:
85
+
- Use Incognito Mode (Private Browsing): Open the browser in incognito mode and access the application using http://localhost:8000.
86
+
- Ensure you're explicitly using http:// instead of https:// in the URL.
87
+
### Notes
88
+
- The project listens on port 8000 over the HTTP protocol.
89
+
- Ensure all required configurations in .env are correct for seamless setup.
90
+
91
+
### Error Edge Cases
92
+
- If container fails execute ./entrypoint.sh due to permission error, use `chmod +x ./entrypoint.sh`
93
+
- If you encounter ./entrypoint.sh was not found, then make sure you are using `LF` line ending in place of `CRLF`
94
+
- If you encounter ERR_SSL_PROTOCOL_ERROR when you try to access the server on http://localhost:8000, make sure the Browser doesn't automatically redirect to https://localhost:8000. If it keeps doing this behaviour, then you can set `SECURE_SSL_REDIRECT` to `False` locally only(search for it /blt/settings.py), stop the container and start it again.
95
+
- If you encounter the same error indicating SSL_REDIRECT in the logs while building the container, set `SECURE_SSL_REDIRECT` to `False`
96
+
97
+
### Option 2.Setting up development server using vagrant
51
98
52
99
-Install [vagrant](https://www.vagrantup.com/)
53
100
@@ -89,7 +136,7 @@ Add a Domain `http://127.0.0.1:8000/admin/website/domain/` with the name 'owasp.
89
136
**Note:** In case you encounter an error with vagrant's vbguest module, run `vagrant plugin install vagrant-vbguest`
90
137
from the host machine.
91
138
92
-
### 3.Setting up development server using python virtual environment
139
+
### Option 3.Setting up development server using python virtual environment
0 commit comments