Skip to content

Commit 1926616

Browse files
committed
Refactor Supabase setup to use source compilation instead of binary download
1 parent 2fbb245 commit 1926616

File tree

2 files changed

+18
-40
lines changed

2 files changed

+18
-40
lines changed

bin/install-service.sh

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -106,41 +106,35 @@ fi
106106

107107
echo -e "${GREEN}Dependencies installed.${NC}"
108108

109-
# Install Supabase CLI
110-
echo -e "${YELLOW}Installing Supabase CLI...${NC}"
109+
# Run Supabase setup script
110+
echo -e "${YELLOW}Running Supabase setup script...${NC}"
111111

112112
# Create local bin directory if it doesn't exist
113113
if [ "$EUID" -eq 0 ]; then
114114
sudo -u "$ORIGINAL_USER" mkdir -p "/home/$ORIGINAL_USER/.local/bin"
115-
else
116-
mkdir -p "$HOME/.local/bin"
117-
fi
118-
119-
# Download and install Supabase CLI
120-
SUPABASE_VERSION="1.175.6" # change to latest if needed
121-
BINARY_URL="https://github.com/supabase/cli/releases/download/v$SUPABASE_VERSION/supabase_linux_amd64"
122-
123-
if [ "$EUID" -eq 0 ]; then
124-
echo -e "${YELLOW}Downloading Supabase CLI for $ORIGINAL_USER...${NC}"
125-
sudo -u "$ORIGINAL_USER" curl -L "$BINARY_URL" -o "/home/$ORIGINAL_USER/.local/bin/supabase"
126-
sudo -u "$ORIGINAL_USER" chmod +x "/home/$ORIGINAL_USER/.local/bin/supabase"
127115

128116
# Add to PATH if not already there
129117
if ! grep -q "export PATH=\"\$HOME/.local/bin:\$PATH\"" "/home/$ORIGINAL_USER/.zshrc"; then
130118
echo 'export PATH="$HOME/.local/bin:$PATH"' | sudo -u "$ORIGINAL_USER" tee -a "/home/$ORIGINAL_USER/.zshrc" > /dev/null
131119
fi
120+
121+
# Run the setup script as the original user
122+
echo -e "${YELLOW}Running Supabase setup as $ORIGINAL_USER...${NC}"
123+
sudo -u "$ORIGINAL_USER" zsh -c "cd \"$PROJECT_DIR\" && chmod +x ./bin/supabase-db.sh && ./bin/supabase-db.sh setup"
132124
else
133-
echo -e "${YELLOW}Downloading Supabase CLI...${NC}"
134-
curl -L "$BINARY_URL" -o "$HOME/.local/bin/supabase"
135-
chmod +x "$HOME/.local/bin/supabase"
125+
mkdir -p "$HOME/.local/bin"
136126

137127
# Add to PATH if not already there
138128
if ! grep -q "export PATH=\"\$HOME/.local/bin:\$PATH\"" "$HOME/.zshrc"; then
139129
echo 'export PATH="$HOME/.local/bin:$PATH"' >> "$HOME/.zshrc"
140130
fi
131+
132+
# Run the setup script
133+
echo -e "${YELLOW}Running Supabase setup...${NC}"
134+
cd "$PROJECT_DIR" && chmod +x ./bin/supabase-db.sh && ./bin/supabase-db.sh setup
141135
fi
142136

143-
echo -e "${GREEN}Supabase CLI installed.${NC}"
137+
echo -e "${GREEN}Supabase setup complete.${NC}"
144138

145139
# Reload systemd
146140
echo -e "${YELLOW}Reloading systemd...${NC}"

bin/supabase-db.sh

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -42,25 +42,9 @@ install_cli() {
4242
return 0
4343
fi
4444

45-
SUPABASE_VERSION="2.22.1" # Latest version as of April 2025
45+
SUPABASE_VERSION="2.20.12" # Known working version
4646

47-
# First try to download pre-built binary
48-
echo "Trying to download pre-built binary..."
49-
BINARY_URL="https://github.com/supabase/cli/releases/download/v$SUPABASE_VERSION/supabase_linux_amd64"
50-
51-
curl -L "$BINARY_URL" -o "$HOME/.local/bin/supabase"
52-
chmod +x "$HOME/.local/bin/supabase"
53-
54-
# Check if binary works
55-
if [ -s "$HOME/.local/bin/supabase" ] && "$HOME/.local/bin/supabase" --version &>/dev/null; then
56-
echo -e "${GREEN}Supabase CLI installed from pre-built binary: $("$HOME/.local/bin/supabase" --version 2>&1)${NC}"
57-
return 0
58-
else
59-
echo "Pre-built binary failed, removing it..."
60-
rm -f "$HOME/.local/bin/supabase"
61-
fi
62-
63-
# If binary download failed, compile from source
47+
# Compile from source using ZIP file
6448
echo "Compiling Supabase CLI from source..."
6549

6650
# Check if Go is installed
@@ -80,21 +64,21 @@ install_cli() {
8064
fi
8165

8266
# Download source code
83-
SOURCE_URL="https://github.com/supabase/cli/archive/refs/tags/v$SUPABASE_VERSION.tar.gz"
67+
SOURCE_URL="https://github.com/supabase/cli/archive/refs/tags/v$SUPABASE_VERSION.zip"
8468
TEMP_DIR=$(mktemp -d)
8569

8670
echo "Downloading source code from $SOURCE_URL..."
87-
curl -L "$SOURCE_URL" -o "$TEMP_DIR/supabase-src.tar.gz"
71+
curl -L "$SOURCE_URL" -o "$TEMP_DIR/supabase-src.zip"
8872

8973
# Check if download was successful
90-
if [ ! -s "$TEMP_DIR/supabase-src.tar.gz" ]; then
74+
if [ ! -s "$TEMP_DIR/supabase-src.zip" ]; then
9175
echo -e "${RED}Error: Failed to download Supabase CLI source code${NC}"
9276
rm -rf "$TEMP_DIR"
9377
exit 1
9478
fi
9579

9680
echo "Extracting source code..."
97-
tar -xzf "$TEMP_DIR/supabase-src.tar.gz" -C "$TEMP_DIR"
81+
unzip -q "$TEMP_DIR/supabase-src.zip" -d "$TEMP_DIR"
9882

9983
# Find the extracted directory
10084
SRC_DIR=$(find "$TEMP_DIR" -type d -name "cli-*" | head -n 1)

0 commit comments

Comments
 (0)