Skip to content

Commit

Permalink
Merge branch 'main' into fix-cosmosdb-partitioning
Browse files Browse the repository at this point in the history
  • Loading branch information
crickman committed Aug 28, 2023
2 parents 8034b9e + 753535b commit 28ef657
Show file tree
Hide file tree
Showing 17 changed files with 407 additions and 107 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
**/node_modules
**/bin
**/obj
79 changes: 79 additions & 0 deletions .github/workflows/copilot-build-images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: copilot-build-images

on:
workflow_call:
inputs:
REACT_APP_BACKEND_URI:
required: true
type: string
REACT_APP_AAD_AUTHORITY:
required: true
type: string
REACT_APP_AAD_CLIENT_ID:
required: true
type: string
REACT_APP_AAD_API_SCOPE:
required: false
type: string
env:
REGISTRY: ghcr.io

jobs:
build-and-push-image:
name: Build and push images
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- file: ./docker/webapi/Dockerfile
image: ${{ github.repository }}-webapi
build-args: |
- file: ./docker/webapp/Dockerfile
image: ${{ github.repository }}-webapp
build-args: |
- file: ./docker/webapp/Dockerfile.nginx
image: ${{ github.repository }}-webapp-nginx
build-args: |
REACT_APP_BACKEND_URI=${{ inputs.REACT_APP_BACKEND_URI }}
REACT_APP_AAD_AUTHORITY=${{ inputs.REACT_APP_AAD_AUTHORITY }}
REACT_APP_AAD_CLIENT_ID=${{ inputs.REACT_APP_AAD_CLIENT_ID }}
REACT_APP_AAD_API_SCOPE=${{ inputs.REACT_APP_AAD_API_SCOPE }}
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Login container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels)
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ matrix.image }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}
type=semver,pattern={{major}}.{{minor}}
- name: Build and push image
uses: docker/build-push-action@v4
with:
context: .
file: ${{ matrix.file }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: ${{ matrix.build-args }}
4 changes: 2 additions & 2 deletions .github/workflows/dotnet-format.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: dotnet-format
name: dotnet-format

on:
pull_request:
Expand Down Expand Up @@ -61,7 +61,7 @@ jobs:
echo "csproj_files=${csproj_files[*]}" >> $GITHUB_OUTPUT
- name: Setup .NET
uses: actions/setup-dotnet@v1
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x

Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -489,4 +489,4 @@ webapi/CopilotChatWebApi.sln
/deploy/

# Tesseract OCR language data files
*.traineddata
*.traineddata
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ By default, Chat Copilot runs locally without authentication, using a guest user

3. Click _Add a permission_

4. Select the tab _My APIs_
4. Select the tab _APIs my organization uses_

5. Choose the app registration representing the web api backend

Expand Down
33 changes: 33 additions & 0 deletions docker/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
version: '3'
services:
chat-copilot-webapp:
image: chat-copilot-webapp-nginx
build:
context: ..
dockerfile: docker/webapp/Dockerfile
ports:
- 3000:3000
env_file:
- ../webapp/.env
depends_on:
chat-copilot-webapi:
condition: service_started
chat-copilot-webapi:
image: chat-copilot-webapi
build:
context: ..
dockerfile: docker/webapi/Dockerfile
ports:
- 8080:8080
env_file:
- ../webapi/.env
environment:
- MemoryStore__Qdrant__Host=http://qdrant
depends_on:
qdrant:
condition: service_started
qdrant:
image: qdrant/qdrant
ports:
- 6333:6333

29 changes: 29 additions & 0 deletions docker/webapi/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# docker build -f docker/webapi/Dockerfile -t chat-copilot-webapi .

# Learn about building .NET container images:
# https://github.com/dotnet/dotnet-docker/blob/main/samples/README.md
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /source

# generate dev-certs for https
RUN dotnet dev-certs https

# copy csproj and restore as distinct layers
COPY webapi/*.csproj .
RUN dotnet restore --use-current-runtime

# copy everything else and build app
COPY webapi/. .
RUN apt update && apt install -y wget
RUN wget -P data https://raw.githubusercontent.com/tesseract-ocr/tessdata/main/eng.traineddata
RUN dotnet publish --use-current-runtime --self-contained false --no-restore -o /app


# final stage/image
FROM mcr.microsoft.com/dotnet/aspnet:6.0
ENV Kestrel__Endpoints__Http__Url=http://0.0.0.0:8080
WORKDIR /app
COPY --from=build /app .
COPY --from=build /root/.dotnet/corefx/cryptography/x509stores/my/* /root/.dotnet/corefx/cryptography/x509stores/my/

ENTRYPOINT ["./CopilotChatWebApi"]
19 changes: 19 additions & 0 deletions docker/webapp/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# docker build -f docker/webapp/Dockerfile -t chat-copilot-webapp .

# builder
FROM node:lts-alpine as builder
WORKDIR /app
COPY webapp/ .
RUN yarn install \
--prefer-offline \
--frozen-lockfile \
--non-interactive \
--production=false

# final stage/image
FROM node:lts-alpine
WORKDIR /app
COPY --from=builder /app .
ENV HOST 0.0.0.0
EXPOSE 3000
ENTRYPOINT [ "yarn", "start" ]
34 changes: 34 additions & 0 deletions docker/webapp/Dockerfile.nginx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# source webapp/.env
# docker build --build-arg REACT_APP_BACKEND_URI=$REACT_APP_BACKEND_URI --build-arg REACT_APP_AAD_AUTHORITY=$REACT_APP_AAD_AUTHORITY --build-arg REACT_APP_AAD_CLIENT_ID=$REACT_APP_AAD_CLIENT_ID --build-arg REACT_APP_AAD_API_SCOPE=$REACT_APP_AAD_API_SCOPE -f docker/webapp/Dockerfile.nginx -t chat-copilot-webapp-nginx .

# builder
FROM node:lts-alpine as builder

ARG REACT_APP_BACKEND_URI
ENV REACT_APP_BACKEND_URI $REACT_APP_BACKEND_URI

ARG REACT_APP_AAD_AUTHORITY
ENV REACT_APP_AAD_AUTHORITY $REACT_APP_AAD_AUTHORITY

ARG REACT_APP_AAD_CLIENT_ID
ENV REACT_APP_AAD_CLIENT_ID $REACT_APP_AAD_CLIENT_ID

ARG REACT_APP_AAD_API_SCOPE
ENV REACT_APP_AAD_API_SCOPE $REACT_APP_AAD_API_SCOPE

WORKDIR /app
COPY webapp/ .
RUN yarn install \
--prefer-offline \
--frozen-lockfile \
--non-interactive \
--production=true

RUN yarn build

# final stage/image
FROM nginx:stable-alpine
EXPOSE 3000
RUN sed -i 's/80/3000/g' /etc/nginx/conf.d/default.conf
COPY --from=builder /app/build /usr/share/nginx/html
CMD ["nginx", "-g", "daemon off;"]
4 changes: 2 additions & 2 deletions scripts/deploy/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"_generator": {
"name": "bicep",
"version": "0.20.4.51522",
"templateHash": "1330294935556235998"
"templateHash": "6091974935920125454"
}
},
"parameters": {
Expand Down Expand Up @@ -102,7 +102,7 @@
},
"azureAdInstance": {
"type": "string",
"defaultValue": "https://login.microsoftonline.com",
"defaultValue": "[environment().authentication.loginEndpoint]",
"metadata": {
"description": "Azure AD cloud instance for authenticating users"
}
Expand Down
25 changes: 25 additions & 0 deletions tools/importdocument/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,33 @@ public sealed class Config
/// <summary>
/// Client ID for the app as registered in Azure AD.
/// </summary>
public string AuthenticationType { get; set; } = "None";

/// <summary>
/// Client ID for the import document tool as registered in Azure AD.
/// </summary>
public string ClientId { get; set; } = string.Empty;

/// <summary>
/// Client ID for the backend web api as registered in Azure AD.
/// </summary>
public string BackendClientId { get; set; } = string.Empty;

/// <summary>
/// Tenant ID against which to authenticate users in Azure AD.
/// </summary>
public string TenantId { get; set; } = string.Empty;

/// <summary>
/// Azure AD cloud instance for authenticating users.
/// </summary>
public string Instance { get; set; } = string.Empty;

/// <summary>
/// Scopes that the client app requires to access the API.
/// </summary>
public string Scopes { get; set; } = string.Empty;

/// <summary>
/// Redirect URI for the app as registered in Azure AD.
/// </summary>
Expand Down
Loading

0 comments on commit 28ef657

Please sign in to comment.