This commit is contained in:
1 parent
61b774ce62
commit
0ea2e400bd
1 file changed
+13
-35
@@ -24,27 +24,17 @@ jobs:
|
|||||||
}
|
}
|
||||||
trap 'error_handler $LINENO' ERR
|
trap 'error_handler $LINENO' ERR
|
||||||
|
|
||||||
# Zorg dat de permanente opslagmappen buiten het project correct bestaan
|
# Zorg dat de opslagmappen bestaan
|
||||||
sudo mkdir -p /var/www/atom-media/uploads /var/www/atom-media/imaging
|
sudo mkdir -p /var/www/atom-media/uploads /var/www/atom-media/imaging /var/www/atom-media/public_assets
|
||||||
sudo chown -R www-data:www-data /var/www/atom-media
|
sudo chown -R www-data:www-data /var/www/atom-media
|
||||||
sudo chmod -R 775 /var/www/atom-media
|
sudo chmod -R 775 /var/www/atom-media
|
||||||
|
|
||||||
# 2. Cleanup & Git Sync
|
# 2. Cleanup & Git Sync
|
||||||
docker image prune -f
|
|
||||||
cd /var/www/atom-nexst/
|
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 fetch origin --prune
|
||||||
git reset --hard origin/main
|
git reset --hard origin/main
|
||||||
|
|
||||||
# Voorkom symlink-loops in de werkmap
|
|
||||||
rm -rf public/uploads public/imaging
|
|
||||||
git clean -fd -e .env -e .env.local -e .env.production -e .env*.local -e .next
|
git clean -fd -e .env -e .env.local -e .env.production -e .env*.local -e .next
|
||||||
|
|
||||||
mkdir -p public
|
|
||||||
|
|
||||||
# Verwijder oude builds, behoud de cache voor snelheid
|
|
||||||
find .next -mindepth 1 -maxdepth 1 ! -name 'cache' -exec rm -rf {} + 2>/dev/null || true
|
find .next -mindepth 1 -maxdepth 1 ! -name 'cache' -exec rm -rf {} + 2>/dev/null || true
|
||||||
|
|
||||||
# 3. Environment Sanitization
|
# 3. Environment Sanitization
|
||||||
@@ -60,47 +50,35 @@ jobs:
|
|||||||
pnpm db:migrate
|
pnpm db:migrate
|
||||||
pnpm prisma:generate
|
pnpm prisma:generate
|
||||||
|
|
||||||
# 5. Standalone Next.js Build
|
# 5. Build
|
||||||
export NEXT_DISABLE_SOURCEMAPS=1
|
|
||||||
export NEXT_TELEMETRY_DISABLED=1
|
|
||||||
export UV_THREADPOOL_SIZE=2
|
|
||||||
export SKIP_ENV_VALIDATION=true
|
|
||||||
pnpm build
|
pnpm build
|
||||||
|
|
||||||
# 6. Sync Standalone Bundle
|
# 6. Sync Standalone Bundle & Overlays
|
||||||
echo "Preparing standalone bundle paths..."
|
echo "Preparing standalone bundle paths..."
|
||||||
cp -r public .next/standalone/
|
cp -r public .next/standalone/
|
||||||
cp -r .next/static .next/standalone/.next/
|
cp -r .next/static .next/standalone/.next/
|
||||||
|
|
||||||
# Kopieer Prisma engines en schema mee voor gegarandeerde database-werking in standalone
|
|
||||||
cp -r node_modules/@prisma .next/standalone/node_modules/ 2>/dev/null || true
|
cp -r node_modules/@prisma .next/standalone/node_modules/ 2>/dev/null || true
|
||||||
cp -r prisma .next/standalone/ 2>/dev/null || true
|
|
||||||
cp .env .next/standalone/.env
|
cp .env .next/standalone/.env
|
||||||
|
|
||||||
# Harde en veilige symlinks leggen
|
# AANPASSING: Overlay dynamische assets (logo's/favicons) over de public map heen
|
||||||
|
if [ "$(ls -A /var/www/atom-media/public_assets)" ]; then
|
||||||
|
cp -r /var/www/atom-media/public_assets/* .next/standalone/public/
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Symlinks voor uploads
|
||||||
rm -rf .next/standalone/public/uploads .next/standalone/public/imaging
|
rm -rf .next/standalone/public/uploads .next/standalone/public/imaging
|
||||||
ln -sfn /var/www/atom-media/uploads .next/standalone/public/uploads
|
ln -sfn /var/www/atom-media/uploads .next/standalone/public/uploads
|
||||||
ln -sfn /var/www/atom-media/imaging .next/standalone/public/imaging
|
ln -sfn /var/www/atom-media/imaging .next/standalone/public/imaging
|
||||||
|
|
||||||
# 7. Permissions & Cache Optimalisatie
|
# 7. Permissions
|
||||||
sudo chown -R www-data:www-data /var/www/atom-nexst/
|
sudo chown -R www-data:www-data /var/www/atom-nexst/
|
||||||
sudo chmod -R g+rw /var/www/atom-nexst/
|
sudo chmod -R g+rw /var/www/atom-nexst/
|
||||||
# Zorg dat Next.js operationele cache-rechten heeft
|
|
||||||
mkdir -p .next/cache && sudo chown -R www-data:www-data .next/cache
|
|
||||||
|
|
||||||
# 8. Restart & Robust Status Check
|
# 8. Restart
|
||||||
echo "Restarting systemd service gracefully..."
|
|
||||||
sudo systemctl daemon-reload
|
|
||||||
sudo systemctl restart atom-nexst.service
|
sudo systemctl restart atom-nexst.service
|
||||||
|
|
||||||
sleep 3
|
sleep 3
|
||||||
if ! systemctl is-active --quiet atom-nexst.service; then
|
if ! systemctl is-active --quiet atom-nexst.service; then
|
||||||
echo "--------------------------------------------------------" >&2
|
echo "ERROR: Service failed to start!" >&2
|
||||||
echo "CRITICAL ERROR: atom-nexst.service failed to start!" >&2
|
|
||||||
echo "Dumping last 30 lines of systemd journal logs below:" >&2
|
|
||||||
echo "--------------------------------------------------------" >&2
|
|
||||||
sudo journalctl -u atom-nexst.service -n 30 --no-pager >&2
|
|
||||||
echo "--------------------------------------------------------" >&2
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user