Enhance Docker deployment with environment variable configuration
- Added environment variable setup in docker-compose.yml for VITE_API_URL. - Introduced update-docker-env.sh script to create/update .env file for local and remote deployments. - Updated Dockerfile to dynamically create env-config.js during build. - Modified frontend to load environment configuration from env-config.js. - Refactored API client to use centralized config for API URL.
This commit is contained in:
34
update-docker-env.sh
Executable file
34
update-docker-env.sh
Executable file
@@ -0,0 +1,34 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Script to set environment variables for Docker deployment
|
||||
# Usage: ./update-docker-env.sh [hostname]
|
||||
|
||||
# Default hostname if not provided
|
||||
DEFAULT_HOSTNAME="localhost"
|
||||
HOSTNAME=${1:-$DEFAULT_HOSTNAME}
|
||||
|
||||
# Create or update root .env file
|
||||
cat > .env << EOL
|
||||
# Frontend Configuration
|
||||
VITE_API_URL=http://${HOSTNAME}:3000
|
||||
|
||||
# Backend Configuration
|
||||
DB_HOST=db
|
||||
DB_PORT=5432
|
||||
DB_USER=postgres
|
||||
DB_PASSWORD=password
|
||||
DB_NAME=worklenz_db
|
||||
NODE_ENV=development
|
||||
PORT=3000
|
||||
|
||||
# Storage Configuration
|
||||
AWS_REGION=us-east-1
|
||||
STORAGE_PROVIDER=s3
|
||||
BUCKET=worklenz-bucket
|
||||
S3_ACCESS_KEY_ID=minioadmin
|
||||
S3_SECRET_ACCESS_KEY=minioadmin
|
||||
S3_URL=http://minio:9000
|
||||
EOL
|
||||
|
||||
echo "Environment configuration updated for ${HOSTNAME}"
|
||||
echo "To run with Docker Compose, use: docker-compose up -d"
|
||||
Reference in New Issue
Block a user