Skip to content

Commit 0b0e231

Browse files
authored
Merge pull request #53 from indrazm/feat/improve-docs-1
update docker, api and documentation
2 parents 4e454e7 + 1d79fde commit 0b0e231

File tree

5 files changed

+73
-13
lines changed

5 files changed

+73
-13
lines changed

apps/api/src/api/account/api.py

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import jwt
22
from fastapi import APIRouter, Depends, HTTPException, status
33
from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer
4+
from sqlalchemy.exc import IntegrityError
45
from sqlalchemy.orm import joinedload
56
from sqlmodel import Session
67

@@ -82,15 +83,37 @@ def get_account(
8283

8384
# Create user settings if they don't exist (for existing users)
8485
if not user_with_data.user_settings:
85-
user_settings = UserSettings(user_id=user_with_data.id, is_onboarded=False)
86-
db.add(user_settings)
87-
db.commit()
86+
try:
87+
user_settings = UserSettings(user_id=user_with_data.id, is_onboarded=False)
88+
db.add(user_settings)
89+
db.commit()
90+
except IntegrityError:
91+
# Handle race condition - another request already created the settings
92+
db.rollback()
93+
# Re-load the user to get the newly created settings
94+
user_with_data = (
95+
db.query(User)
96+
.options(joinedload(User.user_settings), joinedload(User.user_social))
97+
.filter(User.id == current_user.id)
98+
.first()
99+
)
88100

89101
# Create user social if they don't exist (for existing users)
90102
if not user_with_data.user_social:
91-
user_social = UserSocial(user_id=user_with_data.id)
92-
db.add(user_social)
93-
db.commit()
103+
try:
104+
user_social = UserSocial(user_id=user_with_data.id)
105+
db.add(user_social)
106+
db.commit()
107+
except IntegrityError:
108+
# Handle race condition - another request already created the social data
109+
db.rollback()
110+
# Re-load the user to get the newly created social data
111+
user_with_data = (
112+
db.query(User)
113+
.options(joinedload(User.user_settings), joinedload(User.user_social))
114+
.filter(User.id == current_user.id)
115+
.first()
116+
)
94117

95118
# Refresh to get the newly created relationships
96119
db.refresh(user_with_data)

docker-compose.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ services:
99
# ports:
1010
# - "5432:5432" # Commented out for production - no external access
1111
volumes:
12-
- postgres_data:/var/lib/postgresql/data
12+
- opencircle_pg_data:/var/lib/postgresql/data
1313
healthcheck:
1414
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-postgres}"]
1515
interval: 10s
@@ -25,7 +25,7 @@ services:
2525
# ports:
2626
# - "6379:6379" # Commented out for production - no external access
2727
volumes:
28-
- redis_data:/data
28+
- opencircle_redis_data:/data
2929
healthcheck:
3030
test: ["CMD", "redis-cli", "ping"]
3131
interval: 10s
@@ -146,9 +146,9 @@ services:
146146
- opencircle-network
147147

148148
volumes:
149-
postgres_data:
149+
opencircle_pg_data:
150150
driver: local
151-
redis_data:
151+
opencircle_redis_data:
152152
driver: local
153153

154154
networks:

docs/www/pages/platform-setup.mdx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ Once you've deployed OpenCircle using Docker, follow these steps to set up your
77
## Access the Admin Panel
88

99
1. Navigate to your admin dashboard: **http://localhost:4000** (or your configured `ADMIN_URL`)
10-
2. Log in with your admin credentials
10+
2. Create an Admin Account, Remember that register form is only shown once.
11+
12+
![OpenCircle Platform](/admin/step-1.png)
13+
1114

1215
## Create Your First Channel
1316

@@ -57,4 +60,3 @@ Create additional channels for different purposes:
5760
- Verify database is running and accessible
5861
- Check authentication settings in Admin → Core Admin → Auth
5962
- Review API logs: `docker compose logs api`
60-

docs/www/pages/self-hosting.mdx

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,44 @@ Access your applications:
2323
- **Admin Dashboard**: http://localhost:4000
2424
- **API**: http://localhost:8000
2525

26+
## Install Docker
27+
28+
### macOS
29+
```bash
30+
# Install Docker Desktop using Homebrew
31+
brew install --cask docker
32+
33+
# Or download from https://docker.com/products/docker-desktop
34+
```
35+
36+
### Ubuntu/Debian
37+
```bash
38+
# Install Docker
39+
curl -fsSL https://get.docker.com -o get-docker.sh
40+
sudo sh get-docker.sh
41+
42+
# Add your user to the docker group
43+
sudo usermod -aG docker $USER
44+
45+
# Install Docker Compose
46+
sudo apt-get update
47+
sudo apt-get install docker-compose-plugin
48+
49+
# Log out and back in for group changes to take effect
50+
```
51+
52+
### Windows
53+
Download and install Docker Desktop from [docker.com](https://docker.com/products/docker-desktop)
54+
55+
### Verify Installation
56+
```bash
57+
docker --version
58+
docker compose version
59+
```
60+
2661
## Prerequisites
2762

28-
- Docker and Docker Compose installed
63+
- Docker and Docker Compose installed (see installation guide above)
2964
- At least 2GB RAM available
3065
- 10GB free disk space
3166

docs/www/public/admin/step-1.png

148 KB
Loading

0 commit comments

Comments
 (0)