Anpassung für die Installation in DevContainern

This commit is contained in:
Dennis Heinrich 2024-04-05 23:51:04 +00:00
parent e52f65d0df
commit bb90268569
4 changed files with 29 additions and 13 deletions

View file

@ -28,10 +28,6 @@ RUN apt-get install ./ddev.deb -y && rm ./ddev.deb
# Install the `just` command runner # Install the `just` command runner
RUN curl --proto '=https' --tlsv1.2 -sSf https://just.systems/install.sh | bash -s -- --to /bin 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 # Create an developer user with passwordless sudo
RUN useradd -m -s /bin/bash developer && \ RUN useradd -m -s /bin/bash developer && \
echo 'developer:developer' | chpasswd echo 'developer:developer' | chpasswd

View file

@ -3,6 +3,7 @@
"dockerFile": "Dockerfile", "dockerFile": "Dockerfile",
"workspaceMount": "source=${localWorkspaceFolder}/.,target=/workspace,type=bind,consistency=cached", "workspaceMount": "source=${localWorkspaceFolder}/.,target=/workspace,type=bind,consistency=cached",
"workspaceFolder": "/workspace", "workspaceFolder": "/workspace",
"postStartCommand": "just install_url='CODESPACE'",
"mounts": [ "mounts": [
"source=${localWorkspaceFolder},target=/workspace,type=bind,consistency=cached" "source=${localWorkspaceFolder},target=/workspace,type=bind,consistency=cached"
], ],
@ -25,5 +26,13 @@
"DEVSENSE.phptools-vscode" "DEVSENSE.phptools-vscode"
] ]
} }
},
"portsAttributes": {
"8027": {
"label": "Mailpit"
},
"8080": {
"label": "Webserver"
}
} }
} }

View file

@ -51,6 +51,7 @@ just uninstall
| `install_demo_products` | `10` | Falls die Demo-Daten installiert werden: Anzahl der zu generierenden Produkte | | `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_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_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 ### Befehle für den DDEV-Entwicklungsserver

View file

@ -4,6 +4,7 @@ install_demo := "true"
install_demo_products := "10" install_demo_products := "10"
install_demo_categories := "3" install_demo_categories := "3"
install_demo_manufacturers := "3" install_demo_manufacturers := "3"
install_url := "https://jtl-shop-"+shop_version+".ddev.site"
# Installiert den Shop mit den angegebenen Werten # Installiert den Shop mit den angegebenen Werten
[linux] [linux]
@ -23,7 +24,7 @@ install:
@echo "Konfiguriere die Entwicklungsumgebung" @echo "Konfiguriere die Entwicklungsumgebung"
just ddev-configuration just ddev-configuration
@echo "Installiere den Shop automatisch und lösche das Installationsverzeichnis" @echo "Installiere den Shop automatisch und lösche das Installationsverzeichnis"
just run-installer just install_url="{{install_url}}" run-installer
[private] [private]
[linux] [linux]
@ -71,16 +72,25 @@ describe:
echo "Keine Konfiguration gefunden, bitte zuerst 'just install' ausführen."; \ echo "Keine Konfiguration gefunden, bitte zuerst 'just install' ausführen."; \
fi fi
[private]
run-installer: run-installer:
@echo "\r\nInstalliere die Datenbank..." #!/usr/bin/env bash
@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 set -euxo pipefail
@if [ {{install_demo}} = "true" ]; then \ install_url_interpreted=""
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; \ 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 fi
clear clear
@echo "Installation erfolgreich abgeschlossen." echo "Erreichbar unter: "$install_url_interpreted
@echo "Erreichbar unter: https://jtl-shop-{{shop_version}}.ddev.site"
[private] [private]
copy-installer: copy-installer:
@ -90,6 +100,6 @@ copy-installer:
[private] [private]
ddev-configuration: 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 start
ddev exec composer install --working-dir=./shop/includes ddev exec composer install --working-dir=./shop/includes