-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdeploy-macos-dev.sh
More file actions
executable file
Β·138 lines (114 loc) Β· 3.62 KB
/
deploy-macos-dev.sh
File metadata and controls
executable file
Β·138 lines (114 loc) Β· 3.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#!/bin/bash
# macOS Mini Development Server Deployment
# Usage: ./deploy-macos-dev.sh
set -e
echo "π Starting macOS Mini development deployment..."
# Configuration for macOS server
REMOTE_HOST="121.130.214.186"
REMOTE_PORT="2202"
REMOTE_USER="decoded"
REMOTE_DIR="/Users/decoded/decoded-app"
# Check if we're in the right directory
if [ ! -f "package.json" ]; then
echo "β Error: package.json not found. Please run this script from the project root."
exit 1
fi
# Build the application
echo "π¨ Building the application..."
yarn build
if [ $? -ne 0 ]; then
echo "β Build failed!"
exit 1
fi
echo "β
Build completed successfully!"
# Create deployment package
echo "π¦ Creating deployment package..."
DEPLOY_DIR="deploy-package"
rm -rf $DEPLOY_DIR
mkdir -p $DEPLOY_DIR
# Copy necessary files
cp -r .next $DEPLOY_DIR/
cp -r public $DEPLOY_DIR/
cp package.json $DEPLOY_DIR/
cp yarn.lock $DEPLOY_DIR/
cp next.config.ts $DEPLOY_DIR/
cp tailwind.config.ts $DEPLOY_DIR/
cp tsconfig.json $DEPLOY_DIR/
cp -r src $DEPLOY_DIR/
# Create development environment file
echo "π Creating development environment file..."
cat > $DEPLOY_DIR/.env.production << EOF
NODE_ENV=development
NEXT_PUBLIC_API_BASE_URL=https://dev.decoded.style
API_BASE_URL=https://dev.decoded.style
NEXT_PUBLIC_GOOGLE_CLIENT_ID=your_google_client_id_here
NEXT_PUBLIC_GOOGLE_REDIRECT_URI=https://121.130.214.186:3000/auth/callback
PORT=3000
EOF
# Create PM2 ecosystem file for macOS
cat > $DEPLOY_DIR/ecosystem.config.js << EOF
module.exports = {
apps: [
{
name: 'decoded-app-dev',
script: 'yarn',
args: 'start',
cwd: '$REMOTE_DIR',
instances: 1,
autorestart: true,
watch: false,
max_memory_restart: '1G',
env: {
NODE_ENV: 'development',
PORT: 3000,
NEXT_PUBLIC_API_BASE_URL: 'https://dev.decoded.style',
API_BASE_URL: 'https://dev.decoded.style'
}
}
]
};
EOF
# Create deployment archive
echo "π¦ Creating deployment archive..."
tar -czf decoded-app-macos-dev.tar.gz -C $DEPLOY_DIR .
# Upload to macOS server
echo "π€ Uploading to macOS server..."
scp -P $REMOTE_PORT decoded-app-macos-dev.tar.gz $REMOTE_USER@$REMOTE_HOST:/tmp/
# Execute remote deployment
echo "π§ Executing remote deployment on macOS..."
ssh -p $REMOTE_PORT $REMOTE_USER@$REMOTE_HOST << 'EOF'
set -e
echo "π§ Starting macOS development deployment process..."
# Create app directory if it doesn't exist
mkdir -p /Users/decoded/decoded-app
# Stop existing application if running
if pm2 list | grep -q "decoded-app-dev"; then
echo "π Stopping existing development application..."
pm2 stop decoded-app-dev
pm2 delete decoded-app-dev
fi
# Extract deployment package
echo "π¦ Extracting deployment package..."
cd /Users/decoded/decoded-app
tar -xzf /tmp/decoded-app-macos-dev.tar.gz
rm /tmp/decoded-app-macos-dev.tar.gz
# Install dependencies
echo "π¦ Installing dependencies..."
yarn install --frozen-lockfile
# Start with PM2
echo "π Starting development application with PM2..."
pm2 start ecosystem.config.js
pm2 save
echo "β
macOS development deployment completed successfully!"
echo "π Development application should be available at: http://121.130.214.186:3000"
echo "π Using development API: https://dev.decoded.style"
echo "π PM2 Status:"
pm2 status
EOF
# Cleanup local files
echo "π§Ή Cleaning up local files..."
rm -rf $DEPLOY_DIR
rm decoded-app-macos-dev.tar.gz
echo "β
macOS development deployment completed successfully!"
echo "π Your development application should now be running at: http://121.130.214.186:3000"
echo "π API Base URL: https://dev.decoded.style"