added handling for .cofig via .env file
This commit is contained in:
@@ -68,7 +68,7 @@ func LoadConfig() *Config {
|
|||||||
fmt.Printf("DEBUG LoadConfig - DATABASE_TYPE aus ENV: '%s'\n", os.Getenv("DATABASE_TYPE"))
|
fmt.Printf("DEBUG LoadConfig - DATABASE_TYPE aus ENV: '%s'\n", os.Getenv("DATABASE_TYPE"))
|
||||||
|
|
||||||
// Server Port
|
// Server Port
|
||||||
if port := os.Getenv("PORT"); port != "" {
|
if port := os.Getenv("API_PORT"); port != "" {
|
||||||
config.ServerPort = port
|
config.ServerPort = port
|
||||||
}
|
}
|
||||||
if port := os.Getenv("SERVER_PORT"); port != "" {
|
if port := os.Getenv("SERVER_PORT"); port != "" {
|
||||||
@@ -127,8 +127,8 @@ func LoadConfig() *Config {
|
|||||||
config.ExportTempDir = exportTempDir
|
config.ExportTempDir = exportTempDir
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("DEBUG LoadConfig - Finale Config: Environment='%s', DevTesting='%s', DatabaseType='%s'\n",
|
fmt.Printf("DEBUG LoadConfig - Finale Config: Environment='%s', DevTesting='%s', DatabaseType='%s'\n Complete: %v\n",
|
||||||
config.Environment, config.DevTesting, config.DatabaseType)
|
config.Environment, config.DevTesting, config.DatabaseType, config)
|
||||||
|
|
||||||
return config
|
return config
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-3
@@ -1,14 +1,21 @@
|
|||||||
# Environment variables for Bamort development environment
|
# Environment variables for Bamort development environment
|
||||||
|
|
||||||
# API Configuration
|
# API Configuration
|
||||||
VITE_API_URL=http://localhost:8180
|
# API_URL=http://localhost:8180
|
||||||
|
|
||||||
# Database Configuration (for development)
|
# Database Configuration (for development)
|
||||||
DATABASE_TYPE=mysql
|
DATABASE_TYPE=mysql
|
||||||
DATABASE_URL=bamort:bG4)efozrc@tcp(mariadb:3306)/bamort?charset=utf8mb4&parseTime=True&loc=Local
|
DATABASE_URL=bamort:bG4)efozrc@tcp(mariadb-dev:3306)/bamort?charset=utf8mb4&parseTime=True&loc=Local
|
||||||
|
|
||||||
# MariaDB Configuration (development)
|
# MariaDB Configuration (development)
|
||||||
MARIADB_ROOT_PASSWORD=root_password_dev
|
MARIADB_ROOT_PASSWORD=root_password_dev
|
||||||
MARIADB_PASSWORD=bG4)efozrc
|
MARIADB_PASSWORD=bG4)efozrc
|
||||||
|
MARIADB_DATABASE=bamort
|
||||||
|
MARIADB_USER=bamort
|
||||||
|
|
||||||
VITE_API_URL=http://192.168.0.48:8180
|
# Frontend Configuration
|
||||||
|
API_URL=http://192.168.0.48:8180
|
||||||
|
API_PORT=8180
|
||||||
|
BASE_URL=http://localhost:5173
|
||||||
|
TEMPLATES_DIR=./templates
|
||||||
|
EXPORT_TEMP_DIR=./export_temp
|
||||||
@@ -9,8 +9,11 @@ services:
|
|||||||
environment:
|
environment:
|
||||||
- GO_ENV=development
|
- GO_ENV=development
|
||||||
- CGO_ENABLED=1
|
- CGO_ENABLED=1
|
||||||
- DATABASE_TYPE=mysql
|
- DATABASE_TYPE=${DATABASE_TYPE:-mysql}
|
||||||
- DATABASE_URL=bamort:bG4)efozrc@tcp(mariadb-dev:3306)/bamort?charset=utf8mb4&parseTime=True&loc=Local
|
- DATABASE_URL=${DATABASE_URL:-${MARIADB_USER:-bamort}:${MARIADB_PASSWORD:-secure_user_password}@tcp(mariadb-dev:3306)/${MARIADB_DATABASE:-bamort}?charset=utf8mb4&parseTime=True&loc=Local}
|
||||||
|
- API_PORT=${API_PORT:-8180}
|
||||||
|
- TEMPLATES_DIR=${TEMPLATES_DIR:-./templatesx}
|
||||||
|
- EXPORT_TEMP_DIR=${EXPORT_TEMP_DIR:-./export_tempx}
|
||||||
depends_on:
|
depends_on:
|
||||||
mariadb-dev:
|
mariadb-dev:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
@@ -30,7 +33,9 @@ services:
|
|||||||
- "5173:5173" # Vite dev server port
|
- "5173:5173" # Vite dev server port
|
||||||
environment:
|
environment:
|
||||||
- NODE_ENV=development
|
- NODE_ENV=development
|
||||||
- VITE_API_URL=${VITE_API_URL:-http://192.168.0.48:8180}
|
- VITE_API_URL=${API_URL:-http://192.168.0.1:8180}
|
||||||
|
- VITE_BASE_URL=${BASE_URL:-http://bamort.trokan.de}
|
||||||
|
- VITE_API_PORT=${API_PORT:-8180}
|
||||||
depends_on:
|
depends_on:
|
||||||
- backend-dev
|
- backend-dev
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
@@ -45,10 +50,10 @@ services:
|
|||||||
#ports:
|
#ports:
|
||||||
# - "3306:3306"
|
# - "3306:3306"
|
||||||
environment:
|
environment:
|
||||||
MARIADB_ROOT_PASSWORD: root_password_dev
|
MARIADB_ROOT_PASSWORD: ${MARIADB_ROOT_PASSWORD:-secure_root_password}
|
||||||
MARIADB_DATABASE: bamort
|
MARIADB_DATABASE: ${MARIADB_DATABASE:-bamort}
|
||||||
MARIADB_USER: bamort
|
MARIADB_USER: ${MARIADB_USER:-bamort}
|
||||||
MARIADB_PASSWORD: bG4)efozrc
|
MARIADB_PASSWORD: ${MARIADB_PASSWORD:-secure_user_password}
|
||||||
MARIADB_CHARSET: utf8mb4
|
MARIADB_CHARSET: utf8mb4
|
||||||
MARIADB_COLLATION: utf8mb4_unicode_ci
|
MARIADB_COLLATION: utf8mb4_unicode_ci
|
||||||
volumes:
|
volumes:
|
||||||
@@ -70,8 +75,8 @@ services:
|
|||||||
PMA_HOST: mariadb-dev
|
PMA_HOST: mariadb-dev
|
||||||
PMA_PORT: 3306
|
PMA_PORT: 3306
|
||||||
PMA_USER: root
|
PMA_USER: root
|
||||||
PMA_PASSWORD: root_password_dev
|
PMA_PASSWORD: ${MARIADB_ROOT_PASSWORD:-secure_root_password}
|
||||||
MYSQL_ROOT_PASSWORD: root_password_dev
|
MYSQL_ROOT_PASSWORD: ${MARIADB_ROOT_PASSWORD:-secure_root_password}
|
||||||
PMA_ARBITRARY: 1
|
PMA_ARBITRARY: 1
|
||||||
depends_on:
|
depends_on:
|
||||||
mariadb-dev:
|
mariadb-dev:
|
||||||
|
|||||||
@@ -9,8 +9,9 @@ services:
|
|||||||
environment:
|
environment:
|
||||||
- GO_ENV=production
|
- GO_ENV=production
|
||||||
- CGO_ENABLED=1
|
- CGO_ENABLED=1
|
||||||
- DATABASE_TYPE=mysql
|
- DATABASE_TYPE=${DATABASE_TYPE:-mysql}
|
||||||
- DATABASE_URL=bamort:${MARIADB_PASSWORD:-secure_user_password}@tcp(mariadb:3306)/bamort?charset=utf8mb4&parseTime=True&loc=Local
|
- DATABASE_URL=${DATABASE_URL:-bamort:${MARIADB_PASSWORD:-secure_user_password}@tcp(mariadb:3306)/bamort?charset=utf8mb4&parseTime=True&loc=Local}
|
||||||
|
- API_PORT=${API_PORT:-8180}
|
||||||
depends_on:
|
depends_on:
|
||||||
mariadb:
|
mariadb:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
@@ -27,10 +28,10 @@ services:
|
|||||||
ports:
|
ports:
|
||||||
- "8181:80"
|
- "8181:80"
|
||||||
environment:
|
environment:
|
||||||
- ENVIRONMENT=production
|
- NODE_ENV=production
|
||||||
- VITE_API_URL=${VITE_API_URL:-http://bamort.trokan.de:8180}
|
- VITE_API_URL=${API_URL:-http://bamort.trokan.de:8180}
|
||||||
- BASE_URL=http://bamort.trokan.de
|
- VITE_BASE_URL=${BASE_URL:-http://bamort.trokan.de}
|
||||||
- PORT=8180
|
- VITE_API_PORT=${API_PORT:-8180}
|
||||||
depends_on:
|
depends_on:
|
||||||
- backend
|
- backend
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
@@ -43,8 +44,8 @@ services:
|
|||||||
# - "3306:3306"
|
# - "3306:3306"
|
||||||
environment:
|
environment:
|
||||||
MARIADB_ROOT_PASSWORD: ${MARIADB_ROOT_PASSWORD:-secure_root_password}
|
MARIADB_ROOT_PASSWORD: ${MARIADB_ROOT_PASSWORD:-secure_root_password}
|
||||||
MARIADB_DATABASE: bamort
|
MARIADB_DATABASE: ${MARIADB_DATABASE:-bamort}
|
||||||
MARIADB_USER: bamort
|
MARIADB_USER: ${MARIADB_USER:-bamort}
|
||||||
MARIADB_PASSWORD: ${MARIADB_PASSWORD:-secure_user_password}
|
MARIADB_PASSWORD: ${MARIADB_PASSWORD:-secure_user_password}
|
||||||
MARIADB_CHARSET: utf8mb4
|
MARIADB_CHARSET: utf8mb4
|
||||||
MARIADB_COLLATION: utf8mb4_unicode_ci
|
MARIADB_COLLATION: utf8mb4_unicode_ci
|
||||||
|
|||||||
+2
-2
@@ -17,6 +17,6 @@ echo "📦 Building and starting development containers..."
|
|||||||
docker-compose -f docker-compose.yml down
|
docker-compose -f docker-compose.yml down
|
||||||
|
|
||||||
# Baue und starte die Container
|
# Baue und starte die Container
|
||||||
docker-compose -d -f docker-compose.yml up --build
|
docker-compose -f docker-compose.yml up --build -d
|
||||||
|
|
||||||
echo "✅ Development environment stopped."
|
echo "✅ Development environment started."
|
||||||
|
|||||||
@@ -2,8 +2,6 @@ import axios from 'axios'
|
|||||||
|
|
||||||
const API = axios.create({
|
const API = axios.create({
|
||||||
baseURL: import.meta.env.VITE_API_URL || 'http://localhost:8180', // Use env variable with fallback
|
baseURL: import.meta.env.VITE_API_URL || 'http://localhost:8180', // Use env variable with fallback
|
||||||
//baseURL: 'http://192.168.0.48:8180', // Replace with your backend URL
|
|
||||||
//baseURL: 'http://localhost:8180', // Replace with your backend URL
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// Request interceptor to add auth token
|
// Request interceptor to add auth token
|
||||||
|
|||||||
Reference in New Issue
Block a user