-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuildShortyShort.sh
More file actions
executable file
·73 lines (48 loc) · 1.59 KB
/
buildShortyShort.sh
File metadata and controls
executable file
·73 lines (48 loc) · 1.59 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
#!/bin/bash
OUTPUT_DIR="output"
DOCKER_MODE=false
# Check for --docker flag
for arg in "$@"; do
if [ "$arg" == "--docker" ]; then
DOCKER_MODE=true
break
fi
done
if [ -d "$OUTPUT_DIR" ]; then
echo "Deleting existing output directory"
rm -rf "$OUTPUT_DIR"
fi
mkdir -p "$OUTPUT_DIR/API" "$OUTPUT_DIR/Web"
cd API || { echo "API directory not found"; exit 1; }
if [ ! -d "node_modules" ]; then
echo "node_modules not found in API. Running npm install..."
npm install
fi
echo "Copying node_modules to ../$OUTPUT_DIR/API"
cp -r node_modules "../$OUTPUT_DIR/API/"
echo "Copying .env, package.json, ShortyShortAPI.js to ../$OUTPUT_DIR/API"
cp .env package.json ShortyShortAPI.js "../$OUTPUT_DIR/API/"
cd ../Web || { echo "Web directory not found"; exit 1; }
if [ ! -d "node_modules" ]; then
echo "node_modules not found in Web. Running npm install..."
npm install
fi
echo "Running npm build in Web"
npm run build
echo "Copying dist/bundle.js and dist/index.html to ../$OUTPUT_DIR/Web"
cp .env dist/bundle.js dist/index.html "../$OUTPUT_DIR/Web/"
sed -i 's|src="/dist/bundle.js"|src="/bundle.js"|' "../$OUTPUT_DIR/Web/index.html"
cp ../database.json "../$OUTPUT_DIR"
if $DOCKER_MODE; then
echo "Docker mode enabled. Copying Docker-related files and building Docker image."
cp ../Docker/Dockerfile "../$OUTPUT_DIR"
cp ../Docker/docker-compose.yml "../$OUTPUT_DIR"
cd "../$OUTPUT_DIR"
sudo docker buildx build . -t shortyshort
sudo docker stop ShortyShort
sudo docker rm ShortyShort
sudo docker compose up -d
cd ..
rm -rf "$OUTPUT_DIR"
fi
echo "Build completed successfully."