From bb90268569dff525824787b7f22bdc66c7e0d4f3 Mon Sep 17 00:00:00 2001 From: Dennis Heinrich Date: Fri, 5 Apr 2024 23:51:04 +0000 Subject: [PATCH] =?UTF-8?q?Anpassung=20f=C3=BCr=20die=20Installation=20in?= =?UTF-8?q?=20DevContainern?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .devcontainer/Dockerfile | 4 --- .../{settings.json => devcontainer.json} | 9 ++++++ README.md | 1 + justfile | 28 +++++++++++++------ 4 files changed, 29 insertions(+), 13 deletions(-) rename .devcontainer/{settings.json => devcontainer.json} (81%) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 03214c2..385dd18 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -28,10 +28,6 @@ RUN apt-get install ./ddev.deb -y && rm ./ddev.deb # Install the `just` command runner RUN curl --proto '=https' --tlsv1.2 -sSf https://just.systems/install.sh | bash -s -- --to /bin -# Install `node` and `npm` -RUN curl -fsSL https://deb.nodesource.com/setup_16.x | bash - && \ - apt-get install -y nodejs - # Create an developer user with passwordless sudo RUN useradd -m -s /bin/bash developer && \ echo 'developer:developer' | chpasswd diff --git a/.devcontainer/settings.json b/.devcontainer/devcontainer.json similarity index 81% rename from .devcontainer/settings.json rename to .devcontainer/devcontainer.json index 6a9b727..70fc1a5 100644 --- a/.devcontainer/settings.json +++ b/.devcontainer/devcontainer.json @@ -3,6 +3,7 @@ "dockerFile": "Dockerfile", "workspaceMount": "source=${localWorkspaceFolder}/.,target=/workspace,type=bind,consistency=cached", "workspaceFolder": "/workspace", + "postStartCommand": "just install_url='CODESPACE'", "mounts": [ "source=${localWorkspaceFolder},target=/workspace,type=bind,consistency=cached" ], @@ -25,5 +26,13 @@ "DEVSENSE.phptools-vscode" ] } + }, + "portsAttributes": { + "8027": { + "label": "Mailpit" + }, + "8080": { + "label": "Webserver" + } } } \ No newline at end of file diff --git a/README.md b/README.md index 1713251..3f46853 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,7 @@ just uninstall | `install_demo_products` | `10` | Falls die Demo-Daten installiert werden: Anzahl der zu generierenden Produkte | | `install_demo_categories` | `3` | Falls die Demo-Daten installiert werden: Anzahl zu generierenden der Kategorien | | `install_demo_manufacturers` | `3` | Falls die Demo-Daten installiert werden: Anzahl der zu generierenden Hersteller | +| `install_url` | `https://jtl-shop-**X.X.X**.ddev.site` | Die URL über die | ### Befehle für den DDEV-Entwicklungsserver diff --git a/justfile b/justfile index 391d9bb..3ee71cc 100644 --- a/justfile +++ b/justfile @@ -4,6 +4,7 @@ install_demo := "true" install_demo_products := "10" install_demo_categories := "3" install_demo_manufacturers := "3" +install_url := "https://jtl-shop-"+shop_version+".ddev.site" # Installiert den Shop mit den angegebenen Werten [linux] @@ -23,7 +24,7 @@ install: @echo "Konfiguriere die Entwicklungsumgebung" just ddev-configuration @echo "Installiere den Shop automatisch und lösche das Installationsverzeichnis" - just run-installer + just install_url="{{install_url}}" run-installer [private] [linux] @@ -71,16 +72,25 @@ describe: echo "Keine Konfiguration gefunden, bitte zuerst 'just install' ausführen."; \ fi -[private] run-installer: - @echo "\r\nInstalliere die Datenbank..." - @curl --silent -X POST -k -H 'Content-Type: application/x-www-form-urlencoded' -d 'admin[name]=admin&admin[pass]=admin&admin[locale]=de&wawi[name]=sync&wawi[pass]=sync&db[host]=db&db[pass]=db&db[socket]=&db[user]=db&db[name]=db&demoProducts={{install_demo_products}}&demoCategories={{install_demo_categories}}&demoManufacturers={{install_demo_manufacturers}}' https://jtl-shop-{{shop_version}}.ddev.site/install/install.php?task=doinstall - @if [ {{install_demo}} = "true" ]; then \ - curl --silent -X POST -k -H 'Content-Type: application/x-www-form-urlencoded' -d 'admin[name]=admin&admin[pass]=admin&admin[locale]=de&wawi[name]=sync&wawi[pass]=sync&db[host]=db&db[pass]=db&db[socket]=&db[user]=db&db[name]=db&demoProducts={{install_demo_products}}&demoCategories={{install_demo_categories}}&demoManufacturers={{install_demo_manufacturers}}' https://jtl-shop-{{shop_version}}.ddev.site/install/install.php?task=installdemodata; \ + #!/usr/bin/env bash + set -euxo pipefail + install_url_interpreted="" + if [ {{install_url}} = "CODESPACE" ]; then + install_url_interpreted="https://"$(jq -r ".CODESPACE_NAME" /workspaces/.codespaces/shared/environment-variables.json)"-8080.app.github.dev" + else + install_url_interpreted={{install_url}} + fi + curl -X POST -k -H 'Content-Type: application/x-www-form-urlencoded' -d 'admin[name]=admin&admin[pass]=admin&admin[locale]=de&wawi[name]=sync&wawi[pass]=sync&db[host]=db&db[pass]=db&db[socket]=&db[user]=db&db[name]=db&demoProducts={{install_demo_products}}&demoCategories={{install_demo_categories}}&demoManufacturers={{install_demo_manufacturers}}' $install_url_interpreted/install/install.php?task=doinstall + if [ {{install_demo}} = "true" ]; then \ + curl -X POST -k -H 'Content-Type: application/x-www-form-urlencoded' -d 'admin[name]=admin&admin[pass]=admin&admin[locale]=de&wawi[name]=sync&wawi[pass]=sync&db[host]=db&db[pass]=db&db[socket]=&db[user]=db&db[name]=db&demoProducts={{install_demo_products}}&demoCategories={{install_demo_categories}}&demoManufacturers={{install_demo_manufacturers}}' $install_url_interpreted/install/install.php?task=installdemodata; \ + fi + if [ {{install_url}} = "CODESPACE" ]; then + file_path="path/to/your/file.php" + sed -i "s|define('URL_SHOP', 'https://localhost');|define('URL_SHOP', '$install_url_interpreted');|g" ./shop/includes/config.JTL-Shop.ini.php fi clear - @echo "Installation erfolgreich abgeschlossen." - @echo "Erreichbar unter: https://jtl-shop-{{shop_version}}.ddev.site" + echo "Erreichbar unter: "$install_url_interpreted [private] copy-installer: @@ -90,6 +100,6 @@ copy-installer: [private] ddev-configuration: - ddev config --php-version {{php_version}} --project-type php --docroot ./shop --project-name jtl-shop-{{shop_version}} + ddev config --php-version {{php_version}} --project-type php --docroot ./shop --project-name jtl-shop-{{shop_version}} --webserver-type apache-fpm ddev start ddev exec composer install --working-dir=./shop/includes \ No newline at end of file