1 Commits

Author SHA1 Message Date
4d2aad404b Merge pull request 'Improved auth system' (#6) from feature/sqlite-auth-system into main
Some checks failed
Build and Push Docker Image / docker (push) Failing after 2s
Reviewed-on: #6
2025-09-01 19:03:30 -04:00
2 changed files with 7 additions and 62 deletions

View File

@@ -47,9 +47,6 @@ FROM rust:alpine AS backend-builder
WORKDIR /app
RUN apk add --no-cache musl-dev pkgconfig openssl-dev openssl-libs-static
# Install sqlx-cli for migrations
RUN cargo install sqlx-cli --no-default-features --features sqlite
# Copy shared models
COPY calendar-models ./calendar-models
@@ -79,29 +76,19 @@ RUN cargo build --release --bin backend
FROM alpine:latest
# Install runtime dependencies
RUN apk add --no-cache ca-certificates tzdata sqlite
RUN apk add --no-cache ca-certificates tzdata
# Copy frontend files to temporary location
COPY --from=builder /app/frontend/dist /app/frontend-dist
# Copy backend binary and sqlx-cli
# Copy backend binary (built in workspace root)
COPY --from=backend-builder /app/target/release/backend /usr/local/bin/backend
COPY --from=backend-builder /usr/local/cargo/bin/sqlx /usr/local/bin/sqlx
# Copy migrations for database setup
COPY --from=backend-builder /app/backend/migrations /migrations
# Create startup script to copy frontend files, run migrations, and start backend
RUN mkdir -p /srv/www /db
# Create startup script to copy frontend files to shared volume
RUN mkdir -p /srv/www
RUN echo '#!/bin/sh' > /usr/local/bin/start.sh && \
echo 'echo "Copying frontend files..."' >> /usr/local/bin/start.sh && \
echo 'cp -r /app/frontend-dist/* /srv/www/' >> /usr/local/bin/start.sh && \
echo 'echo "Ensuring database directory exists..."' >> /usr/local/bin/start.sh && \
echo 'mkdir -p /db && chmod 755 /db' >> /usr/local/bin/start.sh && \
echo 'echo "Running database migrations..."' >> /usr/local/bin/start.sh && \
echo 'sqlx migrate run --database-url "sqlite:///db/calendar.db" --source /migrations || echo "Migration failed but continuing..."' >> /usr/local/bin/start.sh && \
echo 'echo "Starting backend server..."' >> /usr/local/bin/start.sh && \
echo 'export DATABASE_URL="sqlite:///db/calendar.db"' >> /usr/local/bin/start.sh && \
echo '/usr/local/bin/backend' >> /usr/local/bin/start.sh && \
chmod +x /usr/local/bin/start.sh

View File

@@ -29,12 +29,6 @@ While there are many excellent self-hosted CalDAV server implementations (Nextcl
- **Real-time Updates**: Seamless synchronization with CalDAV servers
- **Timezone Aware**: Proper local time display with UTC storage
### User Experience
- **Persistent Preferences**: Settings sync across devices and sessions
- **Remember Me**: Optional server/username remembering for convenience
- **Session Management**: Secure session tokens with automatic expiry
- **Cross-Device Sync**: User preferences stored in database, not just browser
## Architecture
### Frontend (Yew WebAssembly)
@@ -46,8 +40,7 @@ While there are many excellent self-hosted CalDAV server implementations (Nextcl
### Backend (Axum)
- **Framework**: Axum async web framework with CORS support
- **Authentication**: SQLite-backed session management with JWT tokens
- **Database**: SQLite for user preferences and session storage
- **Authentication**: JWT token management and validation
- **CalDAV Client**: Full CalDAV protocol implementation for server sync
- **API Design**: RESTful endpoints following calendar operation patterns
- **Data Flow**: Proxy between frontend and CalDAV servers with proper authentication
@@ -61,36 +54,12 @@ While there are many excellent self-hosted CalDAV server implementations (Nextcl
## Getting Started
### Docker Deployment (Recommended)
### Prerequisites
The easiest way to run the calendar is using Docker Compose:
1. **Clone the repository**:
```bash
git clone <repository-url>
cd calendar
```
2. **Start the application**:
```bash
docker compose up
```
3. **Access the application** at `http://localhost`
The Docker setup includes:
- **Automatic database migrations** on startup
- **Persistent data storage** in `./data/db/` volume
- **Frontend served via Caddy** on port 80
- **Backend API** accessible on port 3000
### Development Setup
#### Prerequisites
- Rust (latest stable version)
- Trunk (`cargo install trunk`)
#### Local Development
### Development Setup
1. **Start the backend server** (serves API at http://localhost:3000):
```bash
@@ -104,17 +73,6 @@ The Docker setup includes:
3. **Access the application** at `http://localhost:8080`
#### Database Setup
For local development, run the database migrations:
```bash
# Install sqlx-cli if not already installed
cargo install sqlx-cli --features sqlite
# Run migrations
sqlx migrate run --database-url "sqlite:calendar.db" --source backend/migrations
```
### Building for Production
```bash