Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ DEVICE_POSTGRES_PASSWORD=
DEVICE_SECRET_KEY=
TELEMETRY_SERVICE_URL="http://telemetry:8080"

# TimescaleDB Service
TIMESCALEDB_PASSWORD=

# EMQX Service
EMQX_HOST="http://emqx:18083/api/v5"
EMQX_USERNAME=
Expand All @@ -58,9 +61,6 @@ MQTT_TOPICS="tenant/+/transformed/device/location"
EMAIL_HOST_USER=
EMAIL_HOST_PASSWORD=
DEFAULT_FROM_EMAIL="no-reply@gmail.com"
EMAIL_BACKEND=
EMAIL_PORT=
EMAIL_USE_TLS=

# MPA service
MQTT_BROKER="emqx"
Expand Down
33 changes: 33 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
#!/usr/bin/env bash

# Check if .env file exists
if [ ! -f .env ]; then
echo -e "\033[1;31mERROR: .env file not found!\033[0m"
echo -e "\033[0;33mYou can copy from .env.example if available:\033[0m"
echo -e " cp .env.example .env"
exit 1
fi

set -a
source .env
set +a
Expand Down Expand Up @@ -55,6 +64,30 @@ if [ "$PASSWORD_CHANGED" = true ]; then
docker exec rabbitmq rabbitmqctl change_password "$RABBITMQ_DEFAULT_USER" "$RABBITMQ_DEFAULT_PASS"
fi

sync_postgres_password() {
local container_name=$1
local new_password=$2
local db_user=${3:-postgres}

if docker ps --format '{{.Names}}' | grep -q "^${container_name}$"; then
for i in {1..10}; do
if docker exec "$container_name" pg_isready -U "$db_user" &>/dev/null; then
break
fi
sleep 1
done

docker exec "$container_name" psql -U "$db_user" -c "ALTER USER ${db_user} WITH PASSWORD '${new_password}';" &>/dev/null || true
fi
}

# Sync all PostgreSQL passwords from .env BEFORE stopping
sync_postgres_password "device_postgres" "$DEVICE_POSTGRES_PASSWORD"
sync_postgres_password "auth_postgres" "$AUTH_POSTGRES_PASSWORD"
sync_postgres_password "dashboard_postgres" "$DASHBOARD_POSTGRES_PASSWORD"
sync_postgres_password "bootstrap_postgres" "$BOOTSTRAP_POSTGRES_PASSWORD"
sync_postgres_password "timescaledb" "$TIMESCALEDB_PASSWORD"

echo "Deploying SpaceDF Core..."
echo "Stopping existing services (if running)..."
docker compose -f "${COMPOSE_FILE}" -p "${PROJECT_NAME}" stop || true
Expand Down
1 change: 1 addition & 0 deletions generate-keys.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ env_vars = {
'DASHBOARD_POSTGRES_PASSWORD': 'postgres',
'DEVICE_POSTGRES_PASSWORD': 'postgres',
'BOOTSTRAP_POSTGRES_PASSWORD': 'postgres',
'TIMESCALEDB_PASSWORD': 'postgres',
'EMQX_USERNAME': 'user',
'EMQX_PASSWORD': 'password123',
'MQTT_BROKER_BRIDGE_PASSWORD': 'Default@1234',
Expand Down