Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
venv/
*.venv/
__pycache__/
*.pyc
*.pyo
*.pyd
.vscode/
.idea/

.git/
17 changes: 17 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM python:3.10-slim
WORKDIR /app
COPY requirements_docker.txt .

RUN apt-get update && \
apt-get install -y gcc build-essential python3-dev && \
pip install -r requirements_docker.txt && \
apt-get purge -y gcc build-essential python3-dev && \
apt-get autoremove -y && \
apt-get clean


COPY . .
RUN chmod +x /app/entrypoint.sh
ENTRYPOINT ["/app/entrypoint.sh"]

CMD ["python", "main.py"]
43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,49 @@ python3 main.py --create-config
sudo python3 main.py -v
```

# 🐳 Running with Docker

Using Docker is the recommended way to run the firewall, as it automatically manages all dependencies and network permissions.

---

## βœ… Prerequisites

Make sure you have the following installed:

- **Docker**
- **Docker Compose**
*(Docker Desktop for Windows/macOS includes both.)*

---


### **1. Build and Run**

Open your terminal in the project’s root directory and run:

```bash
docker-compose run --rm firewall
```

The image will build the **first time** you run this command.

`--rm` ensures the container is automatically removed when it stops.

---

## 2. Select Network Interface

After the container starts, you will be prompted to choose the interface:

Select an interface (0–2): 2


---

## βœ… To Stop

Press: Ctrl + C


## Configuration
Expand Down
10 changes: 10 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
services:
firewall:
build: .
container_name: firewall

cap_add:
- NET_ADMIN
network_mode: "host"

restart: unless-stopped
16 changes: 16 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh

# This script runs inside the container
# It checks if a config file exists. If not, it creates one.

CONFIG_FILE="firewall_config.json"

if [ ! -f "$CONFIG_FILE" ]; then
echo "--- No $CONFIG_FILE found, creating one... ---"
python main.py --create-config
echo "--- Default config file created. ---"
else
echo "--- Using existing $CONFIG_FILE. ---"
fi
echo "--- Starting firewall... ---"
exec "$@"
5 changes: 5 additions & 0 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pytest>=7.0.0
pytest-cov>=4.0.0
black>=22.0.0
flake8>=5.0.0
isort>=5.10.0
4 changes: 4 additions & 0 deletions requirements_docker.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
scapy>=2.4.0
psutil>=5.8.0
colorama>=0.4.0
netifaces>=0.11.0
Loading