Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ composer require shopware/docker shopware/deployment-helper fyrst/shopware-cd
- **Local:** `shopware-cli project dev` and the CLI-managed shop-root `compose.yaml`. Live → laptop uploads: `fyrst-cli shopware sync local` (`--data all` is refused).
- **VPS/CD:** files under `deploy/` (Compose templates, edge). CI runs `fyrst-cli shopware deploy release`. Dump stays `shopware-cli project dump`. Create and image build stay out of this recipe.

Flex copies CI, `deploy/` (CD Compose, edge), `.dockerignore`, and `.env.example` from the package `overlay/` into the shop root. The Flex `env` configurator may append a `###> fyrst/shopware-cd ###` block to `.env` (empty shop id, `SHOPWARE_DEPLOY_ENV=live`, `SHOPWARE_DATA_BASE=/var/lib/shopware/data`). It does not overwrite create’s whole `.env` and does not put secrets in that block. Then run `fyrst-cli shopware env init --shop-id <slug>` (VPS: add `--vps`; see `deploy/README.md`). That command does not generate `APP_SECRET` (`shopware-cli project create` already writes it). Install [fyrst-cli](https://github.com/fyrst-dev/cli) 0.1.0+ on each VPS. Commit the copied files; `vendor/` stays gitignored.
Flex copies CI, `deploy/` (CD Compose, edge), `.dockerignore`, and `.env.example` from the package `overlay/` into the shop root. The Flex `env` configurator may append a `###> fyrst/shopware-cd ###` block to `.env` (empty shop id, `SHOPWARE_DEPLOY_ENV=live`, `SHOPWARE_DATA_BASE=/var/lib/shopware/data`). It does not overwrite create’s whole `.env` and does not put secrets in that block. Then run `fyrst-cli shopware env init --shop-id <slug>` (see `deploy/README.md`). That command always comments out create’s `COMPOSE_PROJECT_NAME` (laptop and VPS same). It does not generate `APP_SECRET` (`shopware-cli project create` already writes it). Install [fyrst-cli](https://github.com/fyrst-dev/cli) 0.1.0+ on each VPS. Commit the copied files; `vendor/` stays gitignored.

## Update recipes

Expand Down
4 changes: 2 additions & 2 deletions fyrst/shopware-cd/1.0/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ docker compose --env-file .env -f deploy/compose.yaml -f deploy/compose.prod.yam

CI runs `fyrst-cli shopware deploy release` (existing `IMAGE` / `IMAGE_TAG` / `COMPOSE_DIR`). Rollback is `fyrst-cli shopware deploy rollback`.

Flex `env` may append a `###> fyrst/shopware-cd ###` block to shop-root `.env` (empty `SHOPWARE_SHOP_ID`, `SHOPWARE_DEPLOY_ENV=live`, `SHOPWARE_DATA_BASE=/var/lib/shopware/data`). It does not overwrite create’s whole `.env`. Then run `fyrst-cli shopware env init --shop-id <slug>` (see the copied `deploy/README.md`). That command does not generate `APP_SECRET` (`shopware-cli project create` already writes it). Install fyrst-cli 0.1.0+ on each VPS.
Flex `env` may append a `###> fyrst/shopware-cd ###` block to shop-root `.env` (empty `SHOPWARE_SHOP_ID`, `SHOPWARE_DEPLOY_ENV=live`, `SHOPWARE_DATA_BASE=/var/lib/shopware/data`). It does not overwrite create’s whole `.env`. Then run `fyrst-cli shopware env init --shop-id <slug>` (see the copied `deploy/README.md`). That command always comments out create’s `COMPOSE_PROJECT_NAME=sw-shop-…` line (laptop and VPS same; it overrides Compose `name:`). It does not generate `APP_SECRET` (`shopware-cli project create` already writes it). Install fyrst-cli 0.1.0+ on each VPS.

VPS runtime DB + bind-mount pull (no object storage): `fyrst-cli shopware sync {capture|apply|pull}` — see `deploy/sync-runtime.md`. **Dump stays `shopware-cli project dump`.** **Sync is not a backup** — live backups are `fyrst-cli shopware backup {create|prune|recover}`. Compose source of truth is `SHOPWARE_SHOP_ID` + `SHOPWARE_DEPLOY_ENV` (project name `acme-live`, uploads under `/var/lib/shopware/data/${SHOPWARE_SHOP_ID}/${SHOPWARE_DEPLOY_ENV}`). `COMPOSE_PROJECT_NAME` / `SHOPWARE_DATA_ROOT` are optional script overrides. **VPS:** comment out create’s `COMPOSE_PROJECT_NAME=sw-shop-…` line (`fyrst-cli shopware env init --vps` or by hand; it overrides Compose `name:`). Flex does not delete it on `composer require`. Same-host tag-and-load: `PULL_POLICY=never` / `SKIP_PULL=1`.
VPS runtime DB + bind-mount pull (no object storage): `fyrst-cli shopware sync {capture|apply|pull}` — see `deploy/sync-runtime.md`. **Dump stays `shopware-cli project dump`.** **Sync is not a backup** — live backups are `fyrst-cli shopware backup {create|prune|recover}`. Compose source of truth is `SHOPWARE_SHOP_ID` + `SHOPWARE_DEPLOY_ENV` (project name `acme-live`, uploads under `/var/lib/shopware/data/${SHOPWARE_SHOP_ID}/${SHOPWARE_DEPLOY_ENV}`). `COMPOSE_PROJECT_NAME` / `SHOPWARE_DATA_ROOT` are optional script overrides. Flex does not delete it on `composer require`. Same-host tag-and-load: `PULL_POLICY=never` / `SKIP_PULL=1`.

Prod HTTP is loopback-only; host TLS is `deploy/edge/Caddyfile`. `web` healthcheck is `GET /api/_info/health-check` on `127.0.0.1:8000` inside the container.

Expand Down
10 changes: 6 additions & 4 deletions fyrst/shopware-cd/1.0/post-install.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@
and does not put secrets in that block. Then run
<comment>fyrst-cli shopware env init --shop-id …</comment>
(see <comment>deploy/README</comment>).
That command does not generate <comment>APP_SECRET</comment>
That command always comments out create’s
<comment>COMPOSE_PROJECT_NAME</comment> (laptop and VPS same).
It does not generate <comment>APP_SECRET</comment>
(<comment>shopware-cli project create</comment> already writes it).
VPS <comment>.env</comment> source of truth (required):
<comment>SHOPWARE_SHOP_ID</comment> (same slug on live + staging + laptop),
Expand All @@ -65,8 +67,8 @@
<comment>.env</comment> for local <comment>project dev</comment>. That env var
overrides Compose <comment>name:</comment>
(<comment>${SHOPWARE_SHOP_ID}-${SHOPWARE_DEPLOY_ENV}</comment>).
On the VPS, comment out that line
(<comment>fyrst-cli shopware env init --vps</comment> or by hand).
<comment>fyrst-cli shopware env init</comment> always comments out
that line (laptop and VPS same).
Flex does not delete it on <comment>composer require</comment>
(create owns the local flow).
Bootstrap:
Expand Down Expand Up @@ -95,7 +97,7 @@
Flex may append SoT keys to <comment>.env</comment>; it does not
overwrite create’s whole <comment>.env</comment>. Then run
<comment>fyrst-cli shopware env init --shop-id …</comment>
(VPS: add <comment>--vps</comment>; see <comment>deploy/README</comment>).
(see <comment>deploy/README</comment>).
If <comment>.env</comment> is missing, that command copies
<comment>.env.example</comment> first. Commit the copied files;
<comment>vendor/</comment> is gitignored.
Expand Down
88 changes: 68 additions & 20 deletions fyrst/shopware-cd/1.0/tests/init-env.test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,34 @@ out="$(fyrst-cli shopware env init --help 2>&1)"
rc=$?
set -e
if [[ "$rc" -eq 0 ]] && printf '%s' "$out" | grep -q -- '--shop-id' \
&& printf '%s' "$out" | grep -q -- '--vps' \
&& printf '%s' "$out" | grep -q -- '--dry-run' \
&& printf '%s' "$out" | grep -q 'APP_SECRET' \
&& printf '%s' "$out" | grep -q 'COMPOSE_PROJECT_NAME' \
&& ! printf '%s' "$out" | grep -q -- '--vps' \
&& ! printf '%s' "$out" | grep -q 'generate-app-secret'; then
pass "--help lists identity flags; APP_SECRET is not generated"
pass "--help lists identity flags; always-strip; no --vps"
else
fail "--help rc=$rc out=$out"
fi

echo "==> recipe docs omit --generate-app-secret"
echo "==> recipe docs omit --vps / --generate-app-secret; always-strip"
REPO_README="$(cd "$ROOT/../../.." && pwd)/README.md"
if ! grep -q 'generate-app-secret' "$ROOT/post-install.txt" \
&& ! grep -q 'generate-app-secret' "$ROOT/README.md" \
&& ! grep -q -- '--vps' "$ROOT/post-install.txt" \
&& ! grep -q -- '--vps' "$ROOT/README.md" \
&& ! grep -q -- '--vps' "$REPO_README" \
&& grep -q 'APP_SECRET' "$ROOT/post-install.txt" \
&& grep -q 'APP_SECRET' "$ROOT/README.md"; then
pass "recipe docs say env init leaves APP_SECRET alone"
&& grep -q 'APP_SECRET' "$ROOT/README.md" \
&& grep -q 'always comments out' "$ROOT/post-install.txt" \
&& grep -q 'always comments out' "$ROOT/README.md" \
&& grep -q 'always comments out' "$REPO_README" \
&& grep -q 'laptop and VPS same' "$ROOT/post-install.txt" \
&& grep -q 'laptop and VPS same' "$ROOT/README.md" \
&& grep -q 'laptop and VPS same' "$REPO_README"; then
pass "recipe docs: always-strip COMPOSE_PROJECT_NAME; laptop and VPS same"
else
fail "recipe docs missing APP_SECRET contract or still mention --generate-app-secret"
fail "recipe docs still mention --vps / --generate-app-secret or miss always-strip"
fi

echo "==> manifest Flex env (safe defaults) + copy-from-package"
Expand Down Expand Up @@ -78,7 +89,7 @@ else
fail "missing both files rc=$rc out=$out"
fi

echo "==> dry-run does not write; real run merges + sets shop id + --vps"
echo "==> dry-run does not write; real run always comments COMPOSE_PROJECT_NAME"
SHOP="$TMP/acme"
mkdir -p "$SHOP"
write_stub_env_example "$SHOP"
Expand All @@ -99,18 +110,19 @@ EOF
cp "$SHOP/.env" "$SHOP/.env.before"

set +e
out="$(COMPOSE_DIR="$SHOP" fyrst-cli shopware env init --shop-id acme --env live --vps --image ghcr.io/example/acme --dry-run 2>&1)"
out="$(COMPOSE_DIR="$SHOP" fyrst-cli shopware env init --shop-id acme --env live --image ghcr.io/example/acme --dry-run 2>&1)"
rc=$?
set -e
if [[ "$rc" -eq 0 ]] && printf '%s' "$out" | grep -q 'DRY-RUN' \
&& printf '%s' "$out" | grep -q 'SHOPWARE_SHOP_ID=acme' \
&& printf '%s' "$out" | grep -q 'COMPOSE_PROJECT_NAME' \
&& printf '%s' "$out" | grep -q 'IMAGE=ghcr.io/example/acme' \
&& printf '%s' "$out" | grep -q 'APP_SECRET' \
&& ! printf '%s' "$out" | grep -q -- '--vps' \
&& ! printf '%s' "$out" | grep -q 'generate-app-secret' \
&& ! printf '%s' "$out" | grep -q 'set APP_SECRET' \
&& ! printf '%s' "$out" | grep -q 'oldsecret'; then
pass "dry-run summary sets shop id, image, and leaves APP_SECRET alone"
pass "dry-run summary sets shop id, image, and always-strip without --vps"
else
fail "dry-run rc=$rc out=$out"
fi
Expand All @@ -121,13 +133,14 @@ else
fi

set +e
out="$(COMPOSE_DIR="$SHOP" fyrst-cli shopware env init --shop-id acme --env live --vps --image ghcr.io/example/acme 2>&1)"
out="$(COMPOSE_DIR="$SHOP" fyrst-cli shopware env init --shop-id acme --env live --image ghcr.io/example/acme 2>&1)"
rc=$?
set -e
if [[ "$rc" -eq 0 ]] && printf '%s' "$out" | grep -q 'SHOPWARE_SHOP_ID=acme' \
&& printf '%s' "$out" | grep -q 'commented' \
&& printf '%s' "$out" | grep -q 'COMPOSE_PROJECT_NAME'; then
pass "real run summary sets shop id and comments COMPOSE_PROJECT_NAME"
&& printf '%s' "$out" | grep -q 'COMPOSE_PROJECT_NAME' \
&& ! printf '%s' "$out" | grep -q -- '--vps'; then
pass "real run summary sets shop id and always comments COMPOSE_PROJECT_NAME"
else
fail "real run rc=$rc out=$out"
fi
Expand All @@ -148,12 +161,12 @@ else
fail "clobbered operator secrets"
fi
if grep -q '^# COMPOSE_PROJECT_NAME=sw-shop-acme' "$envf" \
&& grep -q 'restore for local project dev' "$envf" \
&& ! grep -q -- '--vps' "$envf" \
&& ! grep -q '^COMPOSE_PROJECT_NAME=' "$envf" \
&& ! grep -q '^COMPOSE_PROJECT_NAME=$' "$envf"; then
pass "--vps comments COMPOSE_PROJECT_NAME and does not leave COMPOSE_PROJECT_NAME="
pass "always comments COMPOSE_PROJECT_NAME and does not leave COMPOSE_PROJECT_NAME="
else
fail "--vps did not comment COMPOSE_PROJECT_NAME correctly: $(grep COMPOSE_PROJECT_NAME "$envf" || true)"
fail "did not comment COMPOSE_PROJECT_NAME correctly: $(grep COMPOSE_PROJECT_NAME "$envf" || true)"
fi
if grep -q '^HTTP_PORT=' "$envf" && grep -q '^MYSQL_DATABASE=' "$envf"; then
pass "merged missing keys from .env.example"
Expand Down Expand Up @@ -259,16 +272,51 @@ else
fail "generate-app-secret still accepted rc=$rc secret2=$secret2 out=$out"
fi

echo "==> --vps is idempotent (already commented)"
echo "==> laptop env init also comments COMPOSE_PROJECT_NAME"
LAP="$TMP/laptop"
mkdir -p "$LAP"
write_stub_env_example "$LAP"
cat >"$LAP/.env" <<'EOF'
SHOPWARE_SHOP_ID=
SHOPWARE_DEPLOY_ENV=dev
COMPOSE_PROJECT_NAME=sw-shop-widgets
EOF
set +e
out="$(COMPOSE_DIR="$LAP" fyrst-cli shopware env init --shop-id widgets 2>&1)"
rc=$?
set -e
if [[ "$rc" -eq 0 ]] && grep -q '^# COMPOSE_PROJECT_NAME=sw-shop-widgets' "$LAP/.env" \
&& grep -q '^SHOPWARE_DEPLOY_ENV=dev$' "$LAP/.env" \
&& ! grep -q '^COMPOSE_PROJECT_NAME=' "$LAP/.env" \
&& printf '%s' "$out" | grep -q 'commented' \
&& ! printf '%s' "$out" | grep -q -- '--vps'; then
pass "laptop env init comments COMPOSE_PROJECT_NAME (same as VPS)"
else
fail "laptop always-strip rc=$rc out=$out env=$(grep COMPOSE_PROJECT_NAME "$LAP/.env" || true)"
fi

echo "==> --vps is rejected"
set +e
out="$(COMPOSE_DIR="$SHOP" fyrst-cli shopware env init --shop-id acme --vps 2>&1)"
rc=$?
set -e
count="$(grep -c 'commented by deploy/init-env.sh --vps' "$SHOP/.env" || true)"
if [[ "$rc" -eq 0 && "$count" -eq 1 ]] && printf '%s' "$out" | grep -q 'no uncommented COMPOSE_PROJECT_NAME'; then
pass "second --vps does not double-comment"
if [[ "$rc" -ne 0 ]] && printf '%s' "$out" | grep -qiE 'unexpected argument|unexpected'; then
pass "--vps is rejected"
else
fail "--vps still accepted rc=$rc out=$out"
fi

echo "==> always-strip is idempotent (already commented)"
set +e
out="$(COMPOSE_DIR="$SHOP" fyrst-cli shopware env init --shop-id acme 2>&1)"
rc=$?
set -e
count="$(grep -c '^# COMPOSE_PROJECT_NAME=sw-shop-acme' "$SHOP/.env" || true)"
if [[ "$rc" -eq 0 && "$count" -eq 1 ]] && printf '%s' "$out" | grep -q 'no uncommented COMPOSE_PROJECT_NAME' \
&& ! printf '%s' "$out" | grep -q -- '--vps'; then
pass "second env init does not double-comment COMPOSE_PROJECT_NAME"
else
fail "idempotent --vps rc=$rc count=$count out=$out"
fail "idempotent always-strip rc=$rc count=$count out=$out"
fi

if [[ "$FAILS" -ne 0 ]]; then
Expand Down
16 changes: 12 additions & 4 deletions fyrst/shopware-cd/1.0/tests/vps-hardening.test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -264,11 +264,19 @@ if grep -q 'does not delete it' "$ROOT/post-install.txt" \
else
fail "docs missing do-not-auto-delete wording"
fi
if grep -q 'env init --vps' "$ROOT/post-install.txt" \
&& grep -q 'env init --vps' "$ROOT/README.md"; then
pass "docs point at fyrst-cli shopware env init --vps for the VPS footgun"
if ! grep -q -- '--vps' "$ROOT/post-install.txt" \
&& ! grep -q -- '--vps' "$ROOT/README.md"; then
pass "docs do not mention --vps"
else
fail "docs missing env init --vps"
fail "docs still mention --vps"
fi
if grep -q 'always comments out' "$ROOT/post-install.txt" \
&& grep -q 'always comments out' "$ROOT/README.md" \
&& grep -q 'laptop and VPS same' "$ROOT/post-install.txt" \
&& grep -q 'laptop and VPS same' "$ROOT/README.md"; then
pass "docs say env init always comments COMPOSE_PROJECT_NAME (laptop and VPS same)"
else
fail "docs missing always-strip COMPOSE_PROJECT_NAME wording"
fi
if grep -q 'env init --shop-id' "$ROOT/post-install.txt"; then
pass "post-install documents Flex env + env init --shop-id"
Expand Down
27 changes: 25 additions & 2 deletions fyrst/shopware-cd/1.0/tests/wrappers.test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,27 @@ do
fi
done

echo "==> env init always-strip; --vps gone"
set +e
out="$(fyrst-cli shopware env init --help 2>&1)"
rc=$?
set -e
if [[ "$rc" -eq 0 ]] && ! printf '%s' "$out" | grep -q -- '--vps' \
&& printf '%s' "$out" | grep -q 'COMPOSE_PROJECT_NAME'; then
pass "env init --help has no --vps; documents COMPOSE_PROJECT_NAME"
else
fail "env init --help still lists --vps rc=$rc out=$out"
fi
set +e
out="$(fyrst-cli shopware env init --vps 2>&1)"
rc=$?
set -e
if [[ "$rc" -ne 0 ]] && printf '%s' "$out" | grep -qiE 'unexpected argument|unexpected'; then
pass "env init rejects --vps"
else
fail "env init still accepts --vps rc=$rc out=$out"
fi

echo "==> sync local --data all stays rejected"
TMP="$(mktemp -d)"
trap 'rm -rf "$TMP"' EXIT
Expand Down Expand Up @@ -135,11 +156,13 @@ if grep -q 'fyrst-cli shopware deploy release' "$ROOT/post-install.txt" \
&& ! grep -q 'bash deploy/sync-runtime.sh' "$ROOT/post-install.txt" \
&& ! grep -q 'generate-app-secret' "$ROOT/post-install.txt" \
&& ! grep -q 'generate-app-secret' "$ROOT/README.md" \
&& ! grep -q -- '--vps' "$ROOT/post-install.txt" \
&& ! grep -q -- '--vps' "$ROOT/README.md" \
&& ! grep -q 'copy-from-recipe' "$ROOT/manifest.json" \
&& grep -q 'copy-from-package' "$ROOT/README.md"; then
pass "recipe docs are fyrst-cli lifecycle verbs (no wrappers / copy-from-recipe)"
pass "recipe docs are fyrst-cli lifecycle verbs (no wrappers / --vps / copy-from-recipe)"
else
fail "recipe docs still document bash wrappers, copy-from-recipe, or --generate-app-secret"
fail "recipe docs still document bash wrappers, copy-from-recipe, --vps, or --generate-app-secret"
fi

if [[ "$FAILS" -ne 0 ]]; then
Expand Down
Loading