-
Notifications
You must be signed in to change notification settings - Fork 63
/
docker-entrypoint.sh
46 lines (40 loc) · 1012 Bytes
/
docker-entrypoint.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
#!/usr/bin/env bash
set -euo pipefail
# Define supported modes
SUPPORTED_MODES=("build" "zip" "dev")
# Function to display usage information
usage() {
echo "Usage: $0 [build|zip|dev]"
echo " build: Build the extension"
echo " zip: Build and zip the extension"
echo " dev: Run in development mode with HMR"
exit 1
}
# Check if BUILD_MODE is set, otherwise use the first argument
if [ -n "${BUILD_MODE:-}" ]; then
mode="$BUILD_MODE"
elif [ $# -eq 1 ]; then
mode="$1"
else
usage
fi
# Validate the mode
if [[ ! " ${SUPPORTED_MODES[*]} " =~ " ${mode} " ]]; then
echo "Error: Invalid mode '${mode}'" >&2
usage
fi
# Execute the appropriate command based on the mode
case "$mode" in
build)
echo "Building extension..."
exec pnpm run build
;;
zip)
echo "Building and zipping extension..."
exec pnpm run zip
;;
dev)
echo "Running in development mode with HMR..."
exec pnpm run dev
;;
esac