a9df9c0cf4
Build and Push Docker Image / build (push) Successful in 2m26s
- Enforce task ownership on PATCH/DELETE /api/tasks (was: any signed-in user could edit or delete anyone's tasks) - Validate all API request bodies with zod; escape user content and restrict links to http(s) in the Drive export; block reverting a SUBMITTED report - Add @@unique([userId, date]) on Report with upsert to eliminate the duplicate-daily-report race; switch startup from `prisma db push --accept-data-loss` to `prisma migrate deploy` with automatic baselining of existing databases (dedup migration merges any pre-existing duplicates) - Autosave: re-queue and retry failed task saves with a visible saving/error indicator instead of silently dropping edits - Paginate and filter GET /api/reports (?date, ?mine, ?q, ?take, ?cursor); report form fetches only today's report, admin dashboard uses server-side search + Load more - Type the frontend and lib layer (DTOs in src/types/api.ts); zero eslint errors - Update README and Unraid guide for migrations, upgrade path, and API Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
81 lines
3.8 KiB
Markdown
81 lines
3.8 KiB
Markdown
# Unraid Installation Guide for WFH Daily Report
|
|
|
|
To install the WFH Daily Report app on your Unraid server, follow these steps.
|
|
|
|
## Docker Configuration
|
|
|
|
1. **Go to the 'Docker' tab** on your Unraid dashboard.
|
|
2. **Click 'Add Container'** (at the bottom).
|
|
3. **Configure the following settings**:
|
|
- **Name**: `WFH-Daily-Report`
|
|
- **Repository**: `[your-docker-registry]/wfh-daily-report:latest` (or your local build)
|
|
- **Network Type**: `Bridge`
|
|
- **WebUI**: `http://[IP]:[PORT:3000]`
|
|
|
|
### 1. Port Mapping
|
|
- **Container Port**: `3000`
|
|
- **Host Port**: `3000` (or any free port on your server)
|
|
|
|
### 2. Path Mapping (Volumes)
|
|
Adding a path mapping ensures your reports (SQLite database) persist when the container updates.
|
|
- **Container Path**: `/app/data`
|
|
- **Host Path**: `/mnt/user/appdata/wfh-daily-report/data`
|
|
- **Access Mode**: `Read/Write`
|
|
|
|
### 3. Environment Variables
|
|
Click **'Add another Path, Port, Variable, Label or Device'** to add each of these required variables:
|
|
|
|
| Variable | Recommended Value / Description |
|
|
| :--- | :--- |
|
|
| `NEXTAUTH_URL` | `http://[your-unraid-ip]:3000` |
|
|
| `NEXTAUTH_SECRET` | A random 32-char hex string (e.g. from `openssl rand -hex 32`) |
|
|
| `GOOGLE_CLIENT_ID` | Your Google Cloud Client ID |
|
|
| `GOOGLE_CLIENT_SECRET` | Your Google Cloud Client Secret |
|
|
| `DATABASE_URL` | `file:/app/data/dev.db` |
|
|
|
|
---
|
|
|
|
## Obtaining Google OAuth Credentials
|
|
|
|
To enable login and Google Drive exports, you must create a project in the [Google Cloud Console](https://console.cloud.google.com/).
|
|
|
|
### 1. Create a New Project
|
|
- Click the project dropdown in the top-left and select **'New Project'**.
|
|
- Give it a name like `WFH-Daily-Report` and click **Create**.
|
|
|
|
### 2. Configure OAuth Consent Screen
|
|
- Go to **APIs & Services > OAuth consent screen**.
|
|
- Select **'Internal'** (if you have Google Workspace) or 'External'.
|
|
- Fill in the required App Information (App name, support email, developer contact).
|
|
- In the **Scopes** section, click **'Add or Remove Scopes'** and add:
|
|
- `.../auth/userinfo.email`
|
|
- `.../auth/userinfo.profile`
|
|
- `.../auth/drive.file` (Required for report exports)
|
|
|
|
### 3. Create Credentials
|
|
- Go to **APIs & Services > Credentials**.
|
|
- Click **'Create Credentials'** and select **'OAuth client ID'**.
|
|
- Select **'Web application'** as the Application type.
|
|
- **Authorized Redirect URIs**: Add `http://[your-unraid-ip]:3000/api/auth/callback/google`.
|
|
- Click **Create**. Copy the **Client ID** and **Client Secret** now displayed.
|
|
|
|
### 4. Enable Google Drive API
|
|
- Go to **Enabled APIs & Services > Enable APIs and Services**.
|
|
- Search for **'Google Drive API'** and click **Enable**.
|
|
|
|
---
|
|
|
|
## Google Cloud Console Requirements
|
|
For the application to work, you must configure your Google Cloud Project:
|
|
1. **Authorized Redirect URIs**: `http://[your-unraid-ip]:3000/api/auth/callback/google`
|
|
2. **Scopes**: Enable `Google Drive API` and ensure `auth/drive.file` scope is requested.
|
|
|
|
## Database & Upgrades
|
|
|
|
The database schema is managed by Prisma Migrate: every container start runs `prisma migrate deploy`, which applies any pending schema migrations automatically before the server boots.
|
|
|
|
**Upgrading from a version prior to migrations** (i.e. a database created by the old `db push` startup): the first boot after the upgrade will log a one-time `P3005` error followed by `Migration 0_init marked as applied.` — this is the automatic baseline step and is expected. No manual action is required, and your data is preserved. Any duplicate reports for the same user and day (a bug in older versions) are merged automatically during this migration.
|
|
|
|
## Support
|
|
The database is a single SQLite file located at `/mnt/user/appdata/wfh-daily-report/data/dev.db`. You can back this file up directly (ideally while the container is stopped, or copy the file atomically).
|