diff --git a/Dockerfile b/Dockerfile index 38aa4560..d2b702fc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -63,9 +63,6 @@ RUN apt-get update && apt-get install -y \ wget \ && rm -rf /var/lib/apt/lists/* -# Create non-root user -RUN groupadd -g 1001 -r appgroup && \ - useradd -u 1001 -r -g appgroup appuser # Set working directory WORKDIR /app @@ -79,11 +76,21 @@ COPY --from=builder /code /app # Create directories with proper permissions RUN mkdir -p /app/results /app/datasets && \ - chown -R appuser:appgroup /app && \ + + chmod -R 777 /app/results /app/datasets && \ chmod -R 755 /app -# Switch to non-root user -USER appuser +# Create entrypoint script to handle user permissions +RUN echo '#!/bin/bash\n\ +# Handle user permissions for volume mounts\n\ +if [ "$1" = "run.py" ]; then\n\ + # Ensure results directory is writable\n\ + mkdir -p /app/results\n\ + chmod 777 /app/results\n\ +fi\n\ +exec python "$@"' > /app/entrypoint.sh && \ + chmod +x /app/entrypoint.sh + # Health check HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ @@ -93,7 +100,9 @@ HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ EXPOSE 6379 6380 # Set entrypoint -ENTRYPOINT ["python"] + +ENTRYPOINT ["/app/entrypoint.sh"] + # Default command (show help) CMD ["run.py", "--help"] diff --git a/README.md b/README.md index 2f7ab5b2..7a1e32eb 100644 --- a/README.md +++ b/README.md @@ -84,14 +84,16 @@ docker pull filipe958/vector-db-benchmark:latest # Run with help docker run --rm filipe958/vector-db-benchmark:latest run.py --help -# Basic Redis benchmark with local Redis -docker run --rm --network=host filipe958/vector-db-benchmark:latest \ - run.py --host localhost --engines redis --dataset random-100 --experiment redis-default-simple -# With results output (mount current directory) +# Basic Redis benchmark with local Redis (recommended) docker run --rm -v $(pwd)/results:/app/results --network=host \ filipe958/vector-db-benchmark:latest \ - run.py --host localhost --engines redis --dataset random-100 --experiment redis-default-simple + run.py --host localhost --engines redis-default-simple --dataset random-100 + +# Without results output +docker run --rm --network=host filipe958/vector-db-benchmark:latest \ + run.py --host localhost --engines redis-default-simple --dataset random-100 + ``` ### Using with Redis @@ -103,11 +105,14 @@ For testing with Redis, start a Redis container first: docker run -d --name redis-test -p 6379:6379 redis:8.2-rc1-bookworm # Run benchmark against Redis -docker run --rm --network=host filipe958/vector-db-benchmark:latest \ - run.py --host localhost --engines redis --dataset random-100 --experiment redis-default-simple + +docker run --rm -v $(pwd)/results:/app/results --network=host \ + filipe958/vector-db-benchmark:latest \ + run.py --host localhost --engines redis-default-simple --dataset random-100 # Or use the convenience script -./docker-run.sh -H localhost -e redis -d random-100 -x redis-default-simple +./docker-run.sh -H localhost -e redis-default-simple -d random-100 + # Clean up Redis container when done docker stop redis-test && docker rm redis-test @@ -149,20 +154,18 @@ poetry install Run the benchmark: ```bash -Usage: run.py [OPTIONS] - - Example: python3 -m run --engines *-m-16-* --datasets glove-* - -Options: - --engines TEXT [default: *] - --datasets TEXT [default: *] - --host TEXT [default: localhost] - --skip-upload / --no-skip-upload - [default: no-skip-upload] - --install-completion Install completion for the current shell. - --show-completion Show completion for the current shell, to - copy it or customize the installation. - --help Show this message and exit. +# Basic usage examples +python run.py --engines redis-default-simple --dataset random-100 +python run.py --engines redis-default-simple --dataset glove-25-angular +python run.py --engines "*-m-16-*" --dataset "glove-*" + +# Docker usage (recommended) +docker run --rm -v $(pwd)/results:/app/results --network=host \ + filipe958/vector-db-benchmark:latest \ + run.py --host localhost --engines redis-default-simple --dataset random-100 + +# Get help +python run.py --help ``` Command allows you to specify wildcards for engines and datasets.