Skip to content

Commit b3992aa

Browse files
committed
feat: integrate Vercel environment variable fetching script and update Dockerfile for nodemon and vercel installation
1 parent 6a12903 commit b3992aa

File tree

4 files changed

+45
-28
lines changed

4 files changed

+45
-28
lines changed

apps/browserless/Dockerfile.production

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ RUN npm run install:debugger
2222

2323
WORKDIR /app
2424
USER root
25-
RUN npm install -g nodemon
25+
RUN npm install -g nodemon vercel
2626
RUN mkdir -p /app
2727

2828
COPY out/ /app/extension
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/bash
2+
3+
# Check if VERCEL_TOKEN is set
4+
if [ -z "$VERCEL_TOKEN" ]; then
5+
echo "Error: VERCEL_TOKEN is not set"
6+
exit 1
7+
fi
8+
if [ -z "$VERCEL_ORG_ID" ]; then
9+
echo "Error: VERCEL_ORG_ID is not set"
10+
exit 1
11+
fi
12+
if [ -z "$VERCEL_PROJECT_ID" ]; then
13+
echo "Error: VERCEL_PROJECT_ID is not set"
14+
exit 1
15+
fi
16+
17+
# Create .vercel directory if it doesn't exist
18+
cd /app
19+
mkdir -p .vercel
20+
echo "{
21+
\"orgId\": \"$VERCEL_ORG_ID\",
22+
\"projectId\": \"$VERCEL_PROJECT_ID\"
23+
}" >.vercel/project.json
24+
25+
# Fetch Vercel environment variables
26+
vercel env pull --environment=production --token=$VERCEL_TOKEN .env.cloud
27+
echo "Vercel environment variables fetched successfully"
28+
29+
# Merge .env.cloud into .env.production
30+
touch .env.production # Create if it doesn't exist
31+
while IFS= read -r line || [[ -n "$line" ]]; do
32+
if [[ ! "$line" =~ ^# && -n "$line" ]]; then
33+
# Extract key (everything before the first =)
34+
key="${line%%=*}"
35+
if [ -n "$key" ]; then
36+
# Remove the key and its value from .env.production if it exists
37+
sed -i "/^$key=/d" .env.production
38+
# Append the line from .env.cloud to .env.production
39+
echo "$line" >>.env.production
40+
fi
41+
fi
42+
done <.env.cloud
43+
echo "Environment variables merged into .env.production successfully"

apps/browserless/server/scripts/start-ws-server.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
if [[ "$@" == *--cloud* ]]; then
44
echo "Starting in cloud environment"
5-
bash /app/scripts/fetch-vercel-envs.sh
6-
bash /app/scripts/pull-envs-for-all-packages.sh
5+
bash /app/server/scripts/fetch-vercel-envs.sh
76
fi
87

98
dumb-init -- node /app/server/kill-server.js $@ &

scripts/fetch-vercel-envs.sh

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)