Deployment Script

This commit is contained in:
Possible
2025-01-30 17:41:31 +01:00
parent a8864f230a
commit adf99feb3f
5 changed files with 85 additions and 87 deletions
+2 -2
View File
@@ -8,8 +8,8 @@ pnpm-debug.log*
lerna-debug.log*
node_modules
# dist
# dist-ssr
dist
dist-ssr
*.local
# Editor directories and files
+83
View File
@@ -0,0 +1,83 @@
#!/bin/bash
# Exit on any error
set -e
echo "🚀 Starting deployment process..."
# Configuration
DEPLOY_PATH="/var/www/typescripttest.manaknightdigital.com"
NGINX_CONFIG="/etc/nginx/sites-available/typescripttest.manaknightdigital.com"
# Build the application
echo "📦 Building application..."
npm install
npm run build
# Ensure deploy directory exists
echo "📁 Setting up deployment directory..."
sudo mkdir -p $DEPLOY_PATH
# Copy build files to deployment directory
echo "📋 Copying files to deployment directory..."
sudo cp -r dist/* $DEPLOY_PATH/
# Set proper permissions
echo "🔒 Setting permissions..."
sudo chown -R www-data:www-data $DEPLOY_PATH
sudo chmod -R 755 $DEPLOY_PATH
# Create Nginx configuration if it doesn't exist
if [ ! -f "$NGINX_CONFIG" ]; then
echo "📝 Creating Nginx configuration..."
sudo tee $NGINX_CONFIG > /dev/null <<EOF
server {
listen 80;
server_name typescripttest.manaknightdigital.com;
root $DEPLOY_PATH;
index index.html;
location / {
try_files \$uri \$uri/ /index.html;
}
# Add security headers
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
# Enable gzip compression
gzip on;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
}
EOF
# Create symlink to enable the site
sudo ln -s $NGINX_CONFIG /etc/nginx/sites-enabled/
fi
# Test Nginx configuration
echo "🔍 Testing Nginx configuration..."
sudo nginx -t
# Reload Nginx to apply changes
echo "🔄 Reloading Nginx..."
sudo systemctl reload nginx
# Setup SSL with Certbot if not already configured
if [ ! -f "/etc/letsencrypt/live/typescripttest.manaknightdigital.com/fullchain.pem" ]; then
echo "🔒 Setting up SSL with Let's Encrypt..."
sudo certbot --nginx \
--non-interactive \
--agree-tos \
--redirect \
--staple-ocsp \
--must-staple \
--email ryan@manaknight.com \
-d typescripttest.manaknightdigital.com
# Reload Nginx again after SSL configuration
sudo systemctl reload nginx
fi
echo "✅ Deployment completed successfully!"
-70
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
-14
View File
@@ -1,14 +0,0 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React + TS</title>
<script type="module" crossorigin src="/assets/index-B5ak76EG.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-Dwt_rv6c.css">
</head>
<body>
<div id="root"></div>
</body>
</html>