feat(devops): auto generate secure cryptographic keys in setup

This commit is contained in:
datadunia
2026-05-16 02:52:08 +07:00
parent 7ba35c517b
commit ad80ad0c08
+20 -2
View File
@@ -11,7 +11,18 @@ if [ ! -f .env ]; then
if [ -f .env.example ]; then if [ -f .env.example ]; then
echo "[+] Auto-generating .env from .env.example..." echo "[+] Auto-generating .env from .env.example..."
cp .env.example .env cp .env.example .env
echo "[!] IMPORTANT: Please review the .env file and change the default passwords!"
# Generate secure random hex keys for JWT and Server Salt
# Memastikan sistem aman tanpa campur tangan manual
RANDOM_JWT=$(openssl rand -hex 32)
RANDOM_SALT=$(openssl rand -hex 32)
# Replace the placeholders in the newly created .env file
sed -i "s/GantiDenganKunciRahasiaJWTUntukDashboard256Bit/$RANDOM_JWT/g" .env
sed -i "s/GantiDenganKunciGaramUntukWireGuard256Bit/$RANDOM_SALT/g" .env
echo "[+] Secure random cryptographic keys have been auto-generated!"
echo "[!] IMPORTANT: Please review the .env file to change the default database passwords!"
else else
echo "[-] ERROR: .env.example is missing. Cannot generate .env." echo "[-] ERROR: .env.example is missing. Cannot generate .env."
exit 1 exit 1
@@ -26,10 +37,17 @@ if ! command -v docker-compose &> /dev/null; then
exit 1 exit 1
fi fi
echo "[+] Sourcing environment variables to prepare builds..."
export $(grep -v '^#' .env | xargs)
echo "[+] Rebuilding containers if necessary..."
docker-compose build --build-arg VITE_API_BASE_URL=$VITE_API_BASE_URL
echo "[+] Bringing up Docker containers..." echo "[+] Bringing up Docker containers..."
docker-compose up -d docker-compose up -d
echo "======================================" echo "======================================"
echo " NexusGuard is successfully running! " echo " NexusGuard is successfully running! "
echo " API Port : 8080" echo " Web Dashboard : http://localhost"
echo " API Port : ${API_PORT:-8080}"
echo "======================================" echo "======================================"