Skip to content

Commit

Permalink
Fix production deployment issues:
Browse files Browse the repository at this point in the history
- Update app.blade.php to handle production assets correctly
- Fix Input component import in BarriersTab.jsx
- Configure vite.config.js for production
- Add deployment script for automating prod updates
  • Loading branch information
sudoshi committed Feb 22, 2025
1 parent f4143d5 commit 6174531
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 5 deletions.
46 changes: 46 additions & 0 deletions deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/bash
# Deploy script for Zephyrus

# Exit on error
set -e

echo "Starting deployment process..."

# Switch to the project directory
cd "$(dirname "$0")"

echo "Building assets..."
# Build assets
NODE_ENV=production npm run build

echo "Syncing to production..."
# Sync to production (excluding node_modules, .git, etc)
sudo rsync -av --exclude 'node_modules' \
--exclude '.git' \
--exclude '.env' \
--exclude 'storage/logs/*' \
--exclude 'storage/framework/cache/*' \
--exclude '.github' \
--exclude 'tests' \
--exclude 'deploy.sh' \
/home/acumenus/GitHub/Zephyrus/ /var/www/Zephyrus/

echo "Setting permissions..."
# Set proper permissions
sudo chown -R www-data:www-data /var/www/Zephyrus/storage
sudo chown -R www-data:www-data /var/www/Zephyrus/bootstrap/cache
sudo chown -R www-data:www-data /var/www/Zephyrus/public/build

echo "Clearing Laravel caches..."
# Clear Laravel caches
cd /var/www/Zephyrus
php artisan cache:clear
php artisan view:clear
php artisan config:clear
php artisan route:clear

echo "Restarting Apache..."
# Restart Apache
sudo systemctl restart apache2

echo "Deployment completed successfully!"
6 changes: 3 additions & 3 deletions resources/js/Pages/Improvement/PDSA/BarriersTab.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import React, { useState } from 'react';
import { router } from '@inertiajs/react';
import { barriers as mockBarriers } from '@/mock-data/pdsa';
import { Button } from '@/Components/ui/button';
import { Input } from '@/Components/ui/input';
import { Textarea } from '@/Components/ui/textarea';
import { Label } from '@/Components/ui/label';
import Input from '@/Components/ui/input';
import Textarea from '@/Components/ui/textarea';
import Label from '@/Components/ui/label';
import {
Table,
TableBody,
Expand Down
12 changes: 10 additions & 2 deletions resources/views/app.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,16 @@
<link href="https://fonts.bunny.net/css?family=figtree:400,500,600&display=swap" rel="stylesheet" />

<!-- Scripts -->
@viteReactRefresh
@vite(['resources/js/app.jsx', "resources/js/Pages/{$page['component']}.jsx"])
@production
@php
$manifest = json_decode(file_get_contents(public_path('build/manifest.json')), true);
@endphp
<link rel="stylesheet" href="/build/{{ $manifest['resources/js/app.jsx']['css'][0] }}">
<script type="module" src="/build/{{ $manifest['resources/js/app.jsx']['file'] }}"></script>
@else
@viteReactRefresh
@vite(['resources/js/app.jsx', "resources/js/Pages/{$page['component']}.jsx"])
@endproduction
@inertiaHead
</head>
<body class="font-sans antialiased">
Expand Down
6 changes: 6 additions & 0 deletions vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ import laravel from 'laravel-vite-plugin';
import react from '@vitejs/plugin-react';

export default defineConfig({
server: {
host: '0.0.0.0',
hmr: {
host: 'localhost'
}
},
plugins: [
laravel({
input: 'resources/js/app.jsx',
Expand Down

0 comments on commit 6174531

Please sign in to comment.