Skip to content

Commit 7ce75db

Browse files
committed
add slim version
1 parent 5a3c448 commit 7ce75db

5 files changed

Lines changed: 54 additions & 13 deletions

File tree

.github/workflows/docker-images.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,14 @@ jobs:
4444
- name: Build Docker image
4545
run: |
4646
docker build -t ghcr.io/${{ env.REPO_OWNER }}/pyproxy:${{ env.VERSION }} -t ghcr.io/${{ env.REPO_OWNER }}/pyproxy:latest .
47+
48+
- name: Build Docker slim image
49+
run: |
50+
docker build -f Dockerfile.slim -t ghcr.io/${{ env.REPO_OWNER }}/pyproxy:${{ env.VERSION }}-slim -t ghcr.io/${{ env.REPO_OWNER }}/pyproxy:latest-slim .
4751
4852
- name: Push Docker image
4953
run: |
5054
docker push ghcr.io/${{ env.REPO_OWNER }}/pyproxy:${{ env.VERSION }}
5155
docker push ghcr.io/${{ env.REPO_OWNER }}/pyproxy:latest
56+
docker push ghcr.io/${{ env.REPO_OWNER }}/pyproxy:${{ env.VERSION }}-slim
57+
docker push ghcr.io/${{ env.REPO_OWNER }}/pyproxy:latest-slim

Dockerfile.slim

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
FROM python:3.13-slim as builder
2+
WORKDIR /app
3+
COPY requirements.txt .
4+
RUN pip install --no-cache-dir -r requirements.txt
5+
COPY . .
6+
7+
# Remove features
8+
RUN rm -r utils/proxy/monitoring
9+
RUN rm utils/proxy/custom_header.py
10+
RUN rm utils/proxy/shortcuts.py
11+
12+
RUN chmod -R 777 /app/logs
13+
RUN chmod -R 777 /app/config
14+
15+
16+
FROM gcr.io/distroless/python3-debian12:nonroot
17+
WORKDIR /app
18+
COPY --from=builder /usr/local /usr/local
19+
COPY --from=builder /app /app
20+
EXPOSE 8080
21+
ENTRYPOINT ["python3", "pyproxy.py"]

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
- Cancel inspection on bank site
3939
- Custom header
4040
- Web interface monitoring (actives connections, processes status)
41+
- Docker image slim wihtout (moniting, custom header & shortcuts)
4142

4243
## 📦 **Installation**
4344

@@ -86,7 +87,6 @@ If you encounter any problems, or if you want to use the program in a particular
8687
- Adding ACL
8788
- Proxy authentication
8889
- Benchmark
89-
- Image slim wihtout admin interface
9090
- Fix HSTS
9191

9292
---

utils/server.py

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,17 @@
1414
import os
1515
import time
1616

17+
from utils.version import __slim__
1718
from utils.handlers import ProxyHandlers
1819
from utils.proxy.filter import filter_process
19-
from utils.proxy.shortcuts import shortcuts_process
2020
from utils.proxy.cancel_inspect import cancel_inspect_process
21-
from utils.proxy.custom_header import custom_header_process
22-
from utils.proxy.monitoring import start_flask_server
2321
from utils.logger import configure_file_logger, configure_console_logger
22+
if not __slim__:
23+
from utils.proxy.shortcuts import shortcuts_process
24+
if not __slim__:
25+
from utils.proxy.custom_header import custom_header_process
26+
if not __slim__:
27+
from utils.proxy.monitoring import start_flask_server
2428

2529
# pylint: disable=too-few-public-methods,too-many-locals
2630
class ProxyServer:
@@ -104,7 +108,8 @@ def _initialize_processes(self):
104108
self.filter_proc.start()
105109
self.console_logger.debug("[*] Starting the filter process...")
106110

107-
if self.config_shortcuts and os.path.isfile(self.config_shortcuts):
111+
# pylint: disable=E0606
112+
if not __slim__ and self.config_shortcuts and os.path.isfile(self.config_shortcuts):
108113
self.shortcuts_proc = multiprocessing.Process(
109114
target=shortcuts_process,
110115
args=(
@@ -128,7 +133,8 @@ def _initialize_processes(self):
128133
self.cancel_inspect_proc.start()
129134
self.console_logger.debug("[*] Starting the cancel inspection process...")
130135

131-
if self.config_custom_header and os.path.isfile(self.config_custom_header):
136+
# pylint: disable=E0606
137+
if not __slim__ and self.config_custom_header and os.path.isfile(self.config_custom_header):
132138
self.custom_header_proc = multiprocessing.Process(
133139
target=custom_header_process,
134140
args=(
@@ -178,13 +184,14 @@ def start(self):
178184

179185
self._initialize_processes()
180186

181-
flask_thread = threading.Thread(
182-
target=start_flask_server,
183-
args=(self,self.flask_port,self.flask_pass,self.debug),
184-
daemon=True
185-
)
186-
flask_thread.start()
187-
self.console_logger.debug("[*] Starting the monitoring process...")
187+
if not __slim__:
188+
flask_thread = threading.Thread(
189+
target=start_flask_server,
190+
args=(self,self.flask_port,self.flask_pass,self.debug),
191+
daemon=True
192+
)
193+
flask_thread.start()
194+
self.console_logger.debug("[*] Starting the monitoring process...")
188195

189196
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
190197
server.bind(self.host_port)

utils/version.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,11 @@
99
formatted as "major.minor.patch".
1010
"""
1111

12+
import os
13+
1214
__version__ = "0.3.0"
15+
16+
if os.path.isdir("utils/proxy/monitoring"):
17+
__slim__ = False
18+
else:
19+
__slim__ = True

0 commit comments

Comments
 (0)