3.3 KiB
Environment Setup
Notely uses three different environment-file locations depending on how you run the app.
1. Root .env
Use the root .env file when running docker compose from the repository root.
Start from:
cp .env.example .env
Variables Used By Docker Compose
Required or commonly used:
MONGODB_URIBACKEND_PORTJWT_SECRETENCRYPTION_KEYFRONTEND_URLDEFAULT_ADMIN_EMAILDEFAULT_ADMIN_USERNAMEDEFAULT_ADMIN_PASSWORDNGINX_HTTP_PORTNGINX_HTTPS_PORT
Optional backend runtime values that Docker Compose will also pass through if present:
REDIS_ADDRREDIS_USERREDIS_PASSWORDREDIS_DBSESSION_TTL_HOURS
Current Defaults In The Checked-In Example
- MongoDB container:
mongodb://admin:password@mongodb:27017/noteapp?authSource=admin - Backend port:
8080 - Public frontend URL:
http://localhost
2. backend/.env
Use backend/.env for local backend development.
Start from:
cd backend
cp .env.example .env
Variables Currently Read By The Backend Runtime
Read in backend/cmd/server/main.go or other active handlers:
MONGODB_URIJWT_SECRETENCRYPTION_KEYPORTREDIS_ADDRREDIS_USERREDIS_PASSWORDREDIS_DBSESSION_TTL_HOURSDEFAULT_ADMIN_EMAILDEFAULT_ADMIN_USERNAMEDEFAULT_ADMIN_PASSWORDFRONTEND_URL
Variables Present In backend/.env.example But Not Currently Consumed By Runtime Code
These values exist in the example file, but the current code path does not read them yet:
JWT_ISSUERENVLOG_LEVELCORS_ALLOWED_ORIGINSRATE_LIMIT_REQUESTSRATE_LIMIT_WINDOW
Backend Defaults If A Variable Is Missing
MONGODB_URI:mongodb://localhost:27017JWT_SECRET:your-secret-key-change-in-productionENCRYPTION_KEY:00000000000000000000000000000000PORT:8080REDIS_ADDR:localhost:6379REDIS_DB:0SESSION_TTL_HOURS:168FRONTEND_URL: falls back tohttp://localhost:5173for login redirects
3. frontend/.env
Use frontend/.env for local frontend development.
Start from:
cd frontend
cp .env.example .env
Frontend Variables In frontend/.env.example
VITE_ENVVITE_ENABLE_ANALYTICS
Variables Currently Relevant To The Frontend App
- API requests are sent to the current browser origin (same-origin runtime behavior)
The other example values are safe to keep, but the current checked-in frontend code does not actively consume them.
Secret Generation
Examples:
openssl rand -base64 32
openssl rand -hex 16
openssl rand -hex 32
Use generated values for:
JWT_SECRETENCRYPTION_KEY- provider secrets or other sensitive credentials stored through admin settings
Compose Vs Local Development
Use the right env file for the right mode:
- root
.env: Docker Compose backend/.env: local backendfrontend/.env: local frontend
Do not assume values from one location are automatically shared with the others.
Important Notes
- Do not commit real secrets
- Keep
ENCRYPTION_KEYat 32 characters for the current AES-256 usage - If OAuth login is enabled, set
FRONTEND_URLcorrectly so callback redirects go to the intended UI - If Redis settings are omitted, the backend assumes a local Redis instance at
localhost:6379