|
2 | 2 |
|
3 | 3 | set -e |
4 | 4 |
|
| 5 | +FIREBASE_EMULATOR_FUNCTIONS_DISABLED=${FIREBASE_EMULATOR_FUNCTIONS_DISABLED:-false} |
| 6 | + |
5 | 7 | BASE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" |
6 | 8 | FIREBASE_FUNCTIONS_DIR="$BASE_DIR/functions/" |
7 | 9 |
|
8 | | -cd "$BASE_DIR" |
9 | 10 |
|
10 | | -# NOTE: when we are using mapswipe-firebase as a submodule inside docker, |
11 | | -# the .git directory is not accessible. The parent .git directory is in host |
12 | | -# system not accesssible by the container |
13 | | -# Inside the container, pnpm install fails when we are installing packages from git repository. |
14 | | -# So, we need to switch to /tmp directory as a workaround |
15 | | -echo "[INFO] Installing dependencies for transpiling functions for Firebase..." |
16 | | -cd /tmp/ |
17 | | -pnpm --dir "$FIREBASE_FUNCTIONS_DIR" install --frozen-lockfile |
| 11 | +cd "$BASE_DIR" |
18 | 12 |
|
19 | | -echo "[INFO] Transpiling functions for Firebase..." |
20 | | -cd "$FIREBASE_FUNCTIONS_DIR" |
21 | | -pnpm build |
| 13 | +if [ $FIREBASE_EMULATOR_FUNCTIONS_DISABLED != "true" ]; then |
| 14 | + # NOTE: when we are using mapswipe-firebase as a submodule inside docker, |
| 15 | + # the .git directory is not accessible. The parent .git directory is in host |
| 16 | + # system not accesssible by the container |
| 17 | + # Inside the container, pnpm install fails when we are installing packages from git repository. |
| 18 | + # So, we need to switch to /tmp directory as a workaround |
| 19 | + echo "[INFO] Installing dependencies for transpiling functions for Firebase..." |
| 20 | + cd /tmp/ |
| 21 | + pnpm --dir "$FIREBASE_FUNCTIONS_DIR" install --frozen-lockfile |
| 22 | + |
| 23 | + echo "[INFO] Transpiling functions for Firebase..." |
| 24 | + cd "$FIREBASE_FUNCTIONS_DIR" |
| 25 | + pnpm build |
| 26 | +fi |
22 | 27 |
|
23 | 28 | # PIDs |
24 | 29 | pid=0 |
@@ -49,8 +54,13 @@ trap graceful_shutdown SIGINT SIGTERM |
49 | 54 | # Start Firebase emulator in background |
50 | 55 | echo "[INFO] Starting Firebase emulator..." |
51 | 56 | FIREBASE_EMULATOR_DATA_DIR=${FIREBASE_EMULATOR_DATA_DIR?FIREBASE_EMULATOR_DATA_DIR is required} |
52 | | -firebase emulators:start --import="$FIREBASE_EMULATOR_DATA_DIR" --export-on-exit & |
53 | | -pid="$!" |
| 57 | +if [ $FIREBASE_EMULATOR_FUNCTIONS_DISABLED != "true" ]; then |
| 58 | + firebase emulators:start --import="$FIREBASE_EMULATOR_DATA_DIR" --export-on-exit & |
| 59 | + pid="$!" |
| 60 | +else |
| 61 | + firebase emulators:start --only database,hosting,auth --import="$FIREBASE_EMULATOR_DATA_DIR" --export-on-exit & |
| 62 | + pid="$!" |
| 63 | +fi |
54 | 64 |
|
55 | 65 |
|
56 | 66 | # Keep container alive with dummy tail |
|
0 commit comments