Overview
PhotoFlow uses environment variables to configure database connections, network settings, and application behavior. These variables are stored in a.env file in the project root.
Environment File
Create a.env file in your project root:
.gitignore.
Required Variables
DATABASE_URL
The PostgreSQL database connection string..env
postgresql://- Database type (always PostgreSQL)[user]- Database username[password]- Database password[host]- Database server hostname or IP[port]- Database port (default: 5432)[database]- Database name
- Local Development
- Docker
- Network Database
- Production
.env
Special Characters in Passwords
If your password contains special characters, URL-encode them:@becomes%40#becomes%23$becomes%24/becomes%2F?becomes%3F
Optional Variables
VITE_SOCKET_URL
Configures the Socket.io connection URL for real-time synchronization..env
- When other PCs need to connect to the server
- In production deployments
- When using a reverse proxy
window.location (the current page URL), which works for:
- Single-PC installations
- Local development
- When clients access via the correct URL already
.env
The
VITE_ prefix exposes this variable to the client-side code. Without this prefix, the variable would only be available on the server.NODE_ENV
Specifies the environment mode..env
development- Development mode with debuggingproduction- Production mode with optimizationstest- Testing environment
- Logging verbosity
- Error message detail
- Performance optimizations
- Build process behavior
PORT
The port number for the application server..env
- Development: 5173 (Vite dev server)
- Production: 4173 (preview) or 3000 (custom)
.env
http://localhost:8080
Docker Environment Variables
When using Docker, environment variables can be set indocker-compose.yml:
docker-compose.yml
Using .env with Docker
Using .env with Docker
Docker Compose can also read from a Or reference variables:Then in
.env file:docker-compose.yml
docker-compose.yml
.env:.env
Coolify Environment Variables
For Coolify deployments, environment variables are set differently:docker-compose.coolify.yml
${COOLIFY_URL}- Automatically set to your deployment URL${POSTGRES_USER},${POSTGRES_PASSWORD},${POSTGRES_DB}- Set in Coolify UI
Environment File Example
Here’s a complete.env.example file from the repository:
.env.example
Security Best Practices
Strong Passwords
Use complex passwords with:
- Minimum 16 characters
- Mix of letters, numbers, symbols
- No dictionary words
- Unique per environment
Never Commit .env
Always add to .gitignore:
Restrict Access
Set file permissions:Only owner can read/write.
Separate Environments
Use different values for:
- Development
- Staging
- Production
Accessing Environment Variables
Server-Side (Node.js)
Access viaprocess.env:
Client-Side (Browser)
Only variables prefixed withVITE_ are exposed:
Prisma
Prisma automatically readsDATABASE_URL from .env:
schema.prisma
Environment-Specific Configuration
Development
.env.development
Production
.env.production
Troubleshooting
Variables not loading
Variables not loading
- Ensure
.envis in the project root - Check file is named exactly
.env(not.env.txt) - Restart the application after changing
.env - Verify file permissions allow reading
Database connection fails
Database connection fails
- Verify
DATABASE_URLformat is correct - Test database credentials manually:
- Check PostgreSQL is running
- Verify network connectivity to database host
- Encode special characters in password
Socket.io won't connect
Socket.io won't connect
- Check
VITE_SOCKET_URLuses correct IP/hostname - Ensure port is accessible (no firewall blocking)
- Verify protocol (http:// or https://)
- Check browser console for connection errors
Client can't see VITE_ variable
Client can't see VITE_ variable
- Ensure variable name starts with
VITE_ - Rebuild the application:
- Vite injects variables at build time, not runtime
Production Secrets Management
For production environments, consider using a secrets management system:- Docker Secrets
- Environment Variables from CI/CD
- External Secret Stores
docker-compose.yml
Next Steps
Database Setup
Configure PostgreSQL for PhotoFlow
Network Setup
Configure multi-PC network access
Docker Deployment
Deploy with Docker using environment variables
Production Checklist
Security and configuration best practices