Skip to content

Commit f1c608d

Browse files
authored
Merge pull request #3 from raphink/webapp
Poisoning/Webapp/LLM improvements
2 parents c9ba27a + 6a66e3a commit f1c608d

29 files changed

+682
-480
lines changed

base/Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM python:3.9-slim
2+
3+
WORKDIR /app
4+
5+
COPY requirements.txt .
6+
RUN apt-get update && apt-get install -y --no-install-recommends \
7+
gcc \
8+
g++ \
9+
&& pip install --no-cache-dir -r requirements.txt --index-url https://download.pytorch.org/whl/cpu \
10+
&& apt-get purge -y gcc g++ && apt-get autoremove -y \
11+
&& rm -rf /var/lib/apt/lists/*

base/requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
torch
2+
torchvision

inference/Dockerfile

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,24 @@
1-
FROM python:3.9-slim
1+
# ../base/Dockerfile is the base image with Python and PyTorch installed
2+
FROM mnist:base
23

34
WORKDIR /app
45

5-
COPY . .
6+
# Copy requirements first for better Docker layer caching
7+
COPY requirements.txt .
68

7-
RUN pip3 install --no-cache-dir -r requirements.txt
9+
# Install requirements
10+
RUN pip install --no-cache-dir -r requirements.txt
11+
12+
# Copy application code
13+
COPY app/ ./app/
14+
COPY main.py .
15+
16+
# Create non-root user for security
17+
RUN groupadd -r appgroup && useradd -r -g appgroup appuser
18+
RUN chown -R appuser:appgroup /app
19+
USER appuser
820

921
EXPOSE 5000
22+
23+
# Use exec form for better signal handling
24+
CMD ["python", "main.py"]

inference/Dockerfile.slim

Lines changed: 0 additions & 44 deletions
This file was deleted.
-4.58 MB
Binary file not shown.

inference/app/mnist_cnn.pt

-4.58 MB
Binary file not shown.

inference/inference.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@ kind: Deployment
33
metadata:
44
name: mnist-inference
55
labels:
6-
app: mnist
6+
app: mnist-inference
77
spec:
88
replicas: 1
99
selector:
1010
matchLabels:
11-
app: mnist
11+
app: mnist-inference
1212
template:
1313
metadata:
1414
labels:
15-
app: mnist
15+
app: mnist-inference
1616
spec:
1717
containers:
1818
- name: mnist
@@ -31,12 +31,12 @@ spec:
3131
apiVersion: v1
3232
kind: Service
3333
metadata:
34-
name: mnist-inference-service
34+
name: mnist-inference
3535
labels:
36-
app: mnist
36+
app: mnist-inference
3737
spec:
3838
selector:
39-
app: mnist
39+
app: mnist-inference
4040
ports:
4141
- protocol: TCP
4242
port: 5000

inference/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def predict():
2323
except Exception as e:
2424
return jsonify({'error': str(e)})
2525

26-
@app.route('/refresh')
26+
@app.route('/refresh', methods=['PUT'])
2727
def refresh():
2828
refresh_model()
2929
return 'Model refreshed successfully\n'

inference/requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
torch
2-
torchvision
3-
flask
1+
flask
2+
pillow
3+
numpy

llm/Dockerfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM python:3.11-slim
2+
3+
WORKDIR /app
4+
COPY requirements.txt .
5+
RUN pip install -r requirements.txt
6+
7+
COPY agent-server.py .
8+
9+
EXPOSE 8080
10+
CMD ["python", "agent-server.py"]

0 commit comments

Comments
 (0)