Files
next.orly.dev/cmd/benchmark/Dockerfile.next-orly
mleku 1e9c447fe6 Refactor Neo4j tests and improve tag handling in Cypher
Replaces outdated Neo4j test setup with a robust TestMain, shared test database, and utility functions for test data and migrations. Improves Cypher generation for processing e-tags, p-tags, and other tags to ensure compliance with Neo4j syntax. Added integration test script and updated benchmark reports for Badger backend.
2025-12-04 20:09:24 +00:00

83 lines
2.8 KiB
Docker

# Dockerfile for next.orly.dev relay (benchmark version)
# Uses pure Go build with purego for dynamic libsecp256k1 loading
# Fetches latest tag from git repository instead of local code
# Stage 1: Build stage
# Use Debian-based Go image to match runtime stage (avoids musl/glibc linker mismatch)
FROM golang:1.25-bookworm AS builder
# Install build dependencies
RUN apt-get update && apt-get install -y --no-install-recommends git make && rm -rf /var/lib/apt/lists/*
# Set working directory
WORKDIR /build
# Clone the repository and checkout the latest tag
# Using git.nostrdev.com (primary repo, most up-to-date)
RUN git clone https://git.nostrdev.com/mleku/next.orly.dev.git . && \
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "main") && \
echo "Building ORLY version: ${LATEST_TAG}" && \
git checkout "${LATEST_TAG}"
# Remove local replace directives and update to released version, then download dependencies
RUN sed -i '/^replace .* => \/home/d' go.mod && \
sed -i 's/git.mleku.dev\/mleku\/nostr v1.0.7/git.mleku.dev\/mleku\/nostr v1.0.8/' go.mod && \
go mod tidy && \
go mod download
# Build the relay with CGO disabled (uses purego for crypto)
# Include debug symbols for profiling
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -gcflags "all=-N -l" -o relay .
# Create non-root user (uid 1000) for runtime in builder stage (used by analyzer)
RUN useradd -m -u 1000 appuser && \
chown -R 1000:1000 /build
# Switch to uid 1000 for any subsequent runtime use of this stage
USER 1000:1000
# Final stage
# Use Debian slim instead of Alpine because Debian's libsecp256k1 includes
# Schnorr signatures (secp256k1_schnorrsig_*) and ECDH which Nostr requires.
# Alpine's libsecp256k1 is built without these modules.
FROM debian:bookworm-slim
# Install runtime dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends ca-certificates curl libsecp256k1-1 && \
rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy binary (libsecp256k1.so.1 is already installed via apt)
COPY --from=builder /build/relay /app/relay
# Create runtime user and writable directories
RUN useradd -m -u 1000 appuser && \
mkdir -p /data /profiles /app && \
chown -R 1000:1000 /data /profiles /app
# Expose port
EXPOSE 8080
# Set environment variables
ENV ORLY_DATA_DIR=/data
ENV ORLY_LISTEN=0.0.0.0
ENV ORLY_PORT=8080
ENV ORLY_LOG_LEVEL=off
# Aggressive cache settings to match Badger's cost metric
# Badger tracks ~52MB cost per key, need massive cache for good hit ratio
# Block cache: 16GB to hold ~300 keys in cache
# Index cache: 4GB for index lookups
ENV ORLY_DB_BLOCK_CACHE_MB=16384
ENV ORLY_DB_INDEX_CACHE_MB=4096
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
CMD curl -f http://localhost:8080/ || exit 1
# Drop privileges: run as uid 1000
USER 1000:1000
# Run the relay
CMD ["/app/relay"]