Dockerfile raw

   1  # Multi-stage Dockerfile for ORLY relay + bridge (unified binary)
   2  #
   3  # Default: runs the relay (port 3334)
   4  # Bridge:  docker run orly bridge (port 2525)
   5  # Launcher: docker run orly launcher (relay + bridge + db)
   6  
   7  # Stage 1: Build stage
   8  # Use Debian-based Go image to match runtime stage (avoids musl/glibc linker mismatch)
   9  FROM golang:1.25-bookworm AS builder
  10  
  11  # Install build dependencies
  12  RUN apt-get update && apt-get install -y --no-install-recommends git make && rm -rf /var/lib/apt/lists/*
  13  
  14  # Set working directory
  15  WORKDIR /build
  16  
  17  # Copy go mod files. The local replace target must exist before go mod download
  18  # resolves the module graph.
  19  COPY go.mod go.sum ./
  20  COPY pkg/nostr/crypto/mls/go.mod pkg/nostr/crypto/mls/go.sum ./pkg/nostr/crypto/mls/
  21  RUN go mod download
  22  
  23  # Copy source code
  24  COPY . .
  25  
  26  # Build the unified binary (includes all subcommands: relay, bridge, db, acl, launcher)
  27  RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o orly -ldflags="-w -s" ./cmd/orly
  28  
  29  # Stage 2: Runtime stage
  30  # Use Debian slim instead of Alpine because Debian's libsecp256k1 includes
  31  # Schnorr signatures (secp256k1_schnorrsig_*) and ECDH which Nostr requires.
  32  # Alpine's libsecp256k1 is built without these modules.
  33  FROM debian:bookworm-slim
  34  
  35  # Install runtime dependencies
  36  RUN apt-get update && \
  37      apt-get install -y --no-install-recommends ca-certificates curl libsecp256k1-1 && \
  38      rm -rf /var/lib/apt/lists/*
  39  
  40  # Create app user
  41  RUN groupadd -g 1000 orly && \
  42      useradd -m -u 1000 -g orly orly
  43  
  44  # Set working directory
  45  WORKDIR /app
  46  
  47  # Copy binary (libsecp256k1.so.1 is already installed via apt)
  48  COPY --from=builder /build/orly /app/orly
  49  
  50  # Create data and DKIM directories
  51  RUN mkdir -p /data /dkim && chown -R orly:orly /data /dkim /app
  52  
  53  # Switch to app user
  54  USER orly
  55  
  56  # Expose ports: 3334=relay WebSocket, 2525=bridge SMTP inbound
  57  EXPOSE 3334 2525
  58  
  59  # Health check (relay mode — override for bridge mode in compose)
  60  HEALTHCHECK --interval=10s --timeout=5s --start-period=20s --retries=3 \
  61      CMD curl -f http://localhost:3334/ || exit 1
  62  
  63  # Set default environment variables
  64  ENV ORLY_LISTEN=0.0.0.0 \
  65      ORLY_PORT=3334 \
  66      ORLY_DATA_DIR=/data \
  67      ORLY_LOG_LEVEL=info
  68  
  69  # Run the binary (default: relay; pass "bridge" to run the email bridge)
  70  ENTRYPOINT ["/app/orly"]
  71