This commit is contained in:
1 parent
d488162bec
commit
2b766bfd13
1 file changed
+20
-21
@@ -24,29 +24,31 @@ jobs:
|
||||
}
|
||||
trap 'error_handler $LINENO' ERR
|
||||
|
||||
# Zorg dat de permanente opslagmap buiten het project bestaat
|
||||
sudo mkdir -p /var/www/atom-media
|
||||
# Maak permanente mappen aan buiten het project voor je uploads en afbeeldingen
|
||||
sudo mkdir -p /var/www/atom-media/uploads
|
||||
sudo mkdir -p /var/www/atom-media/imaging
|
||||
sudo chown -R www-data:www-data /var/www/atom-media
|
||||
sudo chmod -R 775 /var/www/atom-media
|
||||
|
||||
# Red de huidige live uploads (nieuws, logo's) EERST voordat Git of de build iets wist
|
||||
cd /var/www/atom-nexst/
|
||||
if [ -d .next/standalone/public ]; then
|
||||
echo "Backing up current live images and uploads..."
|
||||
rsync -av --ignore-existing .next/standalone/public/ /var/www/atom-media/ || true
|
||||
fi
|
||||
|
||||
# 2. Cleanup & Git Sync
|
||||
docker image prune -f
|
||||
cd /var/www/atom-nexst/
|
||||
git config --global --add safe.directory /var/www/atom-nexst
|
||||
git remote set-url origin /docker/gitea/gitea/git/repositories/remco/epicnext-cms.git/
|
||||
|
||||
git fetch origin --prune
|
||||
git reset --hard origin/main
|
||||
|
||||
# Sluit de public map uit zodat Git clean de lokale werkmap niet leegtrekt
|
||||
git clean -fd -e .env -e .env.local -e .env.production -e .env*.local -e .next -e public
|
||||
# Sluit de specifieke mediamappen uit van git clean zodat de lokale links blijven bestaan
|
||||
git clean -fd -e .env -e .env.local -e .env.production -e .env*.local -e .next -e public/uploads -e public/imaging
|
||||
|
||||
# Zorg dat de basismap public bestaat
|
||||
mkdir -p public
|
||||
|
||||
# Herstel symlinks in de hoofdmap indien nodig
|
||||
[ -L public/uploads ] || { rm -rf public/uploads && ln -s /var/www/atom-media/uploads public/uploads; }
|
||||
[ -L public/imaging ] || { rm -rf public/imaging && ln -s /var/www/atom-media/imaging public/imaging; }
|
||||
|
||||
# Verwijder oude builds, behoud de cache voor snelheid
|
||||
find .next -mindepth 1 -maxdepth 1 ! -name 'cache' -exec rm -rf {} + 2>/dev/null || true
|
||||
|
||||
@@ -72,21 +74,19 @@ jobs:
|
||||
|
||||
# 6. Sync Standalone Bundle
|
||||
echo "Preparing standalone bundle paths..."
|
||||
|
||||
# Kopieer de schone, nieuw gebouwde public-map naar standalone
|
||||
cp -r public .next/standalone/
|
||||
cp -r .next/static .next/standalone/.next/
|
||||
cp -r node_modules/@prisma .next/standalone/node_modules/ 2>/dev/null || true
|
||||
cp .env .next/standalone/.env
|
||||
|
||||
# Kopieer nu alle bewaarde nieuws-images, logo's en uploads terug over de standalone public-map heen
|
||||
if [ -d /var/www/atom-media ]; then
|
||||
echo "Restoring all news images and uploads to production..."
|
||||
rsync -av /var/www/atom-media/ .next/standalone/public/
|
||||
fi
|
||||
# Koppel de symlinks keihard binnen de vers gebouwde standalone public-map
|
||||
rm -rf .next/standalone/public/uploads
|
||||
ln -s /var/www/atom-media/uploads .next/standalone/public/uploads
|
||||
|
||||
# 7. Permissions (GEBRACHT VÓÓR HET HERSTARTEN)
|
||||
# We forceren de rechten NU op alle gekopieerde bestanden, inclusief de teruggezette rsync-bestanden
|
||||
rm -rf .next/standalone/public/imaging
|
||||
ln -s /var/www/atom-media/imaging .next/standalone/public/imaging
|
||||
|
||||
# 7. Permissions
|
||||
sudo chown -R www-data:www-data /var/www/atom-nexst/
|
||||
sudo chmod -R g+rw /var/www/atom-nexst/
|
||||
|
||||
@@ -95,7 +95,6 @@ jobs:
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl restart atom-nexst.service
|
||||
|
||||
# Geef Node.js 3 seconden de tijd om op te starten en de databaseverbinding te openen
|
||||
sleep 3
|
||||
if ! systemctl is-active --quiet atom-nexst.service; then
|
||||
echo "ERROR: atom-nexst.service failed to start! Check logs using: journalctl -u atom-nexst.service" >&2
|
||||
|
||||
Reference in new issue
Block a user