Skip to content

Commit

Permalink
chore: a few improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
manekinekko committed Nov 28, 2024
1 parent 3db86a6 commit b5412fd
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 15 deletions.
12 changes: 8 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
# syntax=docker/dockerfile:1

# Use full image because we need node-gyp to build native dependencies
FROM node:20 AS build
FROM node:20-alpine AS build

RUN npm install -g [email protected] && npm cache clean --force
RUN npm install -g [email protected] && \
npm cache clean --force

WORKDIR /app

COPY package.json package-lock.* ./
ADD app/lib ./app/lib
RUN pnpm install
RUN pnpm install --ignore-scripts
RUN pnpm add sharp

# Build the application
COPY . .
Expand All @@ -18,4 +20,6 @@ RUN pnpm build
# ====================================
FROM build AS release

CMD ["npm", "run", "start"]
# avoid using npm scripts that create sub-shells
# calling next binary directly
CMD ["/app/node_modules/.bin/next", "start"]
24 changes: 17 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,11 @@ A related option is VS Code Dev Containers, which will open the project in your

1. Install the required tools:

- [Azure Developer CLI](https://aka.ms/azure-dev/install)
- [Node.js 20+](https://nodejs.org/download/)
- [Git](https://git-scm.com/downloads)
- [Powershell 7+ (pwsh)](https://github.com/powershell/powershell) - For Windows users only.
- **Important**: Ensure you can run `pwsh.exe` from a PowerShell terminal. If this fails, you likely need to upgrade PowerShell.
- [Azure Developer CLI](https://aka.ms/azure-dev/install)
- [Node.js 20+](https://nodejs.org/download/)
- [Git](https://git-scm.com/downloads)
- [Powershell 7+ (pwsh)](https://github.com/powershell/powershell) - For Windows users only.
- **Important**: Ensure you can run `pwsh.exe` from a PowerShell terminal. If this fails, you likely need to upgrade PowerShell.

2. Create a new folder and switch to it in the terminal.
3. Run this command to download the project code:
Expand Down Expand Up @@ -151,10 +151,20 @@ azd env new
Enter a name that will be used for the resource group.
This will create a new folder in the `.azure` folder, and set it as the active environment for any calls to `azd` going forward.

Package, provision and deploy this project to Azure:
Provision the infrastructure needed to run the application.

```shell
azd up
azd provision
```

> [!IMPORTANT]
> This application specifically requires some environment variables to be available during the packaging phase. This is why we need to provision the infra first before packaging and deploying the app. In most cases, simply running 'azd up' will package, provision and deploy your apps.
Package and deploy the app to Azure:

```shell
azd package
azd deploy
```

> [!NOTE]
Expand Down
7 changes: 5 additions & 2 deletions infra/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ param openAiEmbedSkuName string = 'Standard'
param chatDeploymentCapacity int = 1
param openAiEmbeddingDeploymentCapacity int = 30

param llamaIndexFileserverUrlPrefix string = 'http://localhost/api/files'
// leave this empty will disable file URLs generated (in the UI)
param llamaIndexFileserverUrlPrefix string = ''
param llamaIndexCacheDir string = '.cache'
param llamaIndexSystemPrompt string = '''
you are an assistant. Always use data_query_engine to answer the user\'s questions, and query for documents from your data source
Expand Down Expand Up @@ -283,7 +284,8 @@ module openAi 'br/public:avm/res/cognitive-services/account:0.8.0' = if (!reuseE
: '${abbrs.cognitiveServicesAccounts}${resourceToken}'
sku: 'S0'
deployments: openAiDeployments
disableLocalAuth: true
disableLocalAuth: false
restrictOutboundNetworkAccess: false
publicNetworkAccess: 'Enabled'
networkAcls: {
defaultAction: 'Allow'
Expand Down Expand Up @@ -423,6 +425,7 @@ module openAiRoleSearchService 'core/security/role.bicep' = if (!reuseExistingSe
// If detected, it will be used to authenticate the user
// using a user-assigned managed identity on Azure.
// However, this is not supported in local development.
output AZURE_CLIENT_ID string = acaIdentity.outputs.clientId

output AZURE_LOCATION string = location
output AZURE_TENANT_ID string = tenantId
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
"scripts": {
"format": "prettier --ignore-unknown --cache --check .",
"format:write": "prettier --ignore-unknown --write .",
"dev": "next dev",
"dev": "AZURE_CLIENT_ID= next dev",
"build": "next build",
"start": "next start",
"lint": "next lint",
"generate": "tsx app/api/chat/engine/generate.ts"
"generate": "AZURE_CLIENT_ID= tsx app/api/chat/engine/generate.ts"
},
"dependencies": {
"@apidevtools/swagger-parser": "^10.1.0",
Expand Down

0 comments on commit b5412fd

Please sign in to comment.