Skip to content

Commit b0c5ff4

Browse files
Remove docker-compose.yml and update docs for Azure Container Apps deployment
Co-authored-by: BenjaminMichaelis <[email protected]>
1 parent 59156f0 commit b0c5ff4

File tree

3 files changed

+83
-123
lines changed

3 files changed

+83
-123
lines changed

EssentialCSharp.Web/appsettings.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626
"ApiKey": ""
2727
},
2828
"TypesenseOptions": {
29-
"Host": "localhost",
30-
"Port": 8108,
31-
"Protocol": "http",
32-
"ApiKey": "xyz",
29+
"Host": "your-typesense-container-app.azurecontainerapps.io",
30+
"Port": 443,
31+
"Protocol": "https",
32+
"ApiKey": "your-secure-api-key",
3333
"TimeoutSeconds": 30
3434
},
3535
"SiteSettings": {

TYPESENSE_INTEGRATION.md

Lines changed: 79 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Typesense Search Integration
1+
# Typesense Search Integration for Azure Container Apps
22

3-
This document describes the integration of Typesense search engine as a replacement for Algolia DocSearch in the EssentialCSharp.Web application.
3+
This document describes the integration of Typesense search engine as a replacement for Algolia DocSearch in the EssentialCSharp.Web application, designed for deployment in Azure Container Apps.
44

55
## Overview
66

@@ -11,9 +11,9 @@ Typesense is an open-source, fast search engine that provides:
1111
- **Self-hosted solution** - no external dependencies
1212
- **Fast search responses** with sub-50ms latency
1313

14-
## Architecture
14+
## Architecture for Azure Container Apps
1515

16-
The integration consists of several components:
16+
The integration consists of several components designed to work in Azure Container Apps:
1717

1818
### Backend Services
1919

@@ -49,13 +49,6 @@ The integration consists of several components:
4949
- Dark mode support
5050
- Loading states and error handling
5151

52-
### Docker Configuration
53-
54-
The `docker-compose.yml` includes:
55-
- **Typesense service** running on port 8108
56-
- **PostgreSQL** for existing vector database functionality
57-
- **Main web application** with environment variables for Typesense connection
58-
5952
## Configuration
6053

6154
### Application Settings
@@ -65,18 +58,30 @@ Add to `appsettings.json`:
6558
```json
6659
{
6760
"TypesenseOptions": {
68-
"Host": "localhost",
69-
"Port": 8108,
70-
"Protocol": "http",
61+
"Host": "your-typesense-container-app.azurecontainerapps.io",
62+
"Port": 443,
63+
"Protocol": "https",
7164
"ApiKey": "your-api-key-here",
7265
"TimeoutSeconds": 30
7366
}
7467
}
7568
```
7669

77-
### Environment Variables (Docker)
70+
### Environment Variables (Azure Container Apps)
7871

79-
- `TYPESENSE_API_KEY`: API key for Typesense authentication
72+
The Typesense configuration should be added to the deployment pipeline:
73+
74+
```bash
75+
# Add to the az containerapp secret set command:
76+
typesense-apikey=keyvaultref:$KEYVAULTURI/secrets/typesense-apikey,identityref:$MANAGEDIDENTITYID \
77+
typesense-host=keyvaultref:$KEYVAULTURI/secrets/typesense-host,identityref:$MANAGEDIDENTITYID
78+
79+
# Add to the az containerapp update --replace-env-vars command:
80+
TypesenseOptions__Host=secretref:typesense-host \
81+
TypesenseOptions__ApiKey=secretref:typesense-apikey \
82+
TypesenseOptions__Port=443 \
83+
TypesenseOptions__Protocol=https
84+
```
8085

8186
### Rate Limiting
8287

@@ -123,50 +128,62 @@ GET /api/search/health
123128
- **tags**: string array (faceted)
124129
- **created_at**: int64 (sorting field)
125130

126-
## Deployment with Docker Compose
131+
## Deployment in Azure Container Apps
132+
133+
### Step 1: Deploy Typesense Container App
134+
135+
Create a separate Container App for Typesense:
136+
137+
```bash
138+
# Create Typesense Container App
139+
az containerapp create \
140+
--name typesense-search \
141+
--resource-group $RESOURCEGROUP \
142+
--environment $CONTAINER_APP_ENVIRONMENT \
143+
--image typesense/typesense:0.25.2 \
144+
--target-port 8108 \
145+
--ingress external \
146+
--env-vars TYPESENSE_API_KEY=secretref:typesense-apikey \
147+
--secrets typesense-apikey="your-secure-api-key" \
148+
--command '--data-dir /data --api-key=$TYPESENSE_API_KEY --enable-cors' \
149+
--cpu 1.0 \
150+
--memory 2Gi
151+
```
127152

128-
1. **Start the services**:
129-
```bash
130-
docker-compose up -d
131-
```
153+
### Step 2: Update Main Application Deployment
132154

133-
2. **Set environment variables**:
134-
```bash
135-
export TYPESENSE_API_KEY="your-secure-api-key"
136-
```
155+
Update the existing deployment pipeline (`Build-Test-And-Deploy.yml`) to include Typesense configuration:
156+
157+
1. **Add Typesense secrets to Key Vault**:
158+
- `typesense-apikey`: Your secure API key
159+
- `typesense-host`: The Typesense Container App URL
137160

138-
3. **Verify Typesense health**:
161+
2. **Update the pipeline secrets configuration**:
139162
```bash
140-
curl http://localhost:8108/health
163+
# Add to the existing secret set command around line 154:
164+
typesense-apikey=keyvaultref:$KEYVAULTURI/secrets/typesense-apikey,identityref:$MANAGEDIDENTITYID \
165+
typesense-host=keyvaultref:$KEYVAULTURI/secrets/typesense-host,identityref:$MANAGEDIDENTITYID
141166
```
142167

143-
4. **Check search functionality**:
168+
3. **Update the environment variables around line 160**:
144169
```bash
145-
curl "http://localhost:8080/api/search?q=variables"
170+
# Add to the existing environment variables:
171+
TypesenseOptions__Host=secretref:typesense-host \
172+
TypesenseOptions__ApiKey=secretref:typesense-apikey \
173+
TypesenseOptions__Port=443 \
174+
TypesenseOptions__Protocol=https
146175
```
147176

148-
## Container App Deployment (Azure)
177+
### Step 3: Verify Deployment
149178

150-
For Azure Container Apps deployment:
151-
152-
1. **Create Typesense container**:
179+
1. **Check Typesense health**:
153180
```bash
154-
az containerapp create \
155-
--name typesense-search \
156-
--resource-group myResourceGroup \
157-
--environment myEnvironment \
158-
--image typesense/typesense:0.25.2 \
159-
--target-port 8108 \
160-
--env-vars API_KEY=secretref:typesense-api-key \
161-
--secrets typesense-api-key=your-secure-key
181+
curl https://your-typesense-container-app.azurecontainerapps.io/health
162182
```
163183

164-
2. **Update main app configuration**:
184+
2. **Test search functionality**:
165185
```bash
166-
az containerapp update \
167-
--name essentialcsharp-web \
168-
--set-env-vars TypesenseOptions__Host=typesense-search \
169-
TypesenseOptions__ApiKey=secretref:typesense-api-key
186+
curl "https://your-main-app.azurecontainerapps.io/api/search?q=variables"
170187
```
171188

172189
## Features
@@ -195,13 +212,13 @@ For Azure Container Apps deployment:
195212

196213
- **Search latency**: Typically under 50ms for most queries
197214
- **Index size**: Automatically managed by Typesense
198-
- **Memory usage**: Typesense uses in-memory indexing for fast searches
215+
- **Memory usage**: Recommend 2GB+ for Typesense Container App
199216
- **Rate limiting**: Prevents search abuse and ensures fair usage
200217

201218
## Monitoring and Health Checks
202219

203220
- Built-in health check endpoint: `/api/search/health`
204-
- Typesense health endpoint: `http://typesense:8108/health`
221+
- Typesense health endpoint: `https://your-typesense-app.azurecontainerapps.io/health`
205222
- Structured logging for search operations and errors
206223
- Application Insights integration for telemetry
207224

@@ -219,19 +236,19 @@ The integration replaces Algolia DocSearch:
219236
### Common Issues
220237

221238
1. **Typesense connection failed**:
222-
- Check if Typesense container is running
223-
- Verify network connectivity between containers
224-
- Ensure API key is correct
239+
- Check if Typesense Container App is running
240+
- Verify network connectivity between Container Apps
241+
- Ensure API key is correct in Key Vault
225242

226243
2. **Search returns no results**:
227244
- Check if content indexing completed successfully
228-
- Verify collection exists: `curl http://typesense:8108/collections`
229-
- Check application logs for indexing errors
245+
- Verify collection exists: `curl https://your-typesense-app.azurecontainerapps.io/collections`
246+
- Check Application Insights for indexing errors
230247

231248
3. **Slow search performance**:
232-
- Monitor Typesense memory usage
233-
- Consider increasing container resources
234-
- Check network latency between services
249+
- Monitor Typesense Container App resource usage
250+
- Consider increasing CPU/memory allocation
251+
- Check network latency between Container Apps
235252

236253
### Logging
237254

@@ -240,6 +257,12 @@ Search operations are logged with structured data:
240257
- Indexing operations and document counts
241258
- Error conditions and health check results
242259

260+
## Cost Considerations
261+
262+
- **Typesense Container App**: Runs continuously, estimated cost based on CPU/memory allocation
263+
- **Storage**: Persistent volumes for Typesense data (if needed)
264+
- **Network**: Minimal egress costs for inter-container communication within the same region
265+
243266
## Future Enhancements
244267

245268
Potential improvements:

docker-compose.yml

Lines changed: 0 additions & 63 deletions
This file was deleted.

0 commit comments

Comments
 (0)