Skip to content

Commit c99eb78

Browse files
YedPoolclaude
andcommitted
Fix LiveKit binary download validation
- Add file size validation (must be >1MB) - Show contents of small files that are likely error pages - Add curl -f flag to fail on HTTP errors - Enhanced logging to show actual file contents 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 850a7f2 commit c99eb78

2 files changed

Lines changed: 20 additions & 7 deletions

File tree

livekit-server/Dockerfile

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ RUN pip install --no-cache-dir -r requirements.txt
1919
# Copy application code
2020
COPY main.py .
2121

22-
# Download LiveKit server binary during build with better debugging
22+
# Download LiveKit server binary during build with validation
2323
RUN echo "System info:" && \
2424
uname -a && \
2525
dpkg --print-architecture && \
@@ -34,13 +34,20 @@ RUN echo "System info:" && \
3434
fi && \
3535
download_url="https://github.com/livekit/livekit/releases/latest/download/livekit-server_linux_${binary_arch}" && \
3636
echo "Downloading LiveKit server from: $download_url" && \
37-
curl -L "$download_url" -o /usr/local/bin/livekit-server && \
38-
echo "Download completed, file info:" && \
37+
curl -L -f --retry 3 --retry-delay 2 "$download_url" -o /usr/local/bin/livekit-server && \
38+
echo "Download completed, validating..." && \
3939
ls -la /usr/local/bin/livekit-server && \
40+
file_size=$(stat -c%s /usr/local/bin/livekit-server) && \
41+
echo "File size: $file_size bytes" && \
42+
if [ "$file_size" -lt 1000000 ]; then \
43+
echo "ERROR: Downloaded file is too small ($file_size bytes), likely an error page" && \
44+
echo "File contents:" && \
45+
head -c 500 /usr/local/bin/livekit-server && \
46+
exit 1; \
47+
fi && \
4048
file /usr/local/bin/livekit-server && \
4149
chmod +x /usr/local/bin/livekit-server && \
42-
echo "Final binary info:" && \
43-
file /usr/local/bin/livekit-server && \
50+
echo "Binary validation successful" && \
4451
ldd /usr/local/bin/livekit-server || echo "ldd failed - static binary or missing dependencies"
4552

4653
# Create directory for config files

livekit-server/main.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,13 +168,19 @@ def start(self):
168168
logger.info(f" Size: {stat_info.st_size} bytes")
169169
logger.info(f" Mode: {oct(stat_info.st_mode)}")
170170

171-
# Check file type
171+
# Check file type and contents
172172
try:
173173
import subprocess
174174
result = subprocess.run(['file', binary_path], capture_output=True, text=True)
175175
logger.info(f" File type: {result.stdout.strip()}")
176+
177+
# Show file contents since it's only 9 bytes
178+
with open(binary_path, 'rb') as f:
179+
content = f.read()
180+
logger.info(f" File contents (hex): {content.hex()}")
181+
logger.info(f" File contents (text): {content.decode('utf-8', errors='ignore')}")
176182
except Exception as e:
177-
logger.info(f" Could not determine file type: {e}")
183+
logger.info(f" Could not analyze file: {e}")
178184

179185
# Test if it's executable by trying to run it with --help
180186
try:

0 commit comments

Comments
 (0)