Skip to content

Commit b624d87

Browse files
committed
fix: refactor to reduce memory accounting
Signed-off-by: Paul Bastide <pbastide@us.ibm.com>
1 parent 978618b commit b624d87

File tree

2 files changed

+28
-9
lines changed

2 files changed

+28
-9
lines changed

cma-keda/hpa-example/Containerfile

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
FROM quay.io/fedora/fedora-minimal:45
22

33
# Install only PHP CLI
4-
RUN microdnf -y install php-cli && \
5-
microdnf clean all
6-
7-
# Copy PHP script
8-
COPY index.php /app/index.php
9-
WORKDIR /app
10-
11-
# Use PHP built-in web server
4+
RUN microdnf install -y python3.13 python-pip && \
5+
python3.13 --version
126

7+
COPY main.py .
8+
USER 0
9+
RUN chmod 755 main.py
1310
EXPOSE 80
1411
USER 1001
15-
CMD ["php", "-S", "0.0.0.0:80", "index.php", "2>&1", ">", "/dev/null"]
12+
CMD ["python3", "main.py"]

cma-keda/hpa-example/main.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from http.server import HTTPServer, BaseHTTPRequestHandler
2+
import math
3+
4+
class RequestHandler(BaseHTTPRequestHandler):
5+
def do_GET(self):
6+
# CPU-intensive work
7+
x = 0.0
8+
for i in range(10000000):
9+
x += math.sqrt(i + 1)
10+
11+
self.send_response(200)
12+
self.send_header('Content-type', 'text/plain')
13+
self.end_headers()
14+
self.wfile.write(b'OK!')
15+
16+
def log_message(self, format, *args):
17+
pass # Suppress logs to reduce memory
18+
19+
if __name__ == '__main__':
20+
server = HTTPServer(('0.0.0.0', 80), RequestHandler)
21+
print('Server starting on port 80')
22+
server.serve_forever()

0 commit comments

Comments
 (0)