Skip to content

Commit 9e242b0

Browse files
committed
fix: Remove hardcoded secrets from docker-compose
Docker was using a hardcoded JWT secret which isn't great even for dev. Now pulls from .env file with a clear error if JWT_SECRET isn't set. Also rewrote the Quick Start section - was confusing about whether Docker runs just the API or the full stack. Now shows both options.
1 parent 411bebf commit 9e242b0

File tree

4 files changed

+32
-14
lines changed

4 files changed

+32
-14
lines changed

.env.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# .env.example
22
# Copy this file to .env and fill in your values
33
# DO NOT commit your actual .env file to version control
4+
#
5+
# These variables are used by both docker-compose and local development.
46

57
# -----------------------------------------------------------------------------
68
# Database Configuration

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ TestResults/
1313
# TUI Log Files
1414
*.log
1515

16+
# Environment files (contains secrets)
17+
.env
18+
.env.local
19+
.env.*.local
20+
1621
# Node
1722
node_modules/
1823
npm-debug.log*

README.md

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,19 +61,30 @@ curl -X POST http://localhost:5257/api/documents/generate \
6161

6262
(Requires Docker OR .NET 8 SDK + Node.js 18+)
6363

64-
**With Docker** (runs API only):
64+
**With Docker**:
6565
```bash
6666
git clone https://github.com/jonmartin721/docforge-api.git
6767
cd docforge-api
68-
docker-compose up -d
6968

70-
# Then start the frontend separately
71-
cd DocumentGenerator.Client
72-
npm install
73-
npm run dev
69+
# 1. Configure environment
70+
cp .env.example .env
71+
# Edit .env and set JWT_SECRET (minimum 32 characters)
72+
73+
# 2. Build frontend and start everything
74+
docker-compose --profile build up docforge-frontend-builder # Build frontend once
75+
docker-compose up -d # Start API + nginx
7476
```
7577

76-
Then open:
78+
Then open http://localhost (nginx serves both frontend and API).
79+
80+
**For development** (hot reload on frontend):
81+
```bash
82+
cp .env.example .env # Set JWT_SECRET
83+
docker-compose up -d docforge-api # API only
84+
85+
# Frontend with hot reload (separate terminal)
86+
cd DocumentGenerator.Client && npm install && npm run dev
87+
```
7788
- **Frontend**: http://localhost:5173
7889
- **API**: http://localhost:5000/swagger
7990

@@ -112,7 +123,7 @@ chmod +x docforge.sh && ./docforge.sh
112123
- **Works offline** - No external API calls, runs entirely on your infrastructure
113124
- **Handles the hard parts** - Chrome rendering, proper fonts, page breaks that don't suck
114125
- **Multi-user ready** - JWT auth built in, not bolted on later
115-
- **Docker support** - API runs in container, frontend runs locally (Vite)
126+
- **Docker support** - Full stack runs in containers, or API-only for development with hot reload
116127

117128
## Architecture
118129

docker-compose.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ services:
1111
ports:
1212
- "5000:8080"
1313
environment:
14-
- ASPNETCORE_ENVIRONMENT=Development
15-
- ConnectionStrings__DefaultConnection=Data Source=/app/data/documentgenerator.db
16-
- JwtSettings__Secret=THIS_IS_A_SUPER_SECRET_KEY_FOR_JWT_TOKEN_GENERATION_AT_LEAST_32_CHARS
17-
- JwtSettings__Issuer=DocForge
18-
- JwtSettings__Audience=DocForgeUsers
19-
- JwtSettings__ExpirationMinutes=60
14+
- ASPNETCORE_ENVIRONMENT=${ASPNETCORE_ENVIRONMENT:-Development}
15+
- ConnectionStrings__DefaultConnection=${DATABASE_CONNECTION_STRING:-Data Source=/app/data/documentgenerator.db}
16+
- JwtSettings__Secret=${JWT_SECRET:?JWT_SECRET is required - copy .env.example to .env}
17+
- JwtSettings__Issuer=${JWT_ISSUER:-DocForge}
18+
- JwtSettings__Audience=${JWT_AUDIENCE:-DocForge}
19+
- JwtSettings__ExpirationMinutes=${JWT_EXPIRATION_MINUTES:-60}
2020
volumes:
2121
- ./data:/app/data
2222
- ./GeneratedDocuments:/app/GeneratedDocuments

0 commit comments

Comments
 (0)