This commit is contained in:
1 parent
91a0f728b7
commit
7ae1d30ab8
1 file changed
+20
-36
@@ -15,8 +15,6 @@ jobs:
|
|||||||
exec 9>/var/tmp/epic_web_control_deploy.lock
|
exec 9>/var/tmp/epic_web_control_deploy.lock
|
||||||
flock -n 9 || { echo "ERROR: Another deployment is already running! Cancelling."; exit 1; }
|
flock -n 9 || { echo "ERROR: Another deployment is already running! Cancelling."; exit 1; }
|
||||||
|
|
||||||
echo "--- EPIC WEB CONTROL: Starting Auto-Cleanup & Deploy ---"
|
|
||||||
|
|
||||||
error_handler() {
|
error_handler() {
|
||||||
echo "!!! DEPLOYMENT FAILED on line $1 !!!" >&2
|
echo "!!! DEPLOYMENT FAILED on line $1 !!!" >&2
|
||||||
sudo systemctl restart atom-nexst.service || true
|
sudo systemctl restart atom-nexst.service || true
|
||||||
@@ -24,65 +22,51 @@ jobs:
|
|||||||
}
|
}
|
||||||
trap 'error_handler $LINENO' ERR
|
trap 'error_handler $LINENO' ERR
|
||||||
|
|
||||||
# Zorg dat de opslagmappen bestaan
|
# 2. Zorg dat de opslagmappen bestaan
|
||||||
sudo mkdir -p /var/www/atom-media/uploads /var/www/atom-media/imaging /var/www/atom-media/public_assets
|
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
|
# 3. Cleanup & Git Sync
|
||||||
cd /var/www/atom-nexst/
|
cd /var/www/atom-nexst/
|
||||||
git fetch origin --prune
|
git fetch origin --prune
|
||||||
git reset --hard origin/main
|
git reset --hard origin/main
|
||||||
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
|
||||||
|
|
||||||
find .next -mindepth 1 -maxdepth 1 ! -name 'cache' -exec rm -rf {} + 2>/dev/null || true
|
# 4. Build
|
||||||
|
|
||||||
# 3. Environment Sanitization
|
|
||||||
if [ -f .env ]; then
|
|
||||||
export $(grep -v '^#' .env | xargs)
|
|
||||||
export DATABASE_URL=$(echo "$DATABASE_URL" | sed 's/[&?]connect_timeout=[^&]*//g')
|
|
||||||
fi
|
|
||||||
|
|
||||||
# 4. Dependencies & Database
|
|
||||||
export PNPM_CONFIG_ONLY_BUILT_DEPENDENCIES="@parcel/watcher,@swc/core,sharp"
|
|
||||||
export PRISMA_SKIP_POSTINSTALL_GENERATE=1
|
|
||||||
pnpm install --frozen-lockfile
|
pnpm install --frozen-lockfile
|
||||||
pnpm db:migrate
|
pnpm db:migrate
|
||||||
pnpm prisma:generate
|
pnpm prisma:generate
|
||||||
|
|
||||||
# 5. Build
|
|
||||||
pnpm build
|
pnpm build
|
||||||
|
|
||||||
# 6. Sync Standalone Bundle & Overlays
|
# 5. SYNC STANDALONE (De 'Force Overlay' Methode)
|
||||||
echo "Preparing standalone bundle paths..."
|
echo "Syncing standalone bundle..."
|
||||||
|
|
||||||
# Maak mapstructuur
|
# Basis files voor standalone
|
||||||
mkdir -p .next/standalone/public
|
|
||||||
|
|
||||||
# Kopieer de nodige build-bestanden
|
|
||||||
cp -r .next/static .next/standalone/.next/
|
cp -r .next/static .next/standalone/.next/
|
||||||
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 .env .next/standalone/.env
|
cp .env .next/standalone/.env
|
||||||
|
|
||||||
# Kopieer ALLES uit je public map (inclusief verborgen bestanden en submappen)
|
# Kopieer repo public map (statische broncode)
|
||||||
# De (.) zorgt ervoor dat ook verborgen bestanden (.well-known, etc) mee gaan
|
cp -rf public/. .next/standalone/public/
|
||||||
cp -a public/. .next/standalone/public/
|
|
||||||
|
# FORCE OVERLAY: Koppel de media mappen direct
|
||||||
|
# We verwijderen de kopieën en leggen links naar de veilige opslag
|
||||||
|
rm -rf .next/standalone/public/uploads
|
||||||
|
rm -rf .next/standalone/public/imaging
|
||||||
|
rm -rf .next/standalone/public/public_assets
|
||||||
|
|
||||||
# Leg de symlinks naar de veilige opslagplek (deze overschrijven lokale kopieën indien aanwezig)
|
|
||||||
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
|
||||||
ln -sfn /var/www/atom-media/public_assets .next/standalone/public/public_assets
|
ln -sfn /var/www/atom-media/public_assets .next/standalone/public/public_assets
|
||||||
|
|
||||||
# 7. Permissions
|
# DIT IS DE FIX VOOR JE FAVICON EN LOGO:
|
||||||
sudo chown -R www-data:www-data /var/www/atom-nexst/
|
# Kopieer ALLES uit je veilige opslag direct naar de public folder van standalone
|
||||||
sudo chmod -R g+rw /var/www/atom-nexst/
|
# Zo kan Next.js ze vinden alsof ze in de code staan
|
||||||
|
cp -rf /var/www/atom-media/public_assets/* .next/standalone/public/
|
||||||
|
|
||||||
# 8. Restart
|
# 6. Permissions & Restart
|
||||||
|
sudo chown -R www-data:www-data .next/standalone/
|
||||||
sudo systemctl restart atom-nexst.service
|
sudo systemctl restart atom-nexst.service
|
||||||
sleep 3
|
|
||||||
if ! systemctl is-active --quiet atom-nexst.service; then
|
|
||||||
echo "ERROR: Service failed to start!" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "--- Deployment successfully completed ---"
|
echo "--- Deployment successfully completed ---"
|
||||||
Reference in new issue
Block a user