Refactor: Centralize .env handling and update Docker/dev setup

This commit is contained in:
courtmanr@gmail.com
2025-04-23 19:45:58 +01:00
parent 989f784f7b
commit 61ed96779c
4 changed files with 8 additions and 8 deletions
+2 -2
View File
@@ -12,8 +12,8 @@ services:
# You can change the host port (left side) if 7655 is already in use on your host
- "7655:7655"
env_file:
# Load environment variables from the .env file located in the server directory
- ./server/.env # Primary location
# Load environment variables from a .env file in the same directory as this compose file
- .env # Standard location
# Optional: Define networks if needed, otherwise uses default bridge network
# networks:
# - pulse_network
+1 -1
View File
@@ -5,7 +5,7 @@
"main": "server/index.js",
"scripts": {
"start": "cd server && node index.js",
"dev:server": "NODE_ENV=development cd server && node index.js",
"dev:server": "NODE_ENV=development node -r dotenv/config --env-file=.env server/index.js",
"dev:css": "tailwindcss -i ./src/index.css -o ./public/output.css --watch",
"build:css": "tailwindcss -i ./src/index.css -o ./public/output.css --minify",
"dev": "concurrently \"npm:dev:server\" \"npm:dev:css\"",
+5 -5
View File
@@ -1,4 +1,4 @@
require('dotenv').config(); // Load environment variables from .env file
// require('dotenv').config(); // Load environment variables from .env file
// --- BEGIN Environment Variable Validation ---
const primaryRequiredEnvVars = [
@@ -29,13 +29,13 @@ primaryRequiredEnvVars.forEach(varName => {
if (missingVars.length > 0 || placeholderVars.length > 0) {
console.error('\n--- Configuration Error (Primary Endpoint) ---');
if (missingVars.length > 0) {
console.error(`Missing required environment variables in server/.env for the primary endpoint: ${missingVars.join(', ')}`);
console.error(`Missing required environment variables: ${missingVars.join(', ')}. These are typically set via docker-compose.yml or a .env file.`);
}
if (placeholderVars.length > 0) {
console.error(`Primary environment variables seem to contain placeholder values in server/.env: ${placeholderVars.join(', ')}`);
console.error(`The following primary environment variables seem to contain placeholder values: ${placeholderVars.join(', ')}.`);
}
console.error('Please ensure server/.env exists and contains valid Proxmox connection details for the primary endpoint.');
console.error('Refer to server/.env.example for the required format.\n');
console.error('Please ensure valid Proxmox connection details are provided via environment variables.');
console.error('Refer to server/.env.example for the required variable names and format.\n');
process.exit(1); // Exit if primary configuration is invalid
}