Self-improving AI Employees for everyone
Python ai-agentsai-employeeai-employeesassistantautonomous-agentsco-employeescompanygrok-botinstinctloop-agentsmuseown-your-datapersonalself-hosted
Optimize Docker frontend build and auto-create .env from template
trohitgb6c1b0b3a998
diff --git a/deploy.sh b/deploy.shindex 1c878c4a..f5c6ef52 100644--- a/deploy.sh+++ b/deploy.sh@@ -63,9 +63,13 @@ elif [ -f "${LOCAL_DIR}/server/.env" ]; thenelif [ -f "${LOCAL_DIR}/.env.template" ]; thenecho "No .env found, creating from .env.template..."scp "${LOCAL_DIR}/.env.template" "${GCP_HOST}:/tmp/${SERVICE_NAME}/.env"+ # Enable Redis for production Docker mode+ ssh ${GCP_HOST} "sed -i 's/^REDIS_ENABLED=false/REDIS_ENABLED=true/' /tmp/${SERVICE_NAME}/.env"elif [ -f "${LOCAL_DIR}/server/.env.template" ]; thenecho "No .env found, creating from server/.env.template..."scp "${LOCAL_DIR}/server/.env.template" "${GCP_HOST}:/tmp/${SERVICE_NAME}/.env"+ # Enable Redis for production Docker mode+ ssh ${GCP_HOST} "sed -i 's/^REDIS_ENABLED=false/REDIS_ENABLED=true/' /tmp/${SERVICE_NAME}/.env"elseecho "Warning: No .env or .env.template found. Using docker-compose environment variables only."fidiff --git a/docker-compose.yml b/docker-compose.ymlindex 06532679..3fd1a9db 100644--- a/docker-compose.yml+++ b/docker-compose.yml@@ -51,30 +51,22 @@ services:whatsapp:condition: service_healthy- # React Frontend (Vite)+ # React Frontend (Vite) - Production build served via nginxfrontend:build:context: ./clientdockerfile: Dockerfile- target: development+ target: production+ args:+ - VITE_AUTH_ENABLED=${VITE_AUTH_ENABLED:-true}container_name: machina-frontendports:- - "${VITE_CLIENT_PORT:-3000}:${VITE_CLIENT_PORT:-3000}"- volumes:- - ./client:/app- - /app/node_modules+ - "${VITE_CLIENT_PORT:-3000}:80"networks:- app-networkrestart: unless-stoppeddepends_on:- backend- env_file:- - .env- environment:- # Override for Docker networking- - VITE_API_URL=http://backend:${PYTHON_BACKEND_PORT:-3010}- - VITE_WS_URL=ws://backend:${PYTHON_BACKEND_PORT:-3010}- - TZ=UTC# WhatsApp RPC Service (Go API)whatsapp:diff --git a/scripts/docker.js b/scripts/docker.jsindex c2ed8ed5..72e6fb31 100644--- a/scripts/docker.js+++ b/scripts/docker.js@@ -6,14 +6,14 @@*/import { spawn } from 'child_process';-import { readFileSync, existsSync, copyFileSync } from 'fs';+import { readFileSync, writeFileSync, existsSync, copyFileSync } from 'fs';import { fileURLToPath } from 'url';import { dirname, resolve } from 'path';const __dirname = dirname(fileURLToPath(import.meta.url));const ROOT = resolve(__dirname, '..');-// Create .env from template if it doesn't exist+// Create .env from template if it doesn't exist, with Docker-specific defaultsfunction ensureEnvFile() {const envPath = resolve(ROOT, '.env');if (existsSync(envPath)) return true;@@ -28,6 +28,13 @@ function ensureEnvFile() {if (existsSync(templatePath)) {console.log(`[Docker] Creating .env from ${templatePath.replace(ROOT, '.')}`);copyFileSync(templatePath, envPath);++ // Enable Redis by default for Docker mode+ let content = readFileSync(envPath, 'utf8');+ content = content.replace(/^REDIS_ENABLED\s*=\s*false/m, 'REDIS_ENABLED=true');+ writeFileSync(envPath, content);+ console.log('[Docker] Set REDIS_ENABLED=true for Docker mode');+return true;}}