@@ -23,27 +23,44 @@ if [ -d "$PROJECT_PATH" ]; then
2323 fi
2424fi
2525
26+ set_free_port () {
27+ FREE_PORT_SITE=$( comm -23 <( { echo 80; seq 9080 9100; }) <( nmap --min-hostgroup 100 -p 80,9080-9100 -sS -n -T4 host.docker.internal | grep ' open' | awk ' {print $1}' | cut -d' /' -f1) | head -n 1)
28+ FREE_PORT_SITE_HTTPS=$( comm -23 <( { echo 443; seq 8080 8100; }) <( nmap --min-hostgroup 100 -p 443,8080-8100 -sS -n -T4 host.docker.internal | grep ' open' | awk ' {print $1}' | cut -d' /' -f1) | head -n 1)
29+ sed -i " s/80:80/${FREE_PORT_SITE} :80/g" compose.yaml
30+ sed -i " s/443:443/${FREE_PORT_SITE_HTTPS} :443/g" compose.yaml
31+
32+ URL_SITE=https://localhost
33+
34+ if [ " ${FREE_PORT_SITE_HTTPS} " -ne 443 ]; then
35+ URL_SITE=${URL_SITE} :${FREE_PORT_SITE_HTTPS}
36+ fi
37+ }
38+
2639echo " Creating new Stochastix project in './${PROJECT_NAME} '..."
2740mkdir -p " $PROJECT_PATH /frankenphp/conf.d"
2841
2942# Copy the template files from the image into the new project directory
30- echo " Scaffolding project files..."
43+ echo " Preparing project files..."
3144cp /templates/compose.yaml " ${PROJECT_PATH} /compose.yaml"
3245cp /templates/compose.override.yaml " ${PROJECT_PATH} /compose.override.yaml"
3346cp /templates/.editorconfig " ${PROJECT_PATH} /.editorconfig"
3447cp /templates/.gitattributes " ${PROJECT_PATH} /.gitattributes"
3548cp /templates/frankenphp/Caddyfile " ${PROJECT_PATH} /frankenphp/Caddyfile"
3649cp /templates/frankenphp/conf.d/20-app.dev.ini " ${PROJECT_PATH} /frankenphp/conf.d/20-app.dev.ini"
3750
51+ echo
3852echo " ✅ Project files created."
39- echo " 🚀 Installing Stochastix... (This may take 3 to 10 minutes depending on your internet connection)"
53+ echo " 🚀 Installing Stochastix..."
54+ echo
4055
4156# Use the mounted Docker socket to run docker-compose on the host machine,
4257# specifying the project directory for context.
4358docker run --rm -it -v " ${HOST_PWD} /${PROJECT_NAME} :/app" ghcr.io/phpquant/stochastix:latest php --version
44- docker compose -p " ${PROJECT_NAME} " -f " ${PROJECT_PATH} /compose.yaml" up -d
59+ cd " ${PROJECT_PATH} "
60+ set_free_port
61+ ABS_PATH=" ${HOST_PWD} /${PROJECT_NAME} " docker compose up -d
4562
4663echo
4764echo " ✅ Stochastix is running!"
48- echo " You can now access the UI at https://localhost ."
65+ echo " You can now access the UI at ${URL_SITE} ."
4966echo
0 commit comments