Skip to content

Commit b905e27

Browse files
isaac-chungclaudeMTEB Agent
authored
test: Add HF Space Dockerfile using pre-built leaderboard image (#3838)
* Add HF Space Dockerfile using pre-built leaderboard image Adds a lightweight Dockerfile for HuggingFace Space deployment that uses the pre-built ghcr.io/embeddings-benchmark/mteb/leaderboard image as base. Also adds a workflow to test the Dockerfile. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Delete .github/workflows/hf_space_docker.yml * test: Add CI workflow for HF Space Dockerfile validation --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> Co-authored-by: MTEB Agent <agent@example.com>
1 parent adb5b42 commit b905e27

File tree

2 files changed

+79
-0
lines changed

2 files changed

+79
-0
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Build HF Space Docker Image
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
paths:
7+
- 'Dockerfile.hf-space'
8+
- '.github/workflows/hf_space_docker.yml'
9+
pull_request:
10+
branches: [ main ]
11+
paths:
12+
- 'Dockerfile.hf-space'
13+
- '.github/workflows/hf_space_docker.yml'
14+
workflow_dispatch:
15+
16+
jobs:
17+
build-hf-space:
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v4
23+
24+
- name: Set up Docker Buildx
25+
uses: docker/setup-buildx-action@v3
26+
27+
- name: Build HF Space Docker image
28+
run: |
29+
docker build -f Dockerfile.hf-space -t mteb-hf-space:test .
30+
echo "✅ Docker image built successfully"
31+
32+
- name: Test Docker image
33+
run: |
34+
# Test that the image can be created and the container starts
35+
docker run -d --name mteb-test -p 7860:7860 mteb-hf-space:test
36+
37+
# Give the container a moment to start
38+
sleep 5
39+
40+
# Check if container is running
41+
if docker ps | grep -q mteb-test; then
42+
echo "✅ Container is running"
43+
docker logs mteb-test
44+
else
45+
echo "❌ Container failed to start"
46+
docker logs mteb-test
47+
exit 1
48+
fi
49+
50+
# Clean up
51+
docker stop mteb-test
52+
docker rm mteb-test
53+
54+
- name: Validate HF Space configuration
55+
run: |
56+
# Check that required environment variables and ports are set
57+
docker run --rm mteb-hf-space:test sh -c '
58+
if [ "$GRADIO_SERVER_NAME" = "0.0.0.0" ]; then
59+
echo "✅ GRADIO_SERVER_NAME is correctly set"
60+
else
61+
echo "❌ GRADIO_SERVER_NAME is not set to 0.0.0.0"
62+
exit 1
63+
fi
64+
'
65+
66+
# Check exposed port
67+
EXPOSED_PORT=$(docker inspect mteb-hf-space:test --format='{{range $key, $value := .Config.ExposedPorts}}{{$key}}{{end}}' | grep -o '7860')
68+
if [ "$EXPOSED_PORT" = "7860" ]; then
69+
echo "✅ Port 7860 is exposed"
70+
else
71+
echo "❌ Port 7860 is not exposed"
72+
exit 1
73+
fi

Dockerfile.hf-space

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM ghcr.io/embeddings-benchmark/mteb/leaderboard:latest
2+
3+
ENV GRADIO_SERVER_NAME="0.0.0.0"
4+
EXPOSE 7860
5+
6+
CMD ["make", "run-leaderboard"]

0 commit comments

Comments
 (0)