Skip to content

Commit 2e9e84a

Browse files
committed
Merge branch 'padws:main' into mataai:main
2 parents 7127555 + 5dbf134 commit 2e9e84a

File tree

124 files changed

+8233
-4423
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

124 files changed

+8233
-4423
lines changed

.env.template

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ CODER_PORT=7080
55
APP_PORT=8000
66

77
# API Configuration
8-
API_WORKERS=4
8+
API_WORKERS=1
99
FRONTEND_URL=your_frontend_url
10+
REDIRECT_URI=http://localhost:8000/api/auth/callback
1011

1112
# Database Configuration
1213
POSTGRES_USER=admin
@@ -38,3 +39,4 @@ CODER_ADDITIONAL_CSP_POLICY=frame-ancestors *
3839
CODER_API_KEY=your_coder_api_key
3940
CODER_TEMPLATE_ID=your_template_id
4041
CODER_DEFAULT_ORGANIZATION=your_organization_id
42+
CODER_WORKSPACE_NAME=your_workspace_name

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ src/excalidraw
66
.env
77
src/frontend/.env.local
88
.vscode/settings.json
9+
dev/

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,14 @@ This simplified example lets you host pad on `localhost` but is not safe for rea
8686
* Fill in the details
8787
* **Important:** Tick `Email verified`
8888
* Go to the `Credentials` tab for the new user and set a password
89-
89+
* **Create an Audience:**
90+
* Navigate to `Clients` -> `[Your Client ID]` -> `Client Scopes`
91+
* Click on the dedicated scope of your Client (`[clientid]-dedicated`)
92+
* Click on `Configure a new mapper`
93+
* Then click on `Audience`
94+
* Ensure `Included Client Audience` matches your `Client ID`
95+
* Ensure `Add to access token` is On
96+
9097
### 5️⃣ Coder 🧑‍💻
9198

9299
* **Find Docker Group ID:** You'll need this to grant necessary permissions
@@ -127,6 +134,8 @@ This simplified example lets you host pad on `localhost` but is not safe for rea
127134
```dotenv
128135
CODER_DEFAULT_ORGANIZATION=your_organization_id # Example: 70f6af06-ef3a-4b4c-a663-c03c9ee423bb
129136
```
137+
* **If you use a custom name for your workspace:**
138+
* You need to provide the name as `CODER_WORKSPACE_NAME` in your `.env`. Otherwise, it will assume your workspace name is the default we chose: `ubuntu`.
130139
131140
### 6️⃣ Pad App 📝
132141
> The fastAPI app that both serves the build frontend and the backend API to interface with Coder

docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ services:
1212
- postgres_data:/var/lib/postgresql/data
1313
restart: unless-stopped
1414
network_mode: host
15-
15+
1616
redis:
1717
image: redis:alpine
1818
container_name: redis
@@ -78,7 +78,7 @@ services:
7878
- OIDC_CLIENT_SECRET=${OIDC_CLIENT_SECRET}
7979
- OIDC_SERVER_URL=http://localhost:${KEYCLOAK_PORT}
8080
- OIDC_REALM=${OIDC_REALM}
81-
- REDIRECT_URI=http://localhost:${APP_PORT}/auth/callback
81+
- REDIRECT_URI=${REDIRECT_URI}
8282
- POSTGRES_USER=${POSTGRES_USER}
8383
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
8484
- POSTGRES_DB=${POSTGRES_DB}

docs/frontend-backend-communication.md

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

scripts/startup.sh

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,5 @@
11
#!/bin/bash
22
set -e
33

4-
# Create runtime config with environment variables
5-
mkdir -p /app/frontend/dist/assets
6-
cat > /app/frontend/dist/assets/runtime-config.js <<EOL
7-
window.RUNTIME_CONFIG = {
8-
CODER_URL: "${CODER_URL}",
9-
VITE_PUBLIC_POSTHOG_KEY: "${VITE_PUBLIC_POSTHOG_KEY}",
10-
VITE_PUBLIC_POSTHOG_HOST: "${VITE_PUBLIC_POSTHOG_HOST}"
11-
};
12-
EOL
13-
144
# Start the application
155
exec uvicorn main:app --host 0.0.0.0 --port 8000 --workers $API_WORKERS

src/backend/cache/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from .redis_client import RedisClient
2+
3+
__all__ = ["RedisClient"]

src/backend/cache/redis_client.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import os
2+
from redis import asyncio as aioredis
3+
from dotenv import load_dotenv
4+
5+
# Load environment variables
6+
load_dotenv()
7+
8+
# Redis Configuration
9+
REDIS_HOST = os.getenv('REDIS_HOST', 'localhost')
10+
REDIS_PASSWORD = os.getenv('REDIS_PASSWORD', None)
11+
REDIS_PORT = int(os.getenv('REDIS_PORT', 6379))
12+
REDIS_URL = f"redis://{REDIS_HOST}:{REDIS_PORT}"
13+
14+
class RedisClient:
15+
"""Service for managing Redis connections with proper lifecycle management."""
16+
17+
_instance = None
18+
19+
@classmethod
20+
async def get_instance(cls) -> aioredis.Redis:
21+
"""Get or create a Redis client instance."""
22+
if cls._instance is None:
23+
cls._instance = cls()
24+
await cls._instance.initialize()
25+
return cls._instance.client
26+
27+
def __init__(self):
28+
self.client = None
29+
30+
async def initialize(self) -> None:
31+
"""Initialize the Redis client."""
32+
self.client = aioredis.from_url(
33+
REDIS_URL,
34+
password=REDIS_PASSWORD,
35+
decode_responses=True,
36+
health_check_interval=30
37+
)
38+
39+
async def close(self) -> None:
40+
"""Close the Redis client connection."""
41+
if self.client:
42+
await self.client.close()
43+
self.client = None
44+
print("Redis client closed.")

0 commit comments

Comments
 (0)