Skip to content

Commit cd5443f

Browse files
committed
Implement GenAI functionality
1 parent 6933149 commit cd5443f

File tree

18 files changed

+259
-76
lines changed

18 files changed

+259
-76
lines changed

deployment/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ The `deployment` directory contains necessary files for the deployment of Meet@M
44
To deploy the system manually on your local machine, follow the guides below. Automated deployment workflows in GitHub Actions can be found under `../.github/workflows`.
55

66
## Docker Compose
7+
Prerequisites:
8+
- a `.env` file is located in `/docker` directory and contains the `OPENAI_API_KEY` secret for the GenAI service (in AWS deployment, a GitHub secret is used instead)
9+
710
Use the following commands to start / stop / inspect the project using Docker Compose:
811
```
912
cd docker # Move to docker directory
@@ -26,6 +29,12 @@ kubectl create secret generic <match/user>-db-secret \
2629
--from-literal=MYSQL_ROOT_PASSWORD='<your-password>' \
2730
--namespace devoops
2831
```
32+
- OpenAI API key is saved as secret in the `devoops` namespace:
33+
```
34+
kubectl create secret generic genai-secret \
35+
--from-literal=OPENAI_API_KEY=sk-... \
36+
--namespace devoops
37+
```
2938

3039
Once the three requirements are fulfilled, you can run the application:
3140
```

deployment/compose.aws.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ services:
9898

9999
meetatmensa-genai:
100100
image: ghcr.io/aet-devops25/team-devoops/genai:latest
101+
environment:
102+
OPENAI_API_KEY: ${OPENAI_API_KEY}
101103
container_name: meetatmensa-genai
102104
labels:
103105
- traefik.enable=true

deployment/docker/compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ services:
4141
- "80"
4242
networks:
4343
- backend
44+
env_file:
45+
- .env
4446

4547
meetatmensa-client:
4648
build:

deployment/k8s/charts/genai/templates/deployment.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ spec:
4040
{{- end }}
4141
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
4242
imagePullPolicy: {{ .Values.image.pullPolicy }}
43+
env:
44+
- name: OPENAI_API_KEY
45+
valueFrom:
46+
secretKeyRef:
47+
name: genai-secret
48+
key: OPENAI_API_KEY
4349
ports:
4450
- name: http
4551
containerPort: {{ .Values.service.port }}

infrastructure/ansible/playbooks/deploy.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,4 +105,5 @@
105105
remove_orphans: yes
106106
environment:
107107
DOCKER_BUILDKIT: 1
108-
EC2_PUBLIC_IP: "{{ ansible_host }}"
108+
EC2_PUBLIC_IP: "{{ ansible_host }}"
109+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
42.7 KB
Binary file not shown.
42.7 KB
Binary file not shown.

server/gateway/src/main/resources/application.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@ spring:
4141
- id: genai_route
4242
uri: http://meetatmensa-genai:80
4343
predicates:
44-
- Path=/genai/**
44+
- Path=/api/v2/genai/**

server/genai/.gitkeep

Whitespace-only changes.

server/genai/Dockerfile

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,35 @@
1-
# ------------ Build Stage ------------
2-
FROM python:3.10-slim AS build
3-
WORKDIR /app
4-
5-
# Copy necessary files
6-
COPY pyproject.toml ./
7-
COPY src ./src
1+
# ---- Build stage (optional, for dependencies precompilation) ----
2+
FROM python:3.11-slim AS builder
83

9-
# install build tools
10-
RUN pip install build
4+
WORKDIR /app
5+
COPY requirements.txt .
116

12-
# build python wheel to be installed later
13-
RUN python3 -m build
7+
# System deps for common LangChain LLM backends (OpenAI, local models, etc.)
8+
RUN apt-get update && apt-get install -y --no-install-recommends \
9+
build-essential curl && \
10+
pip install --upgrade pip && \
11+
pip install --prefix=/install -r requirements.txt && \
12+
apt-get purge -y --auto-remove build-essential && \
13+
rm -rf /root/.cache /var/lib/apt/lists/*
1414

15+
# ---- Final stage ----
16+
FROM python:3.11-slim
1517

16-
# ------------ Runtime Stage ------------
17-
FROM python:3.10-slim
18+
# Create non-root user
19+
RUN useradd -m appuser
1820
WORKDIR /app
1921

20-
# copy wheel from build
21-
COPY --from=build /app/dist/*.whl .
22+
# Copy installed Python packages
23+
COPY --from=builder /install /usr/local
24+
COPY service/ ./service
25+
COPY requirements.txt .
26+
COPY test ./test
2227

23-
# Install python wheel
24-
RUN pip install *.whl
28+
# Set env vars (can be overridden in Helm values)
29+
ENV PYTHONUNBUFFERED=1 \
30+
PORT=80
2531

26-
# Expose default HTTP port
32+
USER appuser
2733
EXPOSE 80
2834

29-
# Run the conversation_starter.main:start_genai() via the project script
30-
CMD ["meetatmensa-start-genai"]
35+
CMD ["uvicorn", "service.main:app", "--host", "0.0.0.0", "--port", "80"]

0 commit comments

Comments
 (0)