j
This commit is contained in:
		
							parent
							
								
									470b80aea9
								
							
						
					
					
						commit
						1fed6042ca
					
				
					 3 changed files with 19 additions and 10 deletions
				
			
		
							
								
								
									
										23
									
								
								README.md
									
										
									
									
									
								
							
							
						
						
									
										23
									
								
								README.md
									
										
									
									
									
								
							|  | @ -3,7 +3,7 @@ | |||
| This repository now contains a two-container stack: | ||||
| 
 | ||||
| - `frontend/` – a Next.js 14 web UI that reimplements the original single-page experience | ||||
| - `backend/` – an Express API with Prisma + SQLite that provides authentication, base/category/defense CRUD, statistics, and image uploads | ||||
| - `backend/` – an Express API with Prisma + PostgreSQL that provides authentication, base/category/defense CRUD, statistics, and image uploads | ||||
| 
 | ||||
| Everything runs via Docker so you can deploy directly to Dokploy (or any Docker-based host). | ||||
| 
 | ||||
|  | @ -12,7 +12,9 @@ Everything runs via Docker so you can deploy directly to Dokploy (or any Docker- | |||
| The Dokploy-oriented compose files assume production domains. For a local smoke test you can temporarily override the variables at runtime: | ||||
| 
 | ||||
| ```bash | ||||
| JWT_SECRET=dev-secret docker compose -f docker-compose.backend.yml up --build -d | ||||
| JWT_SECRET=dev-secret \ | ||||
| DATABASE_URL="postgresql://basenoter:basenoter@localhost:5432/basenoter?schema=public" \ | ||||
| docker compose -f docker-compose.backend.yml up --build -d | ||||
| NEXT_PUBLIC_BACKEND_URL=http://localhost:4000 docker compose -f docker-compose.frontend.yml up --build -d | ||||
| ``` | ||||
| 
 | ||||
|  | @ -25,11 +27,12 @@ Default environment variables ship in `backend/.env.example`. Copy it (e.g. to ` | |||
| 
 | ||||
| **Persistent data** | ||||
| 
 | ||||
| The compose file provisions two named volumes: | ||||
| The compose file provisions a single named volume: | ||||
| 
 | ||||
| - `backend-data` – stores the Prisma SQLite database (`/app/dev.db`) | ||||
| - `backend-uploads` – stores uploaded base layout images (`/app/uploads`) | ||||
| 
 | ||||
| Because the API now targets PostgreSQL, you must supply an external database connection string via the `DATABASE_URL` environment variable (e.g., through Dokploy secrets pointing at your managed Postgres instance). | ||||
| 
 | ||||
| ## Backend details (`backend/`) | ||||
| 
 | ||||
| - Express 4 REST API | ||||
|  | @ -43,7 +46,7 @@ Environment variables (see `.env.example`): | |||
| 
 | ||||
| | Variable           | Purpose                                      | | ||||
| |-------------------|----------------------------------------------| | ||||
| | `DATABASE_URL`     | Prisma connection string (default SQLite)     | | ||||
| | `DATABASE_URL`     | Prisma connection string (PostgreSQL)         | | ||||
| | `JWT_SECRET`       | Secret for signing JWT auth cookies          | | ||||
| | `FRONTEND_ORIGIN`  | CORS allowlist (e.g. `http://localhost:3100`) | | ||||
| | `COOKIE_SECURE`    | Set to `true` when serving over HTTPS        | | ||||
|  | @ -69,7 +72,7 @@ Steps: | |||
| 2. In Dokploy create two Compose apps, each pointing to the respective file above. | ||||
| 3. Provide secrets for `JWT_SECRET` (backend) and any overrides you need; TLS-terminated installs should leave `COOKIE_SECURE` as `true`. | ||||
| 4. Dokploy's Traefik proxy will use the embedded labels to route the domains listed earlier. Adjust `entrypoints`/`certresolver` if your installation uses different names. | ||||
| 5. Configure persistent volumes for `/app/dev.db` and `/app/uploads`, or switch Prisma to an external database before deployment. | ||||
| 5. Configure the `DATABASE_URL` secret to point at your managed Postgres instance and mount the `backend-uploads` volume, or adjust the compose file to include a local Postgres service for testing. | ||||
| 
 | ||||
| ## Development without Docker | ||||
| 
 | ||||
|  | @ -86,6 +89,14 @@ npm run dev | |||
| 
 | ||||
| Set `NEXT_PUBLIC_BACKEND_URL=http://localhost:4100` for the frontend. | ||||
| 
 | ||||
| For the backend, provide a PostgreSQL connection string such as: | ||||
| 
 | ||||
| ``` | ||||
| DATABASE_URL="postgresql://basenoter:basenoter@localhost:5432/basenoter?schema=public" | ||||
| ``` | ||||
| 
 | ||||
| When developing locally you can point this URL at any Postgres instance you manage (Docker Desktop, remote cloud database, etc.). | ||||
| 
 | ||||
| ## Image handling | ||||
| 
 | ||||
| Uploaded base images are saved to `/app/uploads` inside the backend container and served at `http://<backend>/uploads/<filename>`. You can switch to an object store by swapping the Multer storage in `src/server.js`. | ||||
|  |  | |||
|  | @ -3,7 +3,7 @@ generator client { | |||
| } | ||||
| 
 | ||||
| datasource db { | ||||
|   provider = "sqlite" | ||||
|   provider = "postgresql" | ||||
|   url      = env("DATABASE_URL") | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -3,12 +3,11 @@ services: | |||
|     build: | ||||
|       context: ./backend | ||||
|     environment: | ||||
|       DATABASE_URL: file:./dev.db | ||||
|       DATABASE_URL: ${DATABASE_URL:?Set DATABASE_URL in Dokploy secrets} | ||||
|       JWT_SECRET: ${JWT_SECRET:?Set JWT_SECRET in Dokploy secrets} | ||||
|       FRONTEND_ORIGIN: https://basetracker.lona-development.org | ||||
|       COOKIE_SECURE: "true" | ||||
|     volumes: | ||||
|       - backend-data:/app/dev.db | ||||
|       - backend-uploads:/app/uploads | ||||
|     ports: | ||||
|       - "4000:4000" | ||||
|  | @ -22,5 +21,4 @@ services: | |||
|       - traefik.http.services.backend.loadbalancer.server.port=4000 | ||||
| 
 | ||||
| volumes: | ||||
|   backend-data: | ||||
|   backend-uploads: | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 Hymmel
						Hymmel