Skip to content

Commit 7b98477

Browse files
committed
feat(docker): add env variable to disable firebase functions
1 parent fb3dba3 commit 7b98477

File tree

2 files changed

+25
-15
lines changed

2 files changed

+25
-15
lines changed

.github/workflows/docker-push-dev.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
REPO_NAME: ghcr.io/${{ github.repository }}
2222
run: |
2323
REPO_NAME=$(echo $REPO_NAME | tr '[:upper:]' '[:lower:]')
24-
TAG="0.3.1-dev"
24+
TAG="0.3.2-dev"
2525
2626
# Docker
2727
echo "docker_image_name=${REPO_NAME}" >> $GITHUB_OUTPUT

docker_entrypoint.sh

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,28 @@
22

33
set -e
44

5+
FIREBASE_EMULATOR_FUNCTIONS_DISABLED=${FIREBASE_EMULATOR_FUNCTIONS_DISABLED:-false}
6+
57
BASE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
68
FIREBASE_FUNCTIONS_DIR="$BASE_DIR/functions/"
79

8-
cd "$BASE_DIR"
910

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"
1812

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
2227

2328
# PIDs
2429
pid=0
@@ -49,8 +54,13 @@ trap graceful_shutdown SIGINT SIGTERM
4954
# Start Firebase emulator in background
5055
echo "[INFO] Starting Firebase emulator..."
5156
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
5464

5565

5666
# Keep container alive with dummy tail

0 commit comments

Comments
 (0)