Skip to content

Commit de30126

Browse files
authored
Merge pull request #22 from Azure-Samples/gk/steps-observaibility
Adds document upload and processing API
2 parents eb745a7 + 2d9dfbf commit de30126

File tree

17 files changed

+158
-7885
lines changed

17 files changed

+158
-7885
lines changed

azure.yaml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ services:
2525
docker:
2626
path: ./Dockerfile
2727
context: .
28+
buildArgs:
29+
- "VITE_API_BASE_URL=https://caapi-pt7qjgzmrnxgo.politepond-02f6cb2e.eastus2.azurecontainerapps.io/api"
30+
- "VITE_AAD_CLIENT_ID=c448ea01-dc6a-4aaa-910d-e6c307db9fc1"
31+
- "VITE_AAD_TENANT_ID=56643691-ef04-4208-a672-7ffca73f561c"
32+
- "VITE_AAD_USER_FLOW=emailsignflow"
33+
- "VITE_AAD_AUTHORITY=https://gkadaptiverag.ciamlogin.com/"
34+
- "VITE_AAD_REDIRECT_URI=https://caweb-pt7qjgzmrnxgo.politepond-02f6cb2e.eastus2.azurecontainerapps.io/redirect"
35+
- "VITE_API_SCOPE=api://c448ea01-dc6a-4aaa-910d-e6c307db9fc1/access_as_user"
2836

2937
infra:
3038
provider: bicep
@@ -56,8 +64,4 @@ hooks:
5664
from app.ingestion.indexer_job import create_search_index
5765
asyncio.run(create_search_index())
5866
"
59-
prepackage:
60-
shell: sh
61-
run: |
62-
echo "Building frontend..."
63-
cd frontend && npm install && npm run build
67+

frontend/.dockerignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
node_modules
2+
dist
3+
package-lock.json
4+
.env
5+
.env.local
6+
.env.development.local
7+
.env.test.local
8+
.env.production.local
9+
npm-debug.log*
10+
yarn-debug.log*
11+
yarn-error.log*
12+
.DS_Store
13+
*.log

frontend/Dockerfile

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,55 @@
1-
FROM node:18-alpine as build
1+
FROM node:18-alpine AS build
22

33
WORKDIR /app
44

55
# Copy package files
6-
COPY package*.json ./
6+
COPY package.json ./
77

88
# Install ALL dependencies (including dev dependencies needed for build)
9-
RUN npm ci
9+
RUN npm install
1010

1111
# Copy source code
1212
COPY . .
1313

14+
# Accept build args for environment variables
15+
ARG VITE_API_BASE_URL
16+
ARG VITE_AAD_CLIENT_ID
17+
ARG VITE_AAD_TENANT_ID
18+
ARG VITE_AAD_USER_FLOW
19+
ARG VITE_AAD_AUTHORITY
20+
ARG VITE_AAD_REDIRECT_URI
21+
ARG VITE_API_SCOPE
22+
23+
# Set environment variables for the build
24+
ENV VITE_API_BASE_URL=$VITE_API_BASE_URL
25+
ENV VITE_AAD_CLIENT_ID=$VITE_AAD_CLIENT_ID
26+
ENV VITE_AAD_TENANT_ID=$VITE_AAD_TENANT_ID
27+
ENV VITE_AAD_USER_FLOW=$VITE_AAD_USER_FLOW
28+
ENV VITE_AAD_AUTHORITY=$VITE_AAD_AUTHORITY
29+
ENV VITE_AAD_REDIRECT_URI=$VITE_AAD_REDIRECT_URI
30+
ENV VITE_API_SCOPE=$VITE_API_SCOPE
31+
1432
# Build the application
1533
RUN npm run build
1634

1735
# Production stage
1836
FROM nginx:alpine
1937

38+
# Remove the stock config so our template wins
39+
RUN rm /etc/nginx/conf.d/default.conf
40+
2041
# Copy built assets from build stage
2142
COPY --from=build /app/dist /usr/share/nginx/html
2243

23-
# Copy nginx configuration template
24-
COPY nginx.conf.template /etc/nginx/templates/default.conf.template
44+
# Rename the template so it does not clash with the deleted file
45+
COPY nginx.conf.template /etc/nginx/templates/api-proxy.conf.template
46+
47+
# Optional banner to show environment variables
48+
RUN printf '#!/bin/sh\necho "Environment variables:"\nenv | grep -E "(API_|VITE_)"\necho "Starting nginx..."\n' \
49+
> /docker-entrypoint.d/00-print-env.sh && chmod +x /docker-entrypoint.d/00-print-env.sh
2550

2651
# Expose port 80
2752
EXPOSE 80
2853

29-
# Debug environment variables and start nginx
30-
CMD ["sh", "-c", "echo 'Environment variables:' && env | grep -E '(API_|VITE_)' && echo 'Starting nginx...' && nginx -g 'daemon off;'"]
54+
# Revert to the normal CMD so the entrypoint renders templates
55+
CMD ["nginx", "-g", "daemon off;"]

frontend/nginx.conf.template

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,33 @@
11
server {
2-
listen 80;
3-
server_name localhost;
2+
listen 80;
3+
server_name localhost;
44

55
location / {
6-
root /usr/share/nginx/html;
7-
index index.html index.htm;
6+
root /usr/share/nginx/html;
7+
index index.html index.htm;
88
try_files $uri $uri/ /index.html;
99
}
1010

11-
# API proxy configuration
11+
# ---------- proxy every /api/* call to the back‑end Container App ----------
1212
location /api/ {
13-
proxy_pass http://${API_SERVICE_NAME:-api}:8000/;
14-
proxy_set_header Host $host;
15-
proxy_set_header X-Real-IP $remote_addr;
16-
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
13+
proxy_pass http://$API_SERVICE_NAME:8000;
14+
proxy_set_header Host $host;
15+
proxy_set_header X-Real-IP $remote_addr;
16+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
1717
proxy_set_header X-Forwarded-Proto $scheme;
18+
19+
# SSE-specific configuration
20+
proxy_buffering off;
21+
proxy_cache off;
22+
proxy_set_header Connection '';
23+
proxy_http_version 1.1;
24+
chunked_transfer_encoding off;
25+
26+
# Increase timeout for streaming responses
27+
proxy_read_timeout 300s;
28+
proxy_send_timeout 300s;
1829
}
1930

20-
error_page 500 502 503 504 /50x.html;
21-
location = /50x.html {
22-
root /usr/share/nginx/html;
23-
}
31+
error_page 500 502 503 504 /50x.html;
32+
location = /50x.html { root /usr/share/nginx/html; }
2433
}

0 commit comments

Comments
 (0)