-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-entrypoint-dev.sh
More file actions
52 lines (42 loc) · 1.37 KB
/
Copy pathdocker-entrypoint-dev.sh
File metadata and controls
52 lines (42 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash
# Clear Laravel caches
php artisan optimize:clear
# Update .env file with correct Vite settings
sed -i "s#VITE_PORT=.*#VITE_PORT=5173#g" .env
sed -i "s#VITE_HOST=.*#VITE_HOST=0.0.0.0#g" .env
# Add HTTPS settings for secure environments
if [[ "$ENABLE_HTTPS" == "true" ]]; then
echo "Configuring for HTTPS environment..."
# Add HTTPS environment variable if not present
if ! grep -q "VITE_SECURE=" .env; then
echo "VITE_SECURE=true" >> .env
else
sed -i "s#VITE_SECURE=.*#VITE_SECURE=true#g" .env
fi
fi
echo "Starting Laravel and Vite development servers..."
# Determine Vite args based on whether HTTPS is enabled
VITE_ARGS="--host 0.0.0.0 --port 5173"
if [[ "$ENABLE_HTTPS" == "true" ]]; then
echo "Starting Vite with HTTPS support..."
VITE_ARGS="$VITE_ARGS --https"
fi
# Start Vite dev server in the background with appropriate args
npm run dev -- $VITE_ARGS &
VITE_PID=$!
# Start Laravel server
php artisan serve --host=0.0.0.0 --port=8000 &
LARAVEL_PID=$!
# Handle termination
trap 'kill $VITE_PID $LARAVEL_PID; exit' SIGINT SIGTERM
# Keep the script running
echo "Development servers started:"
echo "- Laravel: http://localhost:8000"
if [[ "$ENABLE_HTTPS" == "true" ]]; then
echo "- Vite: https://localhost:5173"
else
echo "- Vite: http://localhost:5173"
fi
echo "Press Ctrl+C to stop both servers."
# Wait for both processes
wait $VITE_PID $LARAVEL_PID