Quellcode des ICON CRM (1)
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
# ICON CRM - Deployment auf icrm.icon-experts.de (31.70.144.60)
|
||||
#
|
||||
# Gebaut wird lokal, hochgeladen werden nur dist/ und die Backend-Quellen.
|
||||
#
|
||||
# Aufruf aus dem Projektverzeichnis:
|
||||
# $env:ICON_CRM_SSH_PASSWORD = '...'
|
||||
# powershell -File deploy/deploy.ps1
|
||||
# powershell -File deploy/deploy.ps1 -SkipBuild
|
||||
# powershell -File deploy/deploy.ps1 -Deps # bei neuen Backend-Paketen
|
||||
|
||||
param(
|
||||
[string]$ServerHost = '31.70.144.60',
|
||||
[int]$Port = 22,
|
||||
[string]$User = 'root',
|
||||
[string]$Password = $env:ICON_CRM_SSH_PASSWORD,
|
||||
[string]$RemotePath = '/var/www/icon_CRM',
|
||||
[switch]$SkipBuild,
|
||||
[switch]$Deps
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
if (-not $Password) {
|
||||
throw 'Kein Passwort. Setze $env:ICON_CRM_SSH_PASSWORD oder uebergib -Password.'
|
||||
}
|
||||
|
||||
$plink = 'C:\Program Files\PuTTY\plink.exe'
|
||||
$pscp = 'C:\Program Files\PuTTY\pscp.exe'
|
||||
foreach ($tool in @($plink, $pscp)) {
|
||||
if (-not (Test-Path $tool)) { throw "Nicht gefunden: $tool" }
|
||||
}
|
||||
|
||||
$projectRoot = Split-Path -Parent $PSScriptRoot
|
||||
Set-Location $projectRoot
|
||||
|
||||
if (-not $SkipBuild) {
|
||||
Write-Host '==> Frontend bauen' -ForegroundColor Yellow
|
||||
npm run build
|
||||
if ($LASTEXITCODE -ne 0) { throw 'Build fehlgeschlagen - es wird nichts hochgeladen.' }
|
||||
}
|
||||
|
||||
$target = "$User@$ServerHost"
|
||||
|
||||
Write-Host '==> dist/ hochladen' -ForegroundColor Yellow
|
||||
& $pscp -r -batch -P $Port -pw $Password 'dist' "${target}:$RemotePath/"
|
||||
|
||||
Write-Host '==> Backend hochladen' -ForegroundColor Yellow
|
||||
& $pscp -r -batch -P $Port -pw $Password 'server\src' "${target}:$RemotePath/server/"
|
||||
& $pscp -batch -P $Port -pw $Password 'server\package.json' "${target}:$RemotePath/server/"
|
||||
|
||||
$remoteCommand = "systemctl restart icon-crm-backend; sleep 3; systemctl is-active icon-crm-backend; curl -s http://127.0.0.1:5007/api/health"
|
||||
if ($Deps) {
|
||||
$remoteCommand = "cd $RemotePath/server && npm install --omit=dev --no-audit --no-fund; $remoteCommand"
|
||||
}
|
||||
|
||||
Write-Host '==> Backend neu starten und pruefen' -ForegroundColor Yellow
|
||||
& $plink -ssh -batch -P $Port -pw $Password $target $remoteCommand
|
||||
|
||||
Write-Host ''
|
||||
Write-Host 'Fertig.' -ForegroundColor Green
|
||||
@@ -0,0 +1,19 @@
|
||||
[Unit]
|
||||
Description=ICON CRM Backend (Express + MariaDB)
|
||||
After=network.target mariadb.service
|
||||
Wants=mariadb.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=root
|
||||
WorkingDirectory=/var/www/icon_CRM/server
|
||||
EnvironmentFile=/var/www/icon_CRM/server/.env
|
||||
ExecStart=/usr/bin/node src/server.js
|
||||
Restart=on-failure
|
||||
RestartSec=5
|
||||
# Der Server hat 8 GB. Die Grenze ist kein Sparzwang, sondern ein Sicherheitsnetz:
|
||||
# ein Leck im Backend soll nicht Apache und MariaDB mitreissen.
|
||||
MemoryMax=1024M
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -0,0 +1,43 @@
|
||||
# ICON CRM - Apache Vhost
|
||||
# Ablage: /etc/apache2/sites-available/icrm.icon-experts.de.conf
|
||||
# Aktivieren: a2ensite icrm.icon-experts.de && systemctl reload apache2
|
||||
#
|
||||
# Reihenfolge beim Aufsetzen:
|
||||
# 1. DNS A-Record icrm.icon-experts.de -> 31.70.144.60
|
||||
# 2. Diese Datei aktivieren (HTTP-Teil), Apache neu laden
|
||||
# 3. certbot --apache -d icrm.icon-experts.de (legt den :443-Block selbst an)
|
||||
|
||||
<VirtualHost *:80>
|
||||
ServerName icrm.icon-experts.de
|
||||
DocumentRoot /var/www/icon_CRM/dist
|
||||
|
||||
<Directory /var/www/icon_CRM/dist>
|
||||
Options -Indexes +FollowSymLinks
|
||||
AllowOverride None
|
||||
Require all granted
|
||||
# Single Page Application: alle unbekannten Pfade auf index.html
|
||||
FallbackResource /index.html
|
||||
</Directory>
|
||||
|
||||
# Die mit Hash benannten Build-Dateien aendern sich nie - die darf der
|
||||
# Browser dauerhaft behalten. index.html dagegen nie, sonst sieht ein
|
||||
# Benutzer nach dem Rollout weiter die alte Anwendung.
|
||||
<IfModule mod_expires.c>
|
||||
ExpiresActive On
|
||||
<FilesMatch "\.(js|css|woff2|png|jpg|svg|ico)$">
|
||||
ExpiresDefault "access plus 1 year"
|
||||
</FilesMatch>
|
||||
</IfModule>
|
||||
<FilesMatch "index\.html$">
|
||||
Header set Cache-Control "no-cache, must-revalidate"
|
||||
</FilesMatch>
|
||||
|
||||
# Die API laeuft lokal auf 127.0.0.1:5007 und ist von aussen
|
||||
# ausschliesslich hierueber erreichbar.
|
||||
ProxyPreserveHost On
|
||||
ProxyPass /api http://127.0.0.1:5007/api
|
||||
ProxyPassReverse /api http://127.0.0.1:5007/api
|
||||
|
||||
ErrorLog ${APACHE_LOG_DIR}/icon_crm_error.log
|
||||
CustomLog ${APACHE_LOG_DIR}/icon_crm_access.log combined
|
||||
</VirtualHost>
|
||||
Reference in New Issue
Block a user