mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-11-08 14:17:57 +00:00
feat(shopware): migrate to single Shopware base image and split services (web/worker/scheduler/init)
• Introduce init container and runtime-ready Dockerfile (Alpine) installing php83-gd/intl/pdo_mysql • Disable composer scripts in builder and ignore build-time ext reqs • New docker-compose template (web/worker/scheduler/opensearch) + persistent volumes • Use TRUSTED_PROXIES env; fix APP_URL formatting; set OPENSEARCH_HOST=opensearch • Replace SHOPWARE_PHP_CONTAINER refs with SHOPWARE_WEB_CONTAINER in tasks • Render and copy init.sh via volumes path • Remove old nginx/php split and legacy DB env task • Fix svc-db-postgres var: database_type now uses entity_name https://chatgpt.com/share/6907fc58-7c28-800f-a993-c207f28859c9
This commit is contained in:
49
roles/web-app-shopware/templates/init.sh.j2
Normal file
49
roles/web-app-shopware/templates/init.sh.j2
Normal file
@@ -0,0 +1,49 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
cd {{ SHOPWARE_ROOT }}
|
||||
|
||||
mkdir -p {{ SHOPWARE_ROOT }}/.infinito
|
||||
MARKER="{{ SHOPWARE_ROOT }}/.infinito/installed"
|
||||
|
||||
echo "[INIT] Checking database via PDO..."
|
||||
php -r '
|
||||
$url = getenv("DATABASE_URL");
|
||||
if (!$url) { fwrite(STDERR, "DATABASE_URL not set\n"); exit(1); }
|
||||
$p = parse_url($url);
|
||||
if (!$p || !isset($p["scheme"])) { fwrite(STDERR, "Invalid DATABASE_URL\n"); exit(1); }
|
||||
$scheme = $p["scheme"];
|
||||
if ($scheme === "mysql" || $scheme === "mariadb") {
|
||||
$host = $p["host"] ?? "localhost";
|
||||
$port = $p["port"] ?? 3306;
|
||||
$db = ltrim($p["path"] ?? "", "/");
|
||||
$user = $p["user"] ?? "";
|
||||
$pass = $p["pass"] ?? "";
|
||||
$dsn = "mysql:host=".$host.";port=".$port.";dbname=".$db.";charset=utf8mb4";
|
||||
} else {
|
||||
fwrite(STDERR, "Unsupported DB scheme: ".$scheme."\n"); exit(1);
|
||||
}
|
||||
$retries = 60;
|
||||
while ($retries-- > 0) {
|
||||
try { $pdo = new PDO($dsn, $user, $pass, [PDO::ATTR_TIMEOUT => 3]); exit(0); }
|
||||
catch (Exception $e) { sleep(2); }
|
||||
}
|
||||
fwrite(STDERR, "DB not reachable\n"); exit(1);
|
||||
'
|
||||
|
||||
if [ ! -f "$MARKER" ]; then
|
||||
echo "[INIT] Installing Shopware..."
|
||||
php -d memory_limit=1024M bin/console system:install --basic-setup --create-database --force
|
||||
php -d memory_limit=1024M bin/console database:migrate --all
|
||||
php -d memory_limit=1024M bin/console database:migrate-destructive --all
|
||||
php bin/console user:create "{{ users.administrator.username }}" \
|
||||
--admin --password="{{ users.administrator.password }}" \
|
||||
--firstName="Admin" --lastName="User" --email="{{ users.administrator.email }}" || true
|
||||
php bin/console cache:clear || true
|
||||
php bin/console dal:refresh:index || true
|
||||
touch "$MARKER"
|
||||
chown -R {{ SHOPWARE_USER }}:{{ SHOPWARE_USER }} {{ SHOPWARE_ROOT }}
|
||||
echo "[INIT] Done."
|
||||
else
|
||||
echo "[INIT] Marker found, skipping install."
|
||||
fi
|
||||
Reference in New Issue
Block a user