-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·61 lines (47 loc) · 1.17 KB
/
build.sh
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
#!/bin/bash
set -e # Exit immediately if a command exits with a non-zero status
echo "NODE_ENV is: $NODE_ENV"
echo "Checking DATABASE_URL..."
if [ -z "$DATABASE_URL" ]; then
echo "DATABASE_URL is not set!"
exit 1
fi
# Set environment
export NODE_VERSION=18.18.0
export NODE_ENV=production
# Activate npm
corepack prepare npm@latest --activate
# Frontend build
cd frontend
rm -rf node_modules package-lock.json dist
npm cache clean --force
npm install
npm run build
cd ..
# Backend build
cd backend
rm -rf node_modules package-lock.json dist
npm cache clean --force
# Install all dependencies (including devDependencies)
npm install
# Generate Prisma client
npx prisma generate
# Database setup
echo "Pushing database schema..."
npx prisma db push --accept-data-loss
echo "Running database seed..."
npm run seed || {
echo "Seeding failed, but continuing build..."
}
# Build TypeScript
npm run build || {
echo "TypeScript build failed"
exit 1
}
# Create frontend directory and copy build files
mkdir -p dist/frontend/dist
cp -r ../frontend/dist/* dist/frontend/dist/
chmod -R 755 dist/frontend/dist
# Remove dev dependencies after build
npm prune --production
cd ..