Add run scripts and actions setup

This commit is contained in:
Jeppe Bundgaard
2026-03-12 12:27:46 +01:00
parent e7ff44bf50
commit e91dda0799
5 changed files with 122 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
# THIS IS AUTOGENERATED. DO NOT EDIT MANUALLY
version = 1
name = "api"
[setup]
script = "./scripts/setup.sh"
[setup.win32]
script = "powershell -ExecutionPolicy Bypass -File .\\scripts\\setup.ps1"
[[actions]]
name = "Start API"
icon = "run"
command = "powershell -ExecutionPolicy Bypass -File .\\scripts\\run.ps1 -Action start"
platform = "win32"
[[actions]]
name = "Stop API"
icon = "run"
command = "powershell -ExecutionPolicy Bypass -File .\\scripts\\run.ps1 -Action stop"
platform = "win32"
[[actions]]
name = "PHP logs"
icon = "debug"
command = "powershell -ExecutionPolicy Bypass -File .\\scripts\\run.ps1 -Action logs -Service php1"
platform = "win32"
[[actions]]
name = "Unit tests"
icon = "test"
command = "powershell -ExecutionPolicy Bypass -File .\\scripts\\run.ps1 -Action test"
platform = "win32"
+26
View File
@@ -0,0 +1,26 @@
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"
param(
[ValidateSet("start", "stop", "logs", "test")]
[string]$Action = "start",
[string]$Service = "php1"
)
$RootDir = Split-Path -Parent $PSScriptRoot
Set-Location $RootDir
switch ($Action) {
"start" {
docker compose up -d traefik redis php1 caddy
}
"stop" {
docker compose down
}
"logs" {
docker compose logs -f --tail=200 $Service
}
"test" {
docker compose exec -T php1 sh -lc "cd /var/www/html && composer test:unit"
}
}
+27
View File
@@ -0,0 +1,27 @@
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$ROOT_DIR"
ACTION="${1:-start}"
SERVICE="${2:-php1}"
case "$ACTION" in
start)
docker compose up -d traefik redis php1 caddy
;;
stop)
docker compose down
;;
logs)
docker compose logs -f --tail=200 "$SERVICE"
;;
test)
docker compose exec -T php1 sh -lc "cd /var/www/html && composer test:unit"
;;
*)
echo "Usage: ./scripts/run.sh [start|stop|logs <service>|test]"
exit 1
;;
esac
+18
View File
@@ -0,0 +1,18 @@
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"
$RootDir = Split-Path -Parent $PSScriptRoot
Set-Location $RootDir
if ((-not (Test-Path ".env")) -and (Test-Path ".env.example")) {
Copy-Item ".env.example" ".env"
Write-Host "Created .env from .env.example"
}
$docker = Get-Command docker -ErrorAction SilentlyContinue
if (-not $docker) {
throw "Docker is required but was not found in PATH."
}
docker compose up -d --build traefik redis php1 caddy
Write-Host "API stack started: http://localhost"
+18
View File
@@ -0,0 +1,18 @@
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$ROOT_DIR"
if [[ ! -f ".env" && -f ".env.example" ]]; then
cp .env.example .env
echo "Created .env from .env.example"
fi
if ! command -v docker >/dev/null 2>&1; then
echo "Docker is required but was not found in PATH."
exit 1
fi
docker compose up -d --build traefik redis php1 caddy
echo "API stack started: http://localhost"