Skip to content

Commit b5412fd

Browse files
committed
chore: a few improvements
1 parent 3db86a6 commit b5412fd

File tree

4 files changed

+32
-15
lines changed

4 files changed

+32
-15
lines changed

Dockerfile

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
# syntax=docker/dockerfile:1
22

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

6-
RUN npm install -g [email protected] && npm cache clean --force
6+
RUN npm install -g [email protected] && \
7+
npm cache clean --force
78

89
WORKDIR /app
910

1011
COPY package.json package-lock.* ./
1112
ADD app/lib ./app/lib
12-
RUN pnpm install
13+
RUN pnpm install --ignore-scripts
14+
RUN pnpm add sharp
1315

1416
# Build the application
1517
COPY . .
@@ -18,4 +20,6 @@ RUN pnpm build
1820
# ====================================
1921
FROM build AS release
2022

21-
CMD ["npm", "run", "start"]
23+
# avoid using npm scripts that create sub-shells
24+
# calling next binary directly
25+
CMD ["/app/node_modules/.bin/next", "start"]

README.md

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,11 @@ A related option is VS Code Dev Containers, which will open the project in your
110110

111111
1. Install the required tools:
112112

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

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

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

156156
```shell
157-
azd up
157+
azd provision
158+
```
159+
160+
> [!IMPORTANT]
161+
> 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.
162+
163+
Package and deploy the app to Azure:
164+
165+
```shell
166+
azd package
167+
azd deploy
158168
```
159169

160170
> [!NOTE]

infra/main.bicep

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ param openAiEmbedSkuName string = 'Standard'
8585
param chatDeploymentCapacity int = 1
8686
param openAiEmbeddingDeploymentCapacity int = 30
8787

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

427430
output AZURE_LOCATION string = location
428431
output AZURE_TENANT_ID string = tenantId

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
"scripts": {
55
"format": "prettier --ignore-unknown --cache --check .",
66
"format:write": "prettier --ignore-unknown --write .",
7-
"dev": "next dev",
7+
"dev": "AZURE_CLIENT_ID= next dev",
88
"build": "next build",
99
"start": "next start",
1010
"lint": "next lint",
11-
"generate": "tsx app/api/chat/engine/generate.ts"
11+
"generate": "AZURE_CLIENT_ID= tsx app/api/chat/engine/generate.ts"
1212
},
1313
"dependencies": {
1414
"@apidevtools/swagger-parser": "^10.1.0",

0 commit comments

Comments
 (0)