Skip to content

Commit cc02356

Browse files
committed
Configure docker to accept api key from .env
1 parent 88d2dfc commit cc02356

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ services:
88
- QUESTION_SVC_PORT=$QUESTION_SVC_PORT
99
- MATCHING_SVC_PORT=$MATCHING_SVC_PORT
1010
- COLLAB_SVC_PORT=$COLLAB_SVC_PORT
11+
- OPENAI_API_KEY=$OPENAI_API_KEY
1112
ports:
1213
- $FRONTEND_PORT:$FRONTEND_PORT
1314
depends_on:

frontend/Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ ARG BASE_URI \
44
USER_SVC_PORT \
55
QUESTION_SVC_PORT \
66
MATCHING_SVC_PORT \
7-
COLLAB_SVC_PORT
7+
COLLAB_SVC_PORT \
8+
OPENAI_API_KEY
89
WORKDIR /app
910
COPY package.json .
1011
COPY yarn.lock .
@@ -13,7 +14,8 @@ ENV NEXT_PUBLIC_BASE_URI=$BASE_URI \
1314
NEXT_PUBLIC_USER_SVC_PORT=$USER_SVC_PORT \
1415
NEXT_PUBLIC_QUESTION_SVC_PORT=$QUESTION_SVC_PORT \
1516
NEXT_PUBLIC_MATCHING_SVC_PORT=$MATCHING_SVC_PORT \
16-
NEXT_PUBLIC_COLLAB_SVC_PORT=$COLLAB_SVC_PORT
17+
NEXT_PUBLIC_COLLAB_SVC_PORT=$COLLAB_SVC_PORT \
18+
NEXT_PUBLIC_OPENAI_API_KEY=$OPENAI_API_KEY
1719

1820
# Production build stage
1921
FROM base AS build

frontend/lib/api/openai/send-ai-message.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ export const sendAiMessage = async (message: string) => {
33
method: 'POST',
44
headers: {
55
'Content-Type': 'application/json',
6-
'Authorization': `Bearer ${process.env.OPENAI_API_KEY}`,
6+
'Authorization': `Bearer ${process.env.NEXT_PUBLIC_OPENAI_API_KEY}`,
77
},
88
body: JSON.stringify({
99
model: 'gpt-3.5-turbo',
1010
messages: [
1111
{
1212
role: 'user',
13-
content: "just work and say its okdoc",
13+
content: message,
1414
},
1515
],
1616
}),

0 commit comments

Comments
 (0)